Class PropertyDictionary
public class PropertyDictionary : DynamicObject
- Inheritance
-
objectDynamicObjectPropertyDictionary
Properties
Count
Gets the number of elements contained in the System.Collections.Generic.ICollection<T>.
public int Count { get; }
Property Value
- int
The number of elements contained in the System.Collections.Generic.ICollection<T>.
IsReadOnly
Gets a value indicating whether the System.Collections.Generic.ICollection<T> is read-only.
public bool IsReadOnly { get; }
Property Value
this[string]
Gets or sets the element with the specified key.
public object this[string key] { get; set; }
Parameters
key
stringThe key of the element to get or set.
Property Value
- object
The element with the specified key.
Exceptions
- ArgumentNullException
key
is null.- KeyNotFoundException
The property is retrieved and
key
is not found.- NotSupportedException
The property is set and the System.Collections.Generic.IDictionary<TKey, TValue> is read-only.
Keys
Gets an System.Collections.Generic.ICollection<T> containing the keys of the System.Collections.Generic.IDictionary<TKey, TValue>.
public ICollection<string> Keys { get; }
Property Value
- ICollection<string>
An System.Collections.Generic.ICollection<T> containing the keys of the object that implements System.Collections.Generic.IDictionary<TKey, TValue>.
Values
Gets an System.Collections.Generic.ICollection<T> containing the values in the System.Collections.Generic.IDictionary<TKey, TValue>.
public ICollection<object> Values { get; }
Property Value
- ICollection<object>
An System.Collections.Generic.ICollection<T> containing the values in the object that implements System.Collections.Generic.IDictionary<TKey, TValue>.
Methods
Add(KeyValuePair<string, object>)
Adds an item to the System.Collections.Generic.ICollection<T>.
public void Add(KeyValuePair<string, object> item)
Parameters
item
KeyValuePair<string, object>The object to add to the System.Collections.Generic.ICollection<T>.
Exceptions
- NotSupportedException
The System.Collections.Generic.ICollection<T> is read-only.
Add(string, object)
Adds an element with the provided key and value to the System.Collections.Generic.IDictionary<TKey, TValue>.
public void Add(string key, object value)
Parameters
key
stringThe object to use as the key of the element to add.
value
objectThe object to use as the value of the element to add.
Exceptions
- ArgumentNullException
key
is null.- ArgumentException
An element with the same key already exists in the System.Collections.Generic.IDictionary<TKey, TValue>.
- NotSupportedException
The System.Collections.Generic.IDictionary<TKey, TValue> is read-only.
Clear()
Removes all items from the System.Collections.Generic.ICollection<T>.
public void Clear()
Exceptions
- NotSupportedException
The System.Collections.Generic.ICollection<T> is read-only.
Contains(KeyValuePair<string, object>)
Determines whether the System.Collections.Generic.ICollection<T> contains a specific value.
public bool Contains(KeyValuePair<string, object> item)
Parameters
item
KeyValuePair<string, object>The object to locate in the System.Collections.Generic.ICollection<T>.
Returns
ContainsKey(string)
Determines whether the System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the specified key.
public bool ContainsKey(string key)
Parameters
key
stringThe key to locate in the System.Collections.Generic.IDictionary<TKey, TValue>.
Returns
- bool
true if the System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the key; otherwise, false.
Exceptions
- ArgumentNullException
key
is null.
CopyTo(KeyValuePair<string, object>[], int)
Copies the elements of the System.Collections.Generic.ICollection<T> to an System.Array, starting at a particular System.Array index.
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
Parameters
array
KeyValuePair<string, object>[]The one-dimensional System.Array that is the destination of the elements copied from System.Collections.Generic.ICollection<T>. The System.Array must have zero-based indexing.
arrayIndex
intThe zero-based index in
array
at which copying begins.
Exceptions
- ArgumentNullException
array
is null.- ArgumentOutOfRangeException
arrayIndex
is less than 0.- ArgumentException
The number of elements in the source System.Collections.Generic.ICollection<T> is greater than the available space from
arrayIndex
to the end of the destinationarray
.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<string, object>>
An enumerator that can be used to iterate through the collection.
OnPropertyChanged(string)
protected virtual void OnPropertyChanged(string propertyName = null)
Parameters
propertyName
string
Remove(KeyValuePair<string, object>)
Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>.
public bool Remove(KeyValuePair<string, object> item)
Parameters
item
KeyValuePair<string, object>The object to remove from the System.Collections.Generic.ICollection<T>.
Returns
- bool
true if
item
was successfully removed from the System.Collections.Generic.ICollection<T>; otherwise, false. This method also returns false ifitem
is not found in the original System.Collections.Generic.ICollection<T>.
Exceptions
- NotSupportedException
The System.Collections.Generic.ICollection<T> is read-only.
Remove(string)
Removes the element with the specified key from the System.Collections.Generic.IDictionary<TKey, TValue>.
public bool Remove(string key)
Parameters
key
stringThe key of the element to remove.
Returns
- bool
true if the element is successfully removed; otherwise, false. This method also returns false if
key
was not found in the original System.Collections.Generic.IDictionary<TKey, TValue>.
Exceptions
- ArgumentNullException
key
is null.- NotSupportedException
The System.Collections.Generic.IDictionary<TKey, TValue> is read-only.
TryGetMember(GetMemberBinder, out object)
Provides the implementation for operations that get member values. Classes derived from the System.Dynamic.DynamicObject class can override this method to specify dynamic behavior for operations such as getting a value for a property.
public override bool TryGetMember(GetMemberBinder binder, out object result)
Parameters
binder
GetMemberBinderProvides information about the object that called the dynamic operation. The
binder.Name
property provides the name of the member on which the dynamic operation is performed. For example, for theConsole.WriteLine(sampleObject.SampleProperty)
statement, wheresampleObject
is an instance of the class derived from the System.Dynamic.DynamicObject class,binder.Name
returns "SampleProperty". Thebinder.IgnoreCase
property specifies whether the member name is case-sensitive.result
objectThe result of the get operation. For example, if the method is called for a property, you can assign the property value to
result
.
Returns
- bool
true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)
TryGetValue(string, out object)
Gets the value associated with the specified key.
public bool TryGetValue(string key, out object value)
Parameters
key
stringThe key whose value to get.
value
objectWhen this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the
value
parameter. This parameter is passed uninitialized.
Returns
- bool
true if the object that implements System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the specified key; otherwise, false.
Exceptions
- ArgumentNullException
key
is null.
TrySetMember(SetMemberBinder, object)
Provides the implementation for operations that set member values. Classes derived from the System.Dynamic.DynamicObject class can override this method to specify dynamic behavior for operations such as setting a value for a property.
public override bool TrySetMember(SetMemberBinder binder, object value)
Parameters
binder
SetMemberBinderProvides information about the object that called the dynamic operation. The
binder.Name
property provides the name of the member to which the value is being assigned. For example, for the statementsampleObject.SampleProperty = "Test"
, wheresampleObject
is an instance of the class derived from the System.Dynamic.DynamicObject class,binder.Name
returns "SampleProperty". Thebinder.IgnoreCase
property specifies whether the member name is case-sensitive.value
objectThe value to set to the member. For example, for
sampleObject.SampleProperty = "Test"
, wheresampleObject
is an instance of the class derived from the System.Dynamic.DynamicObject class, thevalue
is "Test".
Returns
- bool
true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
Events
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler PropertyChanged
Event Type
- PropertyChangedEventHandler