mscorlib(4.0.0.0) API with additions
WebUtilityElement.cs
4 
6 {
8  public sealed class WebUtilityElement : ConfigurationElement
9  {
10  private class EnumTypeConverter<TEnum> : TypeConverter where TEnum : struct
11  {
12  public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
13  {
14  if (sourceType == typeof(string))
15  {
16  return true;
17  }
18  return base.CanConvertFrom(context, sourceType);
19  }
20 
21  public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
22  {
23  string text = value as string;
24  if (text != null && Enum.TryParse(text, ignoreCase: true, out TEnum result))
25  {
26  return result;
27  }
28  return base.ConvertFrom(context, culture, value);
29  }
30  }
31 
32  private readonly ConfigurationProperty unicodeDecodingConformance = new ConfigurationProperty("unicodeDecodingConformance", typeof(UnicodeDecodingConformance), UnicodeDecodingConformance.Auto, new EnumTypeConverter<UnicodeDecodingConformance>(), null, ConfigurationPropertyOptions.None);
33 
34  private readonly ConfigurationProperty unicodeEncodingConformance = new ConfigurationProperty("unicodeEncodingConformance", typeof(UnicodeEncodingConformance), UnicodeEncodingConformance.Auto, new EnumTypeConverter<UnicodeEncodingConformance>(), null, ConfigurationPropertyOptions.None);
35 
36  private readonly ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
37 
40  [ConfigurationProperty("unicodeDecodingConformance", DefaultValue = UnicodeDecodingConformance.Auto)]
42  {
43  get
44  {
45  return (UnicodeDecodingConformance)base[unicodeDecodingConformance];
46  }
47  set
48  {
49  base[unicodeDecodingConformance] = value;
50  }
51  }
52 
55  [ConfigurationProperty("unicodeEncodingConformance", DefaultValue = UnicodeEncodingConformance.Auto)]
57  {
58  get
59  {
60  return (UnicodeEncodingConformance)base[unicodeEncodingConformance];
61  }
62  set
63  {
64  base[unicodeEncodingConformance] = value;
65  }
66  }
67 
68  protected internal override ConfigurationPropertyCollection Properties
69  {
70  protected get
71  {
72  return properties;
73  }
74  }
75 
78  {
79  properties.Add(unicodeDecodingConformance);
80  properties.Add(unicodeEncodingConformance);
81  }
82  }
83 }
Definition: __Canon.cs:3
Provides contextual information about a component, such as its container and property descriptor.
UnicodeEncodingConformance
Controls how Unicode characters are output by the Overload:System.Net.WebUtility.HtmlEncode methods.
Represents the WebUtility element in the configuration file.
Provides the base class for enumerations.
Definition: Enum.cs:14
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
bool CanConvertFrom(Type sourceType)
Returns whether this converter can convert an object of the given type to the type of this converter.
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
Provides a unified way of converting types of values to other types, as well as for accessing standar...
UnicodeDecodingConformance
Controls how Unicode characters are interpreted by the Overload:System.Net.WebUtility....
WebUtilityElement()
Initializes a new instance of the T:System.Net.Configuration.WebUtilityElement class.