Editar

Compartir a través de


DictionaryContainer Class

Definition

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

public abstract class DictionaryContainer
type DictionaryContainer = class
Inheritance
DictionaryContainer
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()

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

DictionaryContainer(NSDictionary)

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

Properties

Dictionary

Gets the wrapped NSDictionary.

Methods

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

Retrieves the array of type T associated with key.

GetBoolValue(NSString)

Returns the nullable Boolean associated with key.

GetCGPointValue(NSString)

Returns the nullable CGPoint associated with key.

GetCGRectValue(NSString)

Returns the nullable NSString associated with key.

GetCGSizeValue(NSString)

Returns the nullable CGSize associated with key.

GetCMTimeValue(NSString)

Returns the nullable CMTime associated with key.

GetDoubleValue(NSString)

Returns the nullable double associated with key.

GetFloatValue(NSString)

Returns the nullable float associated with key.

GetInt32Value(NSString)

Returns the nullable int associated with key.

GetLongValue(NSString)

Returns the nullable long associated with key.

GetNativeValue<T>(NSString)

Returns the native object associated with key.

GetNIntValue(NSString)

Returns the nullable native integer associated with key.

GetNSDictionary(NSString)

Returns the NSDictionary associated with key.

GetNSDictionary<TKey,TValue>(NSString)

Returns the NSDictionary associated with key.

GetNSStringValue(NSString)

Returns the NSString associated with key.

GetNUIntValue(NSString)

Returns the nullable native unsigned int associated with key.

GetStringValue(NSString)

Returns the string associated with key.

GetStringValue(String)

Returns the string associated with key.

GetStrongDictionary<T>(NSString)

Returns the DictionaryContainer associated with key.

GetUInt32Value(NSString)

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

GetUIntValue(NSString)

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

RemoveValue(NSString)

Removes from the dictionary the value associated with key.

SetArrayValue(NSString, INativeObject[])

Associates the INativeObject array values with key.

SetArrayValue(NSString, NSNumber[])

Associates the NSNumber array values with key.

SetArrayValue(NSString, String[])

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

SetArrayValue<T>(NSString, T[])

Associates the array values of type T with key.

SetBooleanValue(NSString, Nullable<Boolean>)

Stores the Boolean value and associates it with the key.

SetCGPointValue(NSString, Nullable<CGPoint>)

Stores the CGPointvalue and associates it with the key.

SetCGRectValue(NSString, Nullable<CGRect>)

Stores the CGRectvalue and associates it with the key.

SetCGSizeValue(NSString, Nullable<CGSize>)

Stores the CGSizevalue and associates it with the key.

SetCMTimeValue(NSString, Nullable<CMTime>)

Stores the CMTimevalue and associates it with the key.

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

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

SetNumberValue(NSString, Nullable<Int32>)

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

SetNumberValue(NSString, Nullable<Int64>)

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

SetNumberValue(NSString, Nullable<nint>)

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

SetNumberValue(NSString, Nullable<nuint>)

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

SetNumberValue(NSString, Nullable<Single>)

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

SetNumberValue(NSString, Nullable<UInt32>)

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

SetStringValue(NSString, NSString)

Stores the string value and associates it with the key.

SetStringValue(NSString, String)

Stores the string value and associates it with the key.

Applies to