In This Article

PropertyDictionary Class

Provides a thread-safe dictionary of properties.

public class PropertyDictionary
Inheritance:
System.Object Object

Constructors

PropertyDictionary()

public PropertyDictionary()

Properties

Item[Object]

Gets or sets the value of the property with the specified key.

[C#] In C#, this property is the indexer for the PropertyDictionary class.

public object this[object key] { get; set; }
Parameter Type Description
key System.Object

The property key for which to search.

Property Value

System.Object:

The value of the property with the specified key.

Keys

Gets the collection of property keys that have been registered in this dictionary.

public ReadOnlyCollection<object> Keys { get; }

Property Value

System.Collections.ObjectModel.ReadOnlyCollection<System.Object>:

The collection of property keys that have been registered in this dictionary.

Methods

Add(Object, Object)

Adds a property to the dictionary.

public void Add(object key, object value)
Parameter Type Description
key System.Object

A key that identifies the property.

value System.Object

The property value.

ContainsKey(Object)

Returns whether the dictionary contains a property with the specified key.

public bool ContainsKey(object key)
Parameter Type Description
key System.Object

The property key for which to search.

Returns

System.Boolean:

true if the dictionary contains a property with the specified key; otherwise, false.

GetOrCreateSingleton<TValue>(PropertyDictionary.Creator<TValue>)

Returns a property value if found; otherwise, uses a specified delegate to create a new instance.

public TValue GetOrCreateSingleton<TValue>(PropertyDictionary.Creator<TValue> creator)
Type Parameters:
TValue -

The type of property value.

Parameter Type Description
creator PropertyDictionary.Creator<TValue>

A delegate that is used to create a new value instance if the property is not yet found.

Returns

TValue:

The singleton property value.

Remarks

This overload uses the TValue Type as the property key for which to search.

GetOrCreateSingleton<TValue>(Object, PropertyDictionary.Creator<TValue>)

Returns a property value if found; otherwise, uses a specified delegate to create a new instance.

public TValue GetOrCreateSingleton<TValue>(object key, PropertyDictionary.Creator<TValue> creator)
Type Parameters:
TValue -

The type of property value.

Parameter Type Description
key System.Object

The property key for which to search.

creator PropertyDictionary.Creator<TValue>

A delegate that is used to create a new value instance if the property is not yet found.

Returns

TValue:

The singleton property value.

Remove(Object)

Removes the property with the specified key from the dictionary.

public bool Remove(object key)
Parameter Type Description
key System.Object

The key of the property to remove.

Returns

System.Boolean:

true if a property was removed; otherwise, false.

TryGetValue<TValue>(Object, out TValue)

Attempts to return the value of the property with the specified key.

public bool TryGetValue<TValue>(object key, out TValue value)
Type Parameters:
TValue -

The type of property value.

Parameter Type Description
key System.Object

The property key for which to search.

value TValue

Returns the property value.

Returns

System.Boolean:

true if a value was returned; otherwise, false.

Inherited Members

  • System.Object.ToString()
  • System.Object.Equals(System.Object)
  • System.Object.Equals(System.Object, System.Object)
  • System.Object.ReferenceEquals(System.Object, System.Object)
  • System.Object.GetHashCode()
  • System.Object.GetType()
  • System.Object.MemberwiseClone()