14 private object _Value;
16 private object _SerializedValue;
18 private bool _Deserialized;
20 private bool _IsDirty;
24 private bool _ChangedSinceLastSerialized;
26 private bool _UsingDefaultValue =
true;
65 _Value = Deserialize();
70 _UsingDefaultValue =
false;
71 _ChangedSinceLastSerialized =
true;
80 _ChangedSinceLastSerialized =
true;
82 _UsingDefaultValue =
false;
94 if (_ChangedSinceLastSerialized)
96 _ChangedSinceLastSerialized =
false;
97 _SerializedValue = SerializePropertyValue();
99 return _SerializedValue;
104 _UsingDefaultValue =
false;
105 _SerializedValue = value;
116 return _Deserialized;
120 _Deserialized = value;
128 _Property = property;
131 private bool IsHostedInAspnet()
136 private object Deserialize()
156 memoryStream.
Close();
164 if (IsHostedInAspnet())
166 object[] args =
new object[3]
172 Type type =
Type.GetType(
"System.Web.Management.WebBaseEvent, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError:
true);
187 _UsingDefaultValue =
true;
206 catch (Exception ex2)
208 throw new ArgumentException(
System.
SR.GetString(
"Could_not_create_from_default_value",
Property.
Name, ex2.Message));
213 throw new ArgumentException(
System.
SR.GetString(
"Could_not_create_from_default_value_2",
Property.
Name));
235 private static object GetObjectFromString(Type type,
SettingsSerializeAs serializeAs,
string attValue)
237 if (type == typeof(
string) && (attValue ==
null || attValue.Length < 1 || serializeAs ==
SettingsSerializeAs.String))
241 if (attValue ==
null || attValue.Length < 1)
249 byte[] buffer =
Convert.FromBase64String(attValue);
258 memoryStream?.
Close();
270 if (converter !=
null && converter.CanConvertTo(typeof(
string)) && converter.CanConvertFrom(typeof(
string)))
272 return converter.ConvertFromInvariantString(attValue);
274 throw new ArgumentException(
System.
SR.GetString(
"Unable_to_convert_type_from_string", type.ToString()),
"type");
281 private object SerializePropertyValue()
295 binaryFormatter.
Serialize(memoryStream, _Value);
300 memoryStream.
Close();
304 private static string ConvertObjectToString(
object propValue, Type type,
SettingsSerializeAs serializeAs,
bool throwOnError)
317 if (converter ==
null || !converter.CanConvertTo(typeof(
string)) || !converter.CanConvertFrom(typeof(
string)))
319 throw new ArgumentException(
System.
SR.GetString(
"Unable_to_convert_type_to_string", type.ToString()),
"type");
321 return converter.ConvertToInvariantString(propValue);
329 binaryFormatter.
Serialize(memoryStream, propValue);
330 byte[] inArray = memoryStream.
ToArray();
331 return Convert.ToBase64String(inArray);
335 memoryStream.
Close();
342 xmlSerializer.
Serialize(stringWriter, propValue);
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
bool IsPrimitive
Gets a value indicating whether the T:System.Type is one of the primitive types.
bool ThrowOnErrorSerializing
Gets or sets a value specifying whether an error will be thrown when the property is unsuccessfully s...
Describes a set of security permissions applied to code. This class cannot be inherited.
virtual object DefaultValue
Gets or sets the default value of the T:System.Configuration.SettingsProperty object.
Used internally as the class that represents metadata about an individual configuration property.
Implements a T:System.IO.TextWriter for writing information to a string. The information is stored in...
static TypeConverter GetConverter(object component)
Returns a type converter for the type of the specified component.
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
static AppDomain CurrentDomain
Gets the current application domain for the current T:System.Threading.Thread.
Represents an application domain, which is an isolated environment where applications execute....
SettingsProperty Property
Gets the T:System.Configuration.SettingsProperty object.
bool UsingDefaultValue
Gets a Boolean value specifying whether the value of the T:System.Configuration.SettingsPropertyValue...
SettingsPropertyValue(SettingsProperty property)
Initializes a new instance of the T:System.Configuration.SettingsPropertyValue class,...
SecurityAction
Specifies the security actions that can be performed using declarative security.
virtual void Close()
Closes the current stream and releases any resources (such as sockets and file handles) associated wi...
Creates a stream whose backing store is memory.To browse the .NET Framework source code for this type...
override string ToString()
Returns a string containing the characters written to the current StringWriter so far.
virtual byte [] ToArray()
Writes the stream contents to a byte array, regardless of the P:System.IO.MemoryStream....
A cast or conversion operation, such as (SampleType)obj in C::or CType(obj, SampleType) in Visual Bas...
Serializes and deserializes objects into and from XML documents. The T:System.Xml....
Provides information about the characteristics for a component, such as its attributes,...
bool Deserialized
Gets or sets whether the value of a T:System.Configuration.SettingsProperty object has been deseriali...
Contains the value of a settings property that can be loaded and stored by an instance of T:System....
bool IsValueType
Gets a value indicating whether the T:System.Type is a value type.
object SerializedValue
Gets or sets the serialized value of the T:System.Configuration.SettingsProperty object.
virtual Type PropertyType
Gets or sets the type for the T:System.Configuration.SettingsProperty.
bool IsDirty
Gets or sets whether the value of a T:System.Configuration.SettingsProperty object has changed.
object Deserialize(Stream stream)
Deserializes the XML document contained by the specified T:System.IO.Stream.
virtual SettingsSerializeAs SerializeAs
Gets or sets a T:System.Configuration.SettingsSerializeAs object for the T:System....
string Name
Gets the name of the property from the associated T:System.Configuration.SettingsProperty object.
object GetData(string name)
Gets the value stored in the current application domain for the specified name.
void Serialize(TextWriter textWriter, object o)
Serializes the specified T:System.Object and writes the XML document to a file using the specified T:...
Provides information about a specific culture (called a locale for unmanaged code development)....
SecurityPermissionFlag
Specifies access flags for the security permission object.
object PropertyValue
Gets or sets the value of the T:System.Configuration.SettingsProperty object.
SettingsSerializeAs
Determines the serialization scheme used to store application settings.
Implements a T:System.IO.TextReader that reads from a string.
Provides a unified way of converting types of values to other types, as well as for accessing standar...
virtual bool IsAssignableFrom(Type c)
Determines whether an instance of a specified type can be assigned to an instance of the current type...
virtual string Name
Gets or sets the name of the T:System.Configuration.SettingsProperty.