| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Net.Security; |
| | | 6 | | using System.Reflection; |
| | | 7 | | using CoreWCF.Security; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF.Description |
| | | 10 | | { |
| | | 11 | | public class MessagePartDescription |
| | | 12 | | { |
| | | 13 | | private ProtectionLevel _protectionLevel; |
| | | 14 | | private bool _hasProtectionLevel; |
| | | 15 | | |
| | | 16 | | private ICustomAttributeProvider _additionalAttributesProvider; |
| | | 17 | | |
| | 4886 | 18 | | public MessagePartDescription(string name, string ns) |
| | | 19 | | { |
| | 4886 | 20 | | if (name == null) |
| | | 21 | | { |
| | 0 | 22 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name), SR.SFxParameterNameCannot |
| | | 23 | | } |
| | | 24 | | |
| | 4886 | 25 | | XmlName = new XmlName(name, true /*isEncoded*/); |
| | | 26 | | |
| | 4886 | 27 | | if (!string.IsNullOrEmpty(ns)) |
| | | 28 | | { |
| | 4879 | 29 | | NamingHelper.CheckUriParameter(ns, nameof(ns)); |
| | | 30 | | } |
| | | 31 | | |
| | 4886 | 32 | | Namespace = ns; |
| | 4886 | 33 | | } |
| | | 34 | | |
| | 96 | 35 | | internal MessagePartDescription(MessagePartDescription other) |
| | | 36 | | { |
| | 96 | 37 | | XmlName = other.XmlName; |
| | 96 | 38 | | Namespace = other.Namespace; |
| | 96 | 39 | | Index = other.Index; |
| | 96 | 40 | | Type = other.Type; |
| | 96 | 41 | | SerializationPosition = other.SerializationPosition; |
| | 96 | 42 | | _hasProtectionLevel = other._hasProtectionLevel; |
| | 96 | 43 | | _protectionLevel = other._protectionLevel; |
| | 96 | 44 | | MemberInfo = other.MemberInfo; |
| | 96 | 45 | | Multiple = other.Multiple; |
| | 96 | 46 | | _additionalAttributesProvider = other._additionalAttributesProvider; |
| | | 47 | | //this.baseType = other.baseType; |
| | | 48 | | //this.uniquePartName = other.uniquePartName; |
| | 96 | 49 | | } |
| | | 50 | | |
| | 0 | 51 | | internal MessagePartDescription(MessagePartDescription other, string name, string ns) : this(other) |
| | | 52 | | { |
| | 0 | 53 | | XmlName = new XmlName(name, true /*isEncoded*/); |
| | 0 | 54 | | Namespace = ns; |
| | 0 | 55 | | } |
| | | 56 | | |
| | | 57 | | public virtual MessagePartDescription Clone() |
| | | 58 | | { |
| | 96 | 59 | | return new MessagePartDescription(this); |
| | | 60 | | } |
| | | 61 | | |
| | 11561 | 62 | | internal XmlName XmlName { get; } |
| | | 63 | | |
| | | 64 | | public string Name |
| | | 65 | | { |
| | 11321 | 66 | | get { return XmlName.EncodedName; } |
| | | 67 | | } |
| | | 68 | | |
| | 13085 | 69 | | public string Namespace { get; } |
| | | 70 | | |
| | 48877 | 71 | | public Type Type { get; set; } |
| | | 72 | | |
| | 7791 | 73 | | public int Index { get; set; } |
| | | 74 | | |
| | 5060 | 75 | | public bool Multiple { get; set; } |
| | | 76 | | |
| | | 77 | | public ProtectionLevel ProtectionLevel |
| | | 78 | | { |
| | 0 | 79 | | get { return _protectionLevel; } |
| | | 80 | | set |
| | | 81 | | { |
| | 0 | 82 | | if (!ProtectionLevelHelper.IsDefined(value)) |
| | | 83 | | { |
| | 0 | 84 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val |
| | | 85 | | } |
| | | 86 | | |
| | 0 | 87 | | _protectionLevel = value; |
| | 0 | 88 | | _hasProtectionLevel = true; |
| | 0 | 89 | | } |
| | | 90 | | } |
| | 497 | 91 | | public MemberInfo MemberInfo { get; set; } |
| | | 92 | | |
| | 0 | 93 | | internal bool HasProtectionLevel => false; |
| | | 94 | | |
| | | 95 | | internal ICustomAttributeProvider AdditionalAttributesProvider |
| | | 96 | | { |
| | 181 | 97 | | get { return _additionalAttributesProvider ?? MemberInfo; } |
| | 9228 | 98 | | set { _additionalAttributesProvider = value; } |
| | | 99 | | } |
| | | 100 | | |
| | 451 | 101 | | internal string UniquePartName { get; set; } |
| | | 102 | | |
| | 415 | 103 | | internal int SerializationPosition { get; set; } |
| | | 104 | | } |
| | | 105 | | } |