Share via


DictionaryContainer Class

Definition

Convenience class to provide strongly-typed classes that wrap NSDictionary based settings.

public abstract class DictionaryContainer
type DictionaryContainer = class
Inheritance
DictionaryContainer
Derived

Remarks

Many APIs accept configuration options as untyped NSDictionary values, or return untyped NSDictionary values. The managed bindings offer strong-typed versions of those dictionaries, which allow developers to get code completion while passing parameters, and to extract data from return values. The DictionaryContainer class is an abstract base class that encapsulates the common code to wrap NSDictionary dictionaries like this.

When creating a strongly-typed wrapper for an NSDictionary, subclass the DictionaryContainer and provide two constructors: one taking an NSDictionary (to create the wrapper) and a default costructor. They should each call the corresponding base class (DictionaryContainer) constructor. Then use one of the various Get and Set methods exposed by this class to get and set values. This is how a sample class would work:

public class MyProperties : DictionaryContainer {
    public MyProperties () : base ()
    {
    }

    public MyProperties (NSDictionary dictionary) : base (dictionary)
    {
    }

    static NSString boolKey = new NSString ("SomeBoolKey");

    public bool MyBool {
        get => return GetInt32Value (boolKey);
        set => SetInt32Value (boolKey, value);
    }
}

Constructors

Name Description
DictionaryContainer()

Creates a new container for an empty NSDictionary.

DictionaryContainer(NSDictionary)

Creates a new container wrapping the specified NSDictionary.

Properties

Name Description
Dictionary

Gets the wrapped NSDictionary.

Methods

Name Description
GetArray<T>(NSString, Func<NativeHandle,T>)

Returns the nullable array of T associated with the specified key.

GetArray<T>(NSString)

Returns the nullable array of T associated with the specified key.

GetArrayOfDictionariesValue<T>(NSString)

Retrieves the DictionaryContainer array associeted with key.

GetBoolValue(NSString)

Returns the nullable Boolean associated with the specified key.

GetByteValue(NSString)

Returns the nullable Byte associated with the specified key.

GetCGPointValue(NSString)

Returns the nullable CGPoint associated with key.

GetCGRectValue(NSString)

Returns the nullable CGRect associated with key.

GetCGSizeValue(NSString)

Returns the nullable CGSize associated with key.

GetCMTimeValue(NSString)

Returns the nullable CMTime associated with key.

GetDateTimeValue(NSString)

Returns the nullable DateTime associated with key.

GetDoubleValue(NSString)

Returns the nullable Double associated with the specified key.

GetFloatValue(NSString)

Returns the nullable Single associated with the specified key.

GetInt16Value(NSString)

Returns the nullable Int16 associated with the specified key.

GetInt32Value(NSString)

Returns the nullable Int32 associated with the specified key.

GetLongValue(NSString)

Returns the nullable Int64 associated with the specified key.

GetNativeValue<T>(NSString)

Returns the nullable T associated with key.

GetNFloatValue(NSString)

Returns the nullable NFloat associated with the specified key.

GetNIntValue(NSString)

Returns the nullable IntPtr associated with the specified key.

GetNSDataAsValueType<T>(NSString)

Returns an NSData with the contents of a value type of type T associated with key.

GetNSDictionary(NSString)

Returns the nullable NSDictionary associated with key.

GetNSDictionary<TKey,TValue>(NSString)

Returns the nullable NSDictionary<TKey,TValue> associated with key.

GetNSStringValue(NSString)

Returns the nullable NSString associated with key.

GetNUIntValue(NSString)

Returns the nullable UIntPtr associated with the specified key.

GetSByteValue(NSString)

Returns the nullable SByte associated with the specified key.

GetStringArrayValue(NSString)

Returns the nullable string array associated with key.

GetStringValue(NSString)

Returns the nullable String associated with key.

GetStringValue(String)

Returns the nullable String associated with key.

GetStrongDictionary<T>(NSString, Func<NSDictionary,T>)

Returns the nullable T associated with key.

GetStrongDictionary<T>(NSString)

Returns the nullable T associated with key.

GetUIEdgeInsets(NSString)

Returns the nullable UIEdgeInsets associated with key.

GetUInt16Value(NSString)

Returns the nullable UInt16 associated with the specified key.

GetUInt32Value(NSString)

Returns the nullable UInt32 associated with the specified key.

GetUIntValue(NSString)

Returns the nullable UInt32 associated with the specified key.

GetULongValue(NSString)

Returns the nullable UInt64 associated with the specified key.

RemoveValue(NSString)

Removes from the dictionary the value associated with key.

SetArrayOfDictionariesValue(NSString, DictionaryContainer[])

Associates a DictionaryContainer array values with key.

SetArrayValue(NSString, INativeObject[])

Associates an array of INativeObject with key.

SetArrayValue(NSString, NSNumber[])

Associates the NSNumber array values with key.

SetArrayValue(NSString, String[])

Associates a string array with key.

SetArrayValue<T>(NSString, T[], Func<T,NativeHandle>)

Associates an array of T with key.

SetArrayValue<T>(NSString, T[])

Associates an array of T with key.

SetBooleanValue(NSString, Nullable<Boolean>)

Associates a nullable Boolean with key.

SetCGPointValue(NSString, Nullable<CGPoint>)

Associates a nullable CGPoint value with key.

SetCGRectValue(NSString, Nullable<CGRect>)

Associates a nullable CGRect value with key.

SetCGSizeValue(NSString, Nullable<CGSize>)

Associates a nullable CGSize value with key.

SetCMTimeValue(NSString, Nullable<CMTime>)

Associates a nullable CMTime value with key.

SetNativeValue(NSString, INativeObject, Boolean)

Associates a nullable INativeObject value with key.

SetNumberValue(NSString, Nullable<Byte>)

Associates a nullable Byte with key.

SetNumberValue(NSString, Nullable<Double>)

Associates a nullable Double with key.

SetNumberValue(NSString, Nullable<Int16>)

Associates a nullable Int16 with key.

SetNumberValue(NSString, Nullable<Int32>)

Associates a nullable Int32 with key.

SetNumberValue(NSString, Nullable<Int64>)

Associates a nullable Int64 with key.

SetNumberValue(NSString, Nullable<IntPtr>)

Associates a nullable IntPtr with key.

SetNumberValue(NSString, Nullable<NFloat>)

Associates a nullable NFloat with key.

SetNumberValue(NSString, Nullable<SByte>)

Associates a nullable SByte with key.

SetNumberValue(NSString, Nullable<Single>)

Associates a nullable Single with key.

SetNumberValue(NSString, Nullable<UInt16>)

Associates a nullable UInt16 with key.

SetNumberValue(NSString, Nullable<UInt32>)

Associates a nullable UInt32 with key.

SetNumberValue(NSString, Nullable<UInt64>)

Associates a nullable UInt64 with key.

SetNumberValue(NSString, Nullable<UIntPtr>)

Associates a nullable UIntPtr with key.

SetStringValue(NSString, NSString)

Associates a nullable NSString with key.

SetStringValue(NSString, String)

Associates a nullable String with key.

SetUIEdgeInsets(NSString, Nullable<UIEdgeInsets>)

Associates a nullable UIEdgeInsets value with key.

SetValueTypeAsNSData<T>(NSString, Nullable<T>)

Sets an NSData with the contents of a value type of type T associated with key.

TryGetNativeValue(NSString, NativeHandle)

Returns the handle associated with key.

TryGetNSObject<T>(NSString, T)

Returns the nullable T associated with key.

Applies to