| | | 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.Configuration; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Configuration |
| | | 8 | | { |
| | | 9 | | internal class ExtensionElement : ConfigurationElement |
| | | 10 | | { |
| | | 11 | | private string _typeName; |
| | | 12 | | |
| | 16 | 13 | | public ExtensionElement() |
| | | 14 | | { |
| | 16 | 15 | | } |
| | | 16 | | |
| | | 17 | | public ExtensionElement(string name) |
| | 16 | 18 | | : this() |
| | | 19 | | { |
| | 16 | 20 | | if (string.IsNullOrEmpty(name)) |
| | | 21 | | { |
| | 0 | 22 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name)); |
| | | 23 | | } |
| | | 24 | | |
| | 16 | 25 | | Name = name; |
| | 16 | 26 | | } |
| | | 27 | | |
| | | 28 | | public ExtensionElement(string name, string type) |
| | 16 | 29 | | : this(name) |
| | | 30 | | { |
| | 16 | 31 | | if (string.IsNullOrEmpty(type)) |
| | | 32 | | { |
| | 0 | 33 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(type)); |
| | | 34 | | } |
| | | 35 | | |
| | 16 | 36 | | Type = type; |
| | 16 | 37 | | } |
| | | 38 | | |
| | | 39 | | [ConfigurationProperty(ConfigurationStrings.Name, Options = ConfigurationPropertyOptions.IsRequired | Configurat |
| | | 40 | | public string Name |
| | | 41 | | { |
| | 495 | 42 | | get { return (string)base[ConfigurationStrings.Name]; } |
| | | 43 | | set |
| | | 44 | | { |
| | 16 | 45 | | if (string.IsNullOrEmpty(value)) |
| | | 46 | | { |
| | 0 | 47 | | value = string.Empty; |
| | | 48 | | } |
| | 16 | 49 | | base[ConfigurationStrings.Name] = value; |
| | 16 | 50 | | } |
| | | 51 | | } |
| | | 52 | | |
| | | 53 | | [ConfigurationProperty(ConfigurationStrings.Type, Options = ConfigurationPropertyOptions.IsRequired)] |
| | | 54 | | public string Type |
| | | 55 | | { |
| | 147 | 56 | | get { return (string)base[ConfigurationStrings.Type]; } |
| | | 57 | | set |
| | | 58 | | { |
| | 16 | 59 | | if (string.IsNullOrEmpty(value)) |
| | | 60 | | { |
| | 0 | 61 | | value = string.Empty; |
| | | 62 | | } |
| | | 63 | | |
| | 16 | 64 | | base[ConfigurationStrings.Type] = value; |
| | 16 | 65 | | } |
| | | 66 | | } |
| | | 67 | | |
| | | 68 | | internal string TypeName |
| | | 69 | | { |
| | | 70 | | get |
| | | 71 | | { |
| | 114 | 72 | | if (string.IsNullOrEmpty(_typeName)) |
| | | 73 | | { |
| | 16 | 74 | | _typeName = GetTypeName(Type); |
| | | 75 | | } |
| | | 76 | | |
| | 114 | 77 | | return _typeName; |
| | | 78 | | } |
| | | 79 | | } |
| | | 80 | | |
| | | 81 | | internal static string GetTypeName(string fullyQualifiedName) |
| | | 82 | | { |
| | 16 | 83 | | string typeName = fullyQualifiedName.Split(',')[0]; |
| | 16 | 84 | | return typeName.Trim(); |
| | | 85 | | } |
| | | 86 | | } |
| | | 87 | | } |