当前位置: 首页>>代码示例>>C#>>正文


C# NSMutableDictionary.Add方法代码示例

本文整理汇总了C#中NSMutableDictionary.Add方法的典型用法代码示例。如果您正苦于以下问题:C# NSMutableDictionary.Add方法的具体用法?C# NSMutableDictionary.Add怎么用?C# NSMutableDictionary.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NSMutableDictionary的用法示例。


在下文中一共展示了NSMutableDictionary.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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();
            }

        }
开发者ID:MikeCodesDotNet,项目名称:Beer-Drinkin,代码行数:32,代码来源:SpotlightService.cs

示例2: 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);
        }
开发者ID:stelapps,项目名称:monotouch-bindings,代码行数:32,代码来源:extras.cs

示例3: 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);
     }
   }
 }
开发者ID:livingblast,项目名称:playn-samples,代码行数:32,代码来源:Main.cs

示例4: Initialize

        // Shared initialization code
        void Initialize()
        {
            this.Window.AlphaValue = 0;
            this.Window.MakeKeyAndOrderFront(this);

            // Fade in splash screen
            NSMutableDictionary dict = new NSMutableDictionary();
            dict.Add(NSViewAnimation.TargetKey, Window);
            dict.Add(NSViewAnimation.EffectKey, NSViewAnimation.FadeInEffect);
            NSViewAnimation anim = new NSViewAnimation(new List<NSMutableDictionary>(){ dict }.ToArray());
            anim.Duration = 0.4f;
            anim.StartAnimation();
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:14,代码来源:SplashWindowController.cs

示例5: MainWindowController

		public MainWindowController(Action<IBaseView> onViewReady) : base ("MainWindow", onViewReady)
        {
            this.Window.AlphaValue = 0;
            ShowWindowCentered();

            // Fade in main window
            NSMutableDictionary dict = new NSMutableDictionary();
            dict.Add(NSViewAnimation.TargetKey, Window);
            dict.Add(NSViewAnimation.EffectKey, NSViewAnimation.FadeInEffect);
            NSViewAnimation anim = new NSViewAnimation(new List<NSMutableDictionary>(){ dict }.ToArray());
            anim.Duration = 0.25f;
            anim.StartAnimation();
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:13,代码来源:MainWindowController.cs

示例6: 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
					));
			}
		}
开发者ID:jlattimer,项目名称:CrmWatchKit,代码行数:31,代码来源:AppDelegate.cs

示例7: 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);
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:36,代码来源:FourthViewController.cs

示例8: 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);
                    }
                }
            }
        }
开发者ID:sgmunn,项目名称:Mobile.Utils,代码行数:26,代码来源:StateBundleExtensions.cs

示例9: TouchesMoved

        public override void TouchesMoved(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);

            // Loop all touch positions
            foreach(var touch in touches)
            {
                // Get the current and last points
                var points = new NSMutableDictionary();

                points.Add(new NSString("currentPoint"), NSValue.FromCGPoint(((UITouch)touch).LocationInView(this)));
                points.Add(new NSString("lastPoint"), NSValue.FromCGPoint(((UITouch)touch).PreviousLocationInView(this)));

                // Draw
                PerformSelector(new Selector("DrawLine:"), points, 0.0f);
            }
        }
开发者ID:Manne990,项目名称:XamarinFormsPaintView,代码行数:17,代码来源:PaintViewRenderer.cs

示例10: submitAchievement

		public void submitAchievement(string identifier, double percentComplete, string achievementName)
		{
			if(earnedAchievementCache == null)
			{
				GKAchievement.LoadAchievements (new GKCompletionHandler (delegate(GKAchievement[] achievements, NSError error) {
					NSMutableDictionary tempCache = new NSMutableDictionary();
					if(achievements !=null)
					{
						foreach(var achievement in achievements)
						{
							tempCache.Add(new NSString(achievement.Identifier), achievement);
						}
					}
					earnedAchievementCache = tempCache;
					submitAchievement(identifier,percentComplete,achievementName);
				}));
			}
			else
			{
				GKAchievement achievement =(GKAchievement) earnedAchievementCache.ValueForKey (new NSString(identifier));
				if (achievement != null)
				{

					if (achievement.PercentComplete >= 100.0 || achievement.PercentComplete >= percentComplete) 
					{
						achievement = null;
					}
					else
						achievement.PercentComplete = percentComplete;
				}
				else
				{
					achievement = new GKAchievement(identifier);
					achievement.PercentComplete = percentComplete;
					earnedAchievementCache.Add(new NSString(achievement.Identifier),achievement);
				}
				if(achievement != null)
				{
					achievement.ReportAchievement (new GKNotificationHandler (delegate(NSError error) {
						if(error == null && achievement != null)
						{
							if(percentComplete == 100)
							{
								new UIAlertView ("Achievement Earned", "Great job!  You earned an achievement: " + achievementName, null, "OK", null).Show ();
							}
							else if(percentComplete >0)
							{
								new UIAlertView ("Achievement Progress", "Great job!  You're "+percentComplete+" % of the way to " + achievementName, null, "OK", null).Show ();
							}
						}
						else
						{
							new UIAlertView ("Achievement submittion failed", "Submittion failed because: " + error, null, "OK", null).Show ();
						}
					}));
				}
			}
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:58,代码来源:GameCenterManager.cs

示例11: SCC_HTTPGETParameters

        private static NSDictionary SCC_HTTPGETParameters (NSUrl url)
        {
            var parameters = new NSMutableDictionary();
            var components = NSUrlComponents.FromUrl(url, false);

            foreach(var queryItem in components.QueryItems)
            {
                if(queryItem.Value.Length > 0)
                {
                    parameters.Add(new NSString(queryItem.Name), new NSString(queryItem.Value));
                }
                else
                {
                    parameters.Add(new NSString(queryItem.Name), null);
                }
            }

            return parameters;
        }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:19,代码来源:Additions.cs

示例12: GetBoundingRect

		public static CGRect GetBoundingRect (this NSString This, CGSize size, NSStringDrawingOptions options, UIStringAttributes attributes, NSStringDrawingContext context)
		{
			// Define attributes
			var attr = new NSMutableDictionary ();
			attr.Add (NSFont.NameAttribute, attributes.Font.NSFont);

			var rect = This.BoundingRectWithSize (size, options, attr);

			// HACK: Cheating on the height
			return new CGRect(rect.Left, rect.Top , rect.Width, rect.Height * 1.5f);
		}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:11,代码来源:UIStringDrawing.cs

示例13: ReceivedResponse

		// received response to RequestProductData - with price,title,description info
		public override void ReceivedResponse (SKProductsRequest request, SKProductsResponse response)
		{
			SKProduct[] products = response.Products;

			NSMutableDictionary userInfo = new NSMutableDictionary ();
			for (int i = 0; i < products.Length; i++)
				userInfo.Add ((NSString)products [i].ProductIdentifier, products [i]);
			NSNotificationCenter.DefaultCenter.PostNotificationName (InAppPurchaseManagerProductsFetchedNotification, this, userInfo);

			foreach (string invalidProductId in response.InvalidProducts)
				Console.WriteLine ("Invalid product id: {0}", invalidProductId);
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:13,代码来源:PurchaseManager.cs

示例14: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            TKChart chart = new TKChart (this.ExampleBounds);
            chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.View.AddSubview (chart);

            string[] months = new string[]{ "Jan", "Feb", "Mar", "Apr", "May", "Jun" };
            int[] values = new int[]{ 95, 40, 55, 30, 76, 34 };
            List<TKChartDataPoint> list = new List<TKChartDataPoint> ();

            for (int i = 0; i < months.Length; i++) {
                list.Add (new TKChartDataPoint(new NSString(months[i]), new NSNumber(values[i])));
            }

            TKChartLineSeries series = new TKChartLineSeries (list.ToArray());
            series.Style.PointShape = new TKPredefinedShape (TKShapeType.Circle, new SizeF (10, 10));
            chart.AddSeries (series);

            NSMutableParagraphStyle paragraphStyle = (NSMutableParagraphStyle)new NSParagraphStyle ().MutableCopy();
            paragraphStyle.Alignment = UITextAlignment.Center;
            NSMutableDictionary attributes = new NSMutableDictionary ();
            attributes.Add (UIStringAttributeKey.ForegroundColor, UIColor.White);
            attributes.Add (UIStringAttributeKey.ParagraphStyle, paragraphStyle);
            NSMutableAttributedString attributedText = new NSMutableAttributedString ("Important milestone:\n $55000", attributes);

            attributedText.AddAttribute (UIStringAttributeKey.ForegroundColor, UIColor.Yellow, new NSRange (22, 6));

            TKChartBalloonAnnotation balloon = new TKChartBalloonAnnotation (new NSString("Mar"), new NSNumber(55), series);
            balloon.AttributedText = attributedText;
            balloon.Style.DistanceFromPoint = 20;
            balloon.Style.ArrowSize = new Size (10, 10);
            chart.AddAnnotation (balloon);

            balloon = new TKChartBalloonAnnotation ("The lowest value:\n $30000", new NSString("Apr"), new NSNumber(30), series);
            balloon.Style.VerticalAlign = TKChartBalloonVerticalAlignment.Bottom;
            chart.AddAnnotation (balloon);
        }
开发者ID:sudipnath,项目名称:ios-sdk,代码行数:39,代码来源:BalloonAnnotation.cs

示例15: ListViewVariableSizeCell

        public ListViewVariableSizeCell(IntPtr handle)
            : base(handle)
        {
            this.label = new UILabel (CGRect.Empty);
            this.label.TranslatesAutoresizingMaskIntoConstraints = false;
            this.label.Lines = 0;
            this.AddSubview (this.label);

            var views = new NSMutableDictionary ();
            views.Add (new NSString("v"), this.label);

            this.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|-10-[v]-10-|", 0, null, views));
            this.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|-10-[v]-10-|", 0, null, views));
        }
开发者ID:tremors,项目名称:ios-sdk,代码行数:14,代码来源:ListViewVariableSizeCell.cs


注:本文中的NSMutableDictionary.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。