DictionaryContainer DictionaryContainer Class

Definition

Convenience base class used by strongly-typed classes that wrap NSDictionary-based settings.

public abstract class DictionaryContainer
type DictionaryContainer = class
Inheritance
DictionaryContainerDictionaryContainer
Derived

Remarks

Many iOS and OSX APIs accept configuration options as untyped NSDictionary values, or return untyped NSDictionary values. The C# 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 DicionaryContainer is an abstract base class that encapsulates the common code to wrap NSDictionaries like this.

When creating a strongly-typed wrapper for NSDictionary, subclass the DicionaryContainer and provide two constructors: one taking an NSDictionary (to create the wrapper) and one taking no arguments, which should call the base class with an NSMutableDictionary. 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 : DicionaryContainer {
    public MyProperties () : base (new NSMutableDictionary ())
    {
    }

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

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

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

Constructors

DictionaryContainer() DictionaryContainer()

When overridden, call the base-class constructor with a NSMutableDictionary.

DictionaryContainer(NSDictionary) DictionaryContainer(NSDictionary)

When overridden, call the base-class constructor, passing the dictionary.

Properties

Dictionary Dictionary

Gets the wrapped NSDictionary.

Methods

GetArray<T>(NSString) GetArray<T>(NSString)

Retrieves the array of type T associated with key.

GetArray<T>(NSString, Func<IntPtr,T>) GetArray<T>(NSString, Func<IntPtr,T>)
GetBoolValue(NSString) GetBoolValue(NSString)

Returns the nullable Boolean associated with key.

GetCGPointValue(NSString) GetCGPointValue(NSString)

Returns the nullable CGPoint associated with key.

GetCGRectValue(NSString) GetCGRectValue(NSString)

Returns the nullable NSString associated with key.

GetCGSizeValue(NSString) GetCGSizeValue(NSString)

Returns the nullable CGSize associated with key.

GetCMTimeValue(NSString) GetCMTimeValue(NSString)

Returns the nullable CMTime associated with key.

GetDoubleValue(NSString) GetDoubleValue(NSString)

Returns the nullable double associated with key.

GetFloatValue(NSString) GetFloatValue(NSString)

Returns the nullable float associated with key.

GetInt32Value(NSString) GetInt32Value(NSString)

Returns the nullable int associated with key.

GetLongValue(NSString) GetLongValue(NSString)

Returns the nullable long associated with key.

GetNativeValue<T>(NSString) GetNativeValue<T>(NSString)

Returns the native object associated with key.

GetNIntValue(NSString) GetNIntValue(NSString)

Returns the nullable native integer associated with key.

GetNSDictionary(NSString) GetNSDictionary(NSString)

Returns the NSDictionary associated with key.

GetNSDictionary<TKey,TValue>(NSString) GetNSDictionary<TKey,TValue>(NSString)

Returns the NSDictionary associated with key.

GetNSStringValue(NSString) GetNSStringValue(NSString)

Returns the NSString associated with key.

GetNUIntValue(NSString) GetNUIntValue(NSString)

Returns the nullable native unsigned int associated with key.

GetStringValue(NSString) GetStringValue(NSString)

Returns the string associated with key.

GetStringValue(String) GetStringValue(String)

Returns the string associated with key.

GetStrongDictionary<T>(NSString) GetStrongDictionary<T>(NSString)

Returns the DictionaryContainer associated with key.

GetUInt32Value(NSString) GetUInt32Value(NSString)

Returns the nullable T:System.UInt32 associated with key.

GetUIntValue(NSString) GetUIntValue(NSString)

Returns the nullable T:System.UInt32 associated with key.

RemoveValue(NSString) RemoveValue(NSString)

Removes from the dictionary the value associated with key.

SetArrayValue(NSString, NSNumber[]) SetArrayValue(NSString, NSNumber[])

Associates the NSNumber array values with key.

SetArrayValue(NSString, INativeObject[]) SetArrayValue(NSString, INativeObject[])

Associates the INativeObject array values with key.

SetArrayValue(NSString, String[]) SetArrayValue(NSString, String[])

Associates the T:System.String array values with key.

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

Associates the array values of type T with key.

SetBooleanValue(NSString, Nullable<Boolean>) SetBooleanValue(NSString, Nullable<Boolean>)

Stores the Boolean value and associates it with the key.

SetCGPointValue(NSString, Nullable<CGPoint>) SetCGPointValue(NSString, Nullable<CGPoint>)

Stores the CGPointvalue and associates it with the key.

SetCGRectValue(NSString, Nullable<CGRect>) SetCGRectValue(NSString, Nullable<CGRect>)

Stores the CGRectvalue and associates it with the key.

SetCGSizeValue(NSString, Nullable<CGSize>) SetCGSizeValue(NSString, Nullable<CGSize>)

Stores the CGSizevalue and associates it with the key.

SetCMTimeValue(NSString, Nullable<CMTime>) SetCMTimeValue(NSString, Nullable<CMTime>)

Stores the CMTimevalue and associates it with the key.

SetNativeValue(NSString, INativeObject, Boolean) SetNativeValue(NSString, INativeObject, Boolean)
SetNumberValue(NSString, Nullable<Double>) SetNumberValue(NSString, Nullable<Double>)

Stores the double value (or null) and associates it with the key.

SetNumberValue(NSString, Nullable<Int32>) SetNumberValue(NSString, Nullable<Int32>)

Stores the int value (or null) and associates it with the key.

SetNumberValue(NSString, Nullable<Int64>) SetNumberValue(NSString, Nullable<Int64>)

Stores the long value (or null) and associates it with the key.

SetNumberValue(NSString, Nullable<nint>) SetNumberValue(NSString, Nullable<nint>)

Stores the native integer value (or null) and associates it with the key.

SetNumberValue(NSString, Nullable<nuint>) SetNumberValue(NSString, Nullable<nuint>)

Stores the native unsigned int value (or null) and associates it with the key.

SetNumberValue(NSString, Nullable<Single>) SetNumberValue(NSString, Nullable<Single>)

Stores the float value (or null) and associates it with the key.

SetNumberValue(NSString, Nullable<UInt32>) SetNumberValue(NSString, Nullable<UInt32>)

Stores the unsigned int value (or null) and associates it with the key.

SetStringValue(NSString, NSString) SetStringValue(NSString, NSString)

Stores the string value and associates it with the key.

SetStringValue(NSString, String) SetStringValue(NSString, String)

Stores the string value and associates it with the key.

Applies to