本文整理汇总了C#中NSMutableDictionary类的典型用法代码示例。如果您正苦于以下问题:C# NSMutableDictionary类的具体用法?C# NSMutableDictionary怎么用?C# NSMutableDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSMutableDictionary类属于命名空间,在下文中一共展示了NSMutableDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CMMemoryPool
public CMMemoryPool (TimeSpan ageOutPeriod)
{
using (var dict = new NSMutableDictionary ()) {
dict.LowlevelSetObject (AgeOutPeriodSelector, new NSNumber (ageOutPeriod.TotalSeconds).Handle);
handle = CMMemoryPoolCreate (dict.Handle);
}
}
示例2: CreateKeyPair
/// <inheritdoc/>
public ICryptographicKey CreateKeyPair(int keySize)
{
Requires.Range(keySize > 0, "keySize");
string keyIdentifier = Guid.NewGuid().ToString();
string publicKeyIdentifier = RsaCryptographicKey.GetPublicKeyIdentifierWithTag(keyIdentifier);
string privateKeyIdentifier = RsaCryptographicKey.GetPrivateKeyIdentifierWithTag(keyIdentifier);
// Configure parameters for the joint keypair.
var keyPairAttr = new NSMutableDictionary();
keyPairAttr[KSec.AttrKeyType] = KSec.AttrKeyTypeRSA;
keyPairAttr[KSec.AttrKeySizeInBits] = NSNumber.FromInt32(keySize);
// Configure parameters for the private key
var privateKeyAttr = new NSMutableDictionary();
privateKeyAttr[KSec.AttrIsPermanent] = NSNumber.FromBoolean(true);
privateKeyAttr[KSec.AttrApplicationTag] = NSData.FromString(privateKeyIdentifier, NSStringEncoding.UTF8);
// Configure parameters for the public key
var publicKeyAttr = new NSMutableDictionary();
publicKeyAttr[KSec.AttrIsPermanent] = NSNumber.FromBoolean(true);
publicKeyAttr[KSec.AttrApplicationTag] = NSData.FromString(publicKeyIdentifier, NSStringEncoding.UTF8);
// Parent the individual key parameters to the keypair one.
keyPairAttr[KSec.PublicKeyAttrs] = publicKeyAttr;
keyPairAttr[KSec.PrivateKeyAttrs] = privateKeyAttr;
// Generate the RSA key.
SecKey publicKey, privateKey;
SecStatusCode code = SecKey.GenerateKeyPair(keyPairAttr, out publicKey, out privateKey);
Verify.Operation(code == SecStatusCode.Success, "status was " + code);
return new RsaCryptographicKey(publicKey, privateKey, keyIdentifier, this.algorithm);
}
示例3: AddBeerToIndex
public void AddBeerToIndex(Beer beer)
{
var activity = new NSUserActivity("com.micjames.beerdrinkin.beerdetails");
if (!string.IsNullOrEmpty(beer.Description))
{
var info = new NSMutableDictionary();
info.Add(new NSString("name"), new NSString(beer.Name));
info.Add(new NSString("description"), new NSString(beer.Description));
if (beer?.Image?.MediumUrl != null)
{
info.Add(new NSString("imageUrl"), new NSString(beer.Image.LargeUrl));
}
var attributes = new CSSearchableItemAttributeSet();
attributes.DisplayName = beer.Name;
attributes.ContentDescription = beer.Description;
var keywords = new NSString[] { new NSString(beer.Name), new NSString("beerName") };
activity.Keywords = new NSSet<NSString>(keywords);
activity.ContentAttributeSet = attributes;
activity.Title = beer.Name;
activity.UserInfo = info;
activity.EligibleForSearch = true;
activity.EligibleForPublicIndexing = true;
activity.BecomeCurrent();
}
}
示例4: logEvent
public void logEvent (string eventName, object[] args) {
if (args.Length == 0) {
try {
FA.Flurry.LogEvent(eventName);
} catch (Exception e) {
PlayN.log().warn("Failed to log event to Flurry [event=" + eventName + "]", e);
}
} else {
var dict = new NSMutableDictionary();
for (int ii = 0; ii < args.Length; ii += 2) {
var key = (string)args[ii];
var value = args[ii+1];
if (value is string) {
dict.Add(new NSString(key), new NSString((string)value));
} else if (value is java.lang.Boolean) {
dict.Add(new NSString(key), new NSNumber(((java.lang.Boolean)value).booleanValue()));
} else if (value is java.lang.Integer) {
dict.Add(new NSString(key), new NSNumber(((java.lang.Integer)value).intValue()));
} else {
var vclass = (value == null) ? "null" : value.GetType().ToString();
PlayN.log().warn("Got unknown Flurry event parameter type [key=" + key +
", value=" + value + ", vclass=" + vclass + "]");
}
}
try {
FA.Flurry.LogEvent(eventName, dict);
} catch (Exception e) {
PlayN.log().warn("Failed to log event to Flurry [event=" + eventName +
", argCount=" + args.Length + "]", e);
}
}
}
示例5: NavigateToURL
/// <summary>
/// Navigates the Webview to the given URL string.
/// </summary>
/// <param name="url">URL.</param>
private void NavigateToURL(string url) {
// Properly formatted?
if (!url.StartsWith ("http://")) {
// Add web
url = "http://" + url;
}
// Display the give webpage
WebView.LoadRequest(new NSUrlRequest(NSUrl.FromString(url)));
// Invalidate existing Activity
if (UserActivity != null) {
UserActivity.Invalidate();
UserActivity = null;
}
// Create a new user Activity to support this tab
UserActivity = new NSUserActivity (ThisApp.UserActivityTab4);
UserActivity.Title = "Coffee Break Tab";
// Update the activity when the tab's URL changes
var userInfo = new NSMutableDictionary ();
userInfo.Add (new NSString ("Url"), new NSString (url));
UserActivity.AddUserInfoEntries (userInfo);
// Inform Activity that it has been updated
UserActivity.BecomeCurrent ();
// Log User Activity
Console.WriteLine ("Creating User Activity: {0} - {1}", UserActivity.Title, url);
}
示例6: SetupLiveCameraStream
public void SetupLiveCameraStream()
{
captureSession = new AVCaptureSession();
var viewLayer = liveCameraStream.Layer;
Console.WriteLine(viewLayer.Frame.Width);
var videoPreviewLayer = new AVCaptureVideoPreviewLayer(captureSession)
{
Frame = liveCameraStream.Bounds
};
liveCameraStream.Layer.AddSublayer(videoPreviewLayer);
Console.WriteLine(liveCameraStream.Layer.Frame.Width);
var captureDevice = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video);
ConfigureCameraForDevice(captureDevice);
captureDeviceInput = AVCaptureDeviceInput.FromDevice(captureDevice);
var dictionary = new NSMutableDictionary();
dictionary[AVVideo.CodecKey] = new NSNumber((int)AVVideoCodec.JPEG);
stillImageOutput = new AVCaptureStillImageOutput()
{
OutputSettings = new NSDictionary()
};
captureSession.AddOutput(stillImageOutput);
captureSession.AddInput(captureDeviceInput);
captureSession.StartRunning();
ViewWillLayoutSubviews();
}
示例7: TwitterRequest
public TwitterRequest (string method, Uri url, IDictionary<string, string> paramters, Account account)
: base (method, url, paramters, account)
{
var ps = new NSMutableDictionary ();
if (paramters != null) {
foreach (var p in paramters) {
ps.SetValueForKey (new NSString (p.Value), new NSString (p.Key));
}
}
var m = TWRequestMethod.Get;
switch (method.ToLowerInvariant()) {
case "get":
m = TWRequestMethod.Get;
break;
case "post":
m = TWRequestMethod.Post;
break;
case "delete":
m = TWRequestMethod.Delete;
break;
default:
throw new NotSupportedException ("Twitter does not support the HTTP method '" + method + "'");
}
request = new TWRequest (new NSUrl (url.AbsoluteUri), ps, m);
Account = account;
}
示例8: ConvertToDictionary
public static Dictionary<String, Object> ConvertToDictionary(NSMutableDictionary dictionary)
{
Dictionary<String,Object> prunedDictionary = new Dictionary<String,Object>();
foreach (NSString key in dictionary.Keys) {
NSObject dicValue = dictionary.ObjectForKey(key);
if (dicValue is NSDictionary) {
prunedDictionary.Add (key.ToString(), ConvertToDictionary(new NSMutableDictionary(dicValue as NSDictionary)));
} else {
//SystemLogger.Log(SystemLogger.Module.PLATFORM, "***** key["+key.ToString ()+"] is instance of: " + dicValue.GetType().FullName);
if ( ! (dicValue is NSNull)) {
if(dicValue is NSString) {
prunedDictionary.Add (key.ToString(), ((NSString)dicValue).Description);
} else if(dicValue is NSNumber) {
prunedDictionary.Add (key.ToString(), ((NSNumber)dicValue).Int16Value);
} else if(dicValue is NSArray) {
prunedDictionary.Add (key.ToString(), ConvertToArray((NSArray)dicValue));
} else {
prunedDictionary.Add (key.ToString(), dicValue);
}
}
}
}
return prunedDictionary;
}
示例9: ToDictionary
internal NSDictionary ToDictionary()
{
int n = 0;
if (Enhance.HasValue && Enhance.Value == false)
n++;
if (RedEye.HasValue && RedEye.Value == false)
n++;
if (ImageOrientation.HasValue)
n++;
if (Features != null && Features.Length != 0)
n++;
if (n == 0)
return null;
NSMutableDictionary dict = new NSMutableDictionary ();
if (Enhance.HasValue && Enhance.Value == false){
dict.LowlevelSetObject (CFBoolean.False.Handle, CIImage.AutoAdjustEnhanceKey.Handle);
}
if (RedEye.HasValue && RedEye.Value == false){
dict.LowlevelSetObject (CFBoolean.False.Handle, CIImage.AutoAdjustRedEyeKey.Handle);
}
if (Features != null && Features.Length != 0){
dict.LowlevelSetObject (NSArray.FromObjects (Features), CIImage.AutoAdjustFeaturesKey.Handle);
}
if (ImageOrientation.HasValue){
dict.LowlevelSetObject (new NSNumber ((int)ImageOrientation.Value), CIImage.ImagePropertyOrientation.Handle);
}
#if false
for (i = 0; i < n; i++){
Console.WriteLine ("{0} {1}-{2}", i, keys [i], values [i]);
}
#endif
return dict;
}
示例10: SetOptions
/// <summary>Sets custom options</summary>
/// <param name="options">Option mask containing the options you want to set. Available
/// options are described
/// below at Options enum</param>
public static void SetOptions(Options options, bool bValue = true)
{
var optionsDict = new NSMutableDictionary();
var strValue = bValue ? new NSString("YES") : new NSString("NO");
if ((options & Options.DisableAutoDeviceIdentifying) == 0 && isFirstTime) {
TestFlight.SetDeviceIdentifier(UIDevice.CurrentDevice.UniqueIdentifier);
isFirstTime = false;
}
if ((options & Options.AttachBacktraceToFeedback) != 0) {
optionsDict.Add (strValue, OptionKeys.AttachBacktraceToFeedback);
}
if ((options & Options.DisableInAppUpdates) != 0) {
optionsDict.Add (strValue, OptionKeys.DisableInAppUpdates);
}
if ((options & Options.LogToConsole) != 0) {
optionsDict.Add (strValue, OptionKeys.LogToSTDERR);
}
if ((options & Options.LogToSTDERR) != 0) {
optionsDict.Add (strValue, OptionKeys.ReinstallCrashHandlers);
}
if ((options & Options.SendLogOnlyOnCrash) != 0) {
optionsDict.Add (strValue, OptionKeys.SendLogOnlyOnCrash);
}
TestFlight.SetOptionsRaw(optionsDict);
}
示例11: SaveToDictionary
public static void SaveToDictionary(this IStateBundle state, NSMutableDictionary bundle)
{
var formatter = new BinaryFormatter();
foreach (var kv in state.Data.Where(x => x.Value != null))
{
var value = kv.Value;
if (value.GetType().IsSerializable)
{
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, value);
stream.Position = 0;
var bytes = stream.ToArray();
var array = new NSMutableArray();
foreach (var b in bytes)
{
array.Add(NSNumber.FromByte(b));
}
bundle.Add(new NSString(kv.Key), array);
}
}
}
}
示例12: GetCrmTasks
public override async void HandleWatchKitExtensionRequest
(UIApplication application, NSDictionary userInfo, Action<NSDictionary> reply)
{
if (userInfo.Values[0].ToString() == "gettasks")
{
string userId = NSUserDefaults.StandardUserDefaults.StringForKey("UserId");
List<CrmTask> tasks = await GetCrmTasks(userId);
var nativeDict = new NSMutableDictionary();
foreach (CrmTask task in tasks)
{
nativeDict.Add((NSString)task.TaskId, (NSString)task.Subject);
}
reply(new NSDictionary(
"count", NSNumber.FromInt32(tasks.Count),
"tasks", nativeDict
));
}
else if (userInfo.Values[0].ToString() == "closetask")
{
string taskId = userInfo.Values[1].ToString();
CloseTask(taskId);
reply(new NSDictionary(
"count", 0,
"something", 0
));
}
}
示例13: RegisterDefaultSettings
public static void RegisterDefaultSettings ()
{
var path = Path.Combine(NSBundle.MainBundle.PathForResource("Settings", "bundle"), "Root.plist");
using (NSString keyString = new NSString ("Key"), defaultString = new NSString ("DefaultValue"), preferenceSpecifiers = new NSString ("PreferenceSpecifiers"))
using (var settings = NSDictionary.FromFile(path))
using (var preferences = (NSArray)settings.ValueForKey(preferenceSpecifiers))
using (var registrationDictionary = new NSMutableDictionary ()) {
for (nuint i = 0; i < preferences.Count; i++)
using (var prefSpecification = preferences.GetItem<NSDictionary>(i))
using (var key = (NSString)prefSpecification.ValueForKey(keyString))
if (key != null)
using (var def = prefSpecification.ValueForKey(defaultString))
if (def != null)
registrationDictionary.SetValueForKey(def, key);
NSUserDefaults.StandardUserDefaults.RegisterDefaults(registrationDictionary);
#if DEBUG
SetSetting(SettingsKeys.UserReferenceKey, debugReferenceKey);
#else
SetSetting(SettingsKeys.UserReferenceKey, UIDevice.CurrentDevice.IdentifierForVendor.AsString());
#endif
Synchronize();
}
}
示例14: ToDictionary
internal NSDictionary ToDictionary ()
{
var ret = new NSMutableDictionary ();
if (AffineMatrix.HasValue){
var a = AffineMatrix.Value;
var affine = new NSNumber [6];
affine [0] = NSNumber.FromFloat (a.xx);
affine [1] = NSNumber.FromFloat (a.yx);
affine [2] = NSNumber.FromFloat (a.xy);
affine [3] = NSNumber.FromFloat (a.yy);
affine [4] = NSNumber.FromFloat (a.x0);
affine [5] = NSNumber.FromFloat (a.y0);
ret.SetObject (NSArray.FromNSObjects (affine), CISampler.AffineMatrix);
}
if (WrapMode.HasValue){
var k = WrapMode.Value == CIWrapMode.Black ? CISampler.WrapBlack : CISampler.FilterNearest;
ret.SetObject (k, CISampler.WrapMode);
}
if (FilterMode.HasValue){
var k = FilterMode.Value == CIFilterMode.Nearest ? CISampler.FilterNearest : CISampler.FilterLinear;
ret.SetObject (k, CISampler.FilterMode);
}
return ret;
}
示例15: WarningWindow
public WarningWindow()
{
// Interface Builder won't allow us to create a window with no title bar
// so we have to create it manually. But we could use IB if we display
// the window with a sheet...
NSRect rect = new NSRect(0, 0, 460, 105);
m_window = NSWindow.Alloc().initWithContentRect_styleMask_backing_defer(rect, 0, Enums.NSBackingStoreBuffered, false);
m_window.setHasShadow(false);
// Initialize the text attributes.
var dict = NSMutableDictionary.Create();
NSFont font = NSFont.fontWithName_size(NSString.Create("Georgia"), 64.0f);
dict.setObject_forKey(font, Externs.NSFontAttributeName);
NSMutableParagraphStyle style = NSMutableParagraphStyle.Create();
style.setAlignment(Enums.NSCenterTextAlignment);
dict.setObject_forKey(style, Externs.NSParagraphStyleAttributeName);
m_attrs = dict.Retain();
// Initialize the background bezier.
m_background = NSBezierPath.Create().Retain();
m_background.appendBezierPathWithRoundedRect_xRadius_yRadius(m_window.contentView().bounds(), 20.0f, 20.0f);
m_color = NSColor.colorWithDeviceRed_green_blue_alpha(250/255.0f, 128/255.0f, 114/255.0f, 1.0f).Retain();
ActiveObjects.Add(this);
}