DictionaryContainer Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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 |
Properties
Dictionary |
Gets the wrapped NSDictionary. |
Methods
GetArray<T>(NSString, Func<IntPtr,T>) | |
GetArray<T>(NSString) |
Retrieves the array of type |
GetBoolValue(NSString) |
Returns the nullable Boolean associated with |
GetCGPointValue(NSString) |
Returns the nullable CGPoint associated with |
GetCGRectValue(NSString) |
Returns the nullable NSString associated with |
GetCGSizeValue(NSString) |
Returns the nullable CGSize associated with |
GetCMTimeValue(NSString) |
Returns the nullable CMTime associated with |
GetDoubleValue(NSString) |
Returns the nullable double associated with |
GetFloatValue(NSString) |
Returns the nullable float associated with |
GetInt32Value(NSString) |
Returns the nullable int associated with |
GetLongValue(NSString) |
Returns the nullable long associated with |
GetNativeValue<T>(NSString) |
Returns the native object associated with |
GetNIntValue(NSString) |
Returns the nullable native integer associated with |
GetNSDictionary(NSString) |
Returns the NSDictionary associated with |
GetNSDictionary<TKey,TValue>(NSString) |
Returns the NSDictionary associated with |
GetNSStringValue(NSString) |
Returns the NSString associated with |
GetNUIntValue(NSString) |
Returns the nullable native unsigned int associated with |
GetStringValue(NSString) |
Returns the string associated with |
GetStringValue(String) |
Returns the string associated with |
GetStrongDictionary<T>(NSString) |
Returns the DictionaryContainer associated with |
GetUInt32Value(NSString) |
Returns the nullable T:System.UInt32 associated with |
GetUIntValue(NSString) |
Returns the nullable T:System.UInt32 associated with |
RemoveValue(NSString) |
Removes from the dictionary the value associated with |
SetArrayValue(NSString, INativeObject[]) |
Associates the INativeObject array |
SetArrayValue(NSString, NSNumber[]) |
Associates the NSNumber array |
SetArrayValue(NSString, String[]) |
Associates the T:System.String array |
SetArrayValue<T>(NSString, T[]) |
Associates the array |
SetBooleanValue(NSString, Nullable<Boolean>) |
Stores the Boolean |
SetCGPointValue(NSString, Nullable<CGPoint>) |
Stores the CGPoint |
SetCGRectValue(NSString, Nullable<CGRect>) |
Stores the CGRect |
SetCGSizeValue(NSString, Nullable<CGSize>) |
Stores the CGSize |
SetCMTimeValue(NSString, Nullable<CMTime>) |
Stores the CMTime |
SetNativeValue(NSString, INativeObject, Boolean) | |
SetNumberValue(NSString, Nullable<Double>) |
Stores the double |
SetNumberValue(NSString, Nullable<Int32>) |
Stores the int |
SetNumberValue(NSString, Nullable<Int64>) |
Stores the long |
SetNumberValue(NSString, Nullable<nint>) |
Stores the native integer |
SetNumberValue(NSString, Nullable<nuint>) |
Stores the native unsigned int |
SetNumberValue(NSString, Nullable<Single>) |
Stores the float |
SetNumberValue(NSString, Nullable<UInt32>) |
Stores the unsigned int |
SetStringValue(NSString, NSString) |
Stores the string |
SetStringValue(NSString, String) |
Stores the string |