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


C# NSDictionary.ValueForKey方法代码示例

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


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

示例1: OnMessageReceived

        public void OnMessageReceived(NSDictionary userInfo)
        {
            var parameters = new Dictionary<string, object>();

            foreach (NSString key in userInfo.Keys)
            {
                if(key == "aps")
                {
                    // flatten this dictionary for the handler
                    var apsDict = userInfo.ValueForKey(key) as NSDictionary;
                    if(apsDict != null)
                    {
                        foreach(var apsKey in apsDict)
                            parameters.Add(apsKey.Key.ToString(), apsKey.Value);
                    }
                }
                parameters.Add(key, userInfo.ValueForKey(key));

            }

            Debug.WriteLine("OnMessageReceived keys: ");
            foreach(var item in parameters)
                Debug.WriteLine("  {0} = {1}", item.Key, item.Value);

            if (CrossPushNotification.IsInitialized)
            {
                CrossPushNotification.PushNotificationListener.OnMessage(parameters, DeviceType.iOS);
            }else
            {
                throw NewPushNotificationNotInitializedException();
            }
        }
开发者ID:cleardemon,项目名称:xamarin-plugins,代码行数:32,代码来源:PushNotificationImplementation.cs

示例2: OnMessageReceived

        public void OnMessageReceived(NSDictionary userInfo)
        {
            var parameters = new Dictionary<string, object>();

            foreach (NSString key in userInfo.Keys)
            {
                if(key == "aps")
                {
                    NSDictionary aps = userInfo.ValueForKey(key) as NSDictionary;

                    if(aps != null)
                    {
                        foreach(var apsKey in aps)
                            parameters.Add(apsKey.Key.ToString(), apsKey.Value);
                    }
                }
                parameters.Add(key, userInfo.ValueForKey(key));
            }

            if (CrossPushNotification.IsInitialized)
            {
                CrossPushNotification.PushNotificationListener.OnMessage(parameters, DeviceType.iOS);
            }else
            {
                throw NewPushNotificationNotInitializedException();
            }
        }
开发者ID:kochizufan,项目名称:xamarin-plugins,代码行数:27,代码来源:PushNotificationImplementation.cs

示例3: OnMessageReceived

        public void OnMessageReceived(NSDictionary userInfo)
        {
            var parameters = new Dictionary<string, object>();
            var json = DictionaryToJson(userInfo);
            JObject values = JObject.Parse(json);

            var keyAps = new NSString("aps");

            if (userInfo.ContainsKey(keyAps))
            {
                NSDictionary aps = userInfo.ValueForKey(keyAps) as NSDictionary;

                if (aps != null)
                {
                    foreach (var apsKey in aps)
                    {
                        parameters.Add(apsKey.Key.ToString(), apsKey.Value);
                        JToken temp;
                        if (!values.TryGetValue(apsKey.Key.ToString(), out temp))
                            values.Add(apsKey.Key.ToString(), apsKey.Value.ToString());
                    }
                }
            }

            CrossPushNotification.PushNotificationListener.OnMessage(values, DeviceType.iOS);
        }
开发者ID:charri,项目名称:xamarin-plugins,代码行数:26,代码来源:PushNotificationImplementation.cs

示例4: FinishedLaunching

        public override bool FinishedLaunching( UIApplication application, NSDictionary launchOptions )
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method
            if ( launchOptions != null && launchOptions.ValueForKey( UIApplication.LaunchOptionsLocationKey ) != null )
            {
                Console.WriteLine( "JERED: Launched from region entered while terminated" );
            }
            else
            {
                Console.WriteLine( "JERED: *NOT* launched due to region monitoring." );
            }

            // ask to send notifications
            var settings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert
                | UIUserNotificationType.Badge
                | UIUserNotificationType.Sound,
                new NSSet());
            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

            // setup our window
            Window = new UIWindow( UIScreen.MainScreen.Bounds );

            MainController = new ViewController();
            MainController.View.Bounds = Window.Bounds;
            Window.RootViewController = MainController;

            Window.MakeKeyAndVisible( );

            SharedCode.LocationLayer.Create( null );

            return true;
        }
开发者ID:jhawkzz,项目名称:LocationRD,代码行数:34,代码来源:AppDelegate.cs

示例5: RegisterDefaultsFromSettingsBundle

 //UITabBarController TabController;
 //
 // This method is invoked when the application has loaded and is ready to run. In this
 // method you should instantiate the window, load the UI into it and then make the window
 // visible.
 // You have 17 seconds to return from this method, or iOS will terminate your application.
 //
 public static void RegisterDefaultsFromSettingsBundle()
 {
     string settingsBundle = NSBundle.MainBundle.PathForResource("Settings", @"bundle");
     if(settingsBundle == null) {
         System.Console.WriteLine(@"Could not find Settings.bundle");
         return;
     }
     NSString keyString = new NSString(@"Key");
     NSString defaultString = new NSString(@"DefaultValue");
     NSDictionary settings = NSDictionary.FromFile(Path.Combine(settingsBundle,@"Root.plist"));
     NSArray preferences = (NSArray) settings.ValueForKey(new NSString(@"PreferenceSpecifiers"));
     NSMutableDictionary defaultsToRegister = new NSMutableDictionary();
     for (uint i=0; i<preferences.Count; i++) {
         NSDictionary prefSpecification = new NSDictionary(preferences.ValueAt(i));
         NSString key = (NSString) prefSpecification.ValueForKey(keyString);
         if(key != null) {
             NSObject def = prefSpecification.ValueForKey(defaultString);
             if (def != null) {
                 defaultsToRegister.SetValueForKey(def, key);
             }
         }
     }
     NSUserDefaults.StandardUserDefaults.RegisterDefaults(defaultsToRegister);
 }
开发者ID:vaashr,项目名称:ProteinTracker,代码行数:31,代码来源:AppDelegate.cs

示例6: FinishedLaunching

        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            PushNotificationManager pushmanager = PushNotificationManager.PushManager;
            pushmanager.Delegate = this;

            if (options != null) {

                if (options.ContainsKey (UIApplication.LaunchOptionsRemoteNotificationKey)) {

                    var data = (NSDictionary)options.ValueForKey (UIApplication.LaunchOptionsRemoteNotificationKey);

                    HandleRemoteNotification (data, true);
                }
            }
            return true;
        }
开发者ID:JelleDamen,项目名称:PushwooshMvvmCrossPlugin,代码行数:16,代码来源:MvxPushwooshApplicationDelegate.cs

示例7: OnMessageReceived

        public void OnMessageReceived(NSDictionary userInfo)
        {
            var parameters = new Dictionary<string, object>();

            foreach (NSString key in userInfo.Keys)
            {
                parameters.Add(key, userInfo.ValueForKey(key));
            }

            if (CrossPushNotification.IsInitialized)
            {
                CrossPushNotification.PushNotificationListener.OnMessage(parameters, DeviceType.iOS);
            }else
            {
                throw NewPushNotificationNotInitializedException();
            }
        }
开发者ID:howbazaar,项目名称:xamarin-plugins,代码行数:17,代码来源:PushNotificationImplementation.cs

示例8: DidReceiveRemoteNotification

        public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
        {
            NSObject apsValue=userInfo.ValueForKey(new NSString("aps"));
            NSObject alertValue=apsValue.ValueForKey(new NSString("alert"));
            string msg=((NSString)alertValue).ToString();
            UIAlertController Alert = UIAlertController.Create ("",
                msg, UIAlertControllerStyle.Alert);
            Alert.AddAction (UIAlertAction.Create ("OK",
                UIAlertActionStyle.Cancel,
                null));

            try{
                if(Global.tabBarController!=null){
                    Global.tabBarController.PresentViewController(Alert,true,null);
                }else{
                    Window.RootViewController.PresentViewController (Alert, true, null);
                }
            }catch {
                //do nothing
            }
        }
开发者ID:MADMUC,项目名称:TAP5050,代码行数:21,代码来源:AppDelegate.cs

示例9: ViewDidLoad

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

			controls = new NSMutableArray ();

			// Fetching data from plist files

			string controlListPathString 	= NSBundle.MainBundle.BundlePath+"/ControlList.plist";
			controlDict 					= new NSDictionary();
			controlDict 					= NSDictionary.FromFile(controlListPathString);
			NSString controlDictKey 		= new NSString ("Control");
		    controlDictArray 				= controlDict.ValueForKey (controlDictKey) as NSArray;

			this.PrepareControlList ();

			// Register the TableView's data source
			TableView.Source = new AllControlsViewSource (this);

		}
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:21,代码来源:AllControlsViewController.cs

示例10: Save

		void Save (string path, int size, Action<bool> callback, NSDictionary data)
		{
			bool result = false;

			UIImage photo = null;
			UIImage source = null;
			NSData file = null;
			NSError error = null;

			try {
				source = data.ValueForKey (new NSString ("UIImagePickerControllerOriginalImage")) as UIImage;
				if (source != null) {

					photo = ScaleImage (source, size);
					file = photo.AsJPEG ();
					error = null;
					bool saved = file.Save (path, false, out error);
					if (!saved)
						_context.HandleException (new NonFatalException (D.IO_EXCEPTION, error.LocalizedDescription));
					result = saved;
				}
			} finally {
				if (photo != null)
					photo.Dispose ();
				if (source != null)
					source.Dispose ();
				if (file != null)
					file.Dispose ();
				if (error != null)
					error.Dispose ();
			}

			Task.Run (() => {
				Thread.Sleep (300);
				_context.InvokeOnMainThread (() => callback (result));
			});
		}
开发者ID:Fedorm,项目名称:core-master,代码行数:37,代码来源:ImagePickerProvider.cs

示例11: ReceivedRemoteNotification

        public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
        {
            // show an alert
            var body = userInfo.ValueForKey (new NSString("inAppMessage")).ToString ();
            var alert = MBAlertView.AlertWithBody (body, "Ok", null);
            alert.AddToDisplayQueue ();
            //			new UIAlertView("Back Channel Word Alert", userInfo.ValueForKey("inAppMessage").ToString(), null, "OK", null).Show();

            // reset our badge
            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
        }
开发者ID:redbitdev,项目名称:socialcloud-mobile,代码行数:11,代码来源:AppDelegate.cs

示例12: GetCell

			public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
			{
				var cell = tableView.DequeueReusableCell (SampleTableViewCell.Key) as SampleTableViewCell;
				if (cell == null)
					cell = new SampleTableViewCell ();

				// Configure the cell...

				nuint row 			= (nuint)indexPath.Row;
				NSString sampleName = sampleArray.GetItem<NSString> (row);
				cell.TextLabel.Text = sampleName;
				sampleDict     		= sampleDictArray.GetItem<NSDictionary>(row);

				if (sampleDict.ValueForKey (new NSString ("SampleName")).ToString () == sampleName) {

					if (sampleDict.ValueForKey (new NSString ("IsNew")).ToString () == "YES") {
						cell.DetailTextLabel.Text 		= "NEW";
						cell.DetailTextLabel.TextColor 	= UIColor.FromRGB (148, 75, 157);
					} else if (sampleDict.ValueForKey (new NSString ("IsUpdated")).ToString () == "YES") {
						cell.DetailTextLabel.Text 		= "UPDATED";
						cell.DetailTextLabel.TextColor 	= UIColor.FromRGB (148, 75, 157);
					} else {
						cell.DetailTextLabel.Text 		= null;
					}
				}
					
				cell.Accessory = UITableViewCellAccessory.None;
				return cell;
			}
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:29,代码来源:SampleViewController.cs

示例13: inspect

		private void inspect (NSArray selectedObjects)
		{
			NSDictionary objectDict = new NSDictionary (selectedObjects.ValueAt (0));
			
			if (objectDict != null) {
				NSString sss = new NSString ("url");
				NSUrl url = new NSUrl (objectDict.ValueForKey (sss).ToString ());
				NSWorkspace.SharedWorkspace.OpenUrl (url);                      
			}
		}
开发者ID:Anomalous-Software,项目名称:monomac,代码行数:10,代码来源:MyWindowController.cs

示例14: RowSelected

			public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
			{
				nuint row = (nuint)indexPath.Row;

				Control ctrl 				= controls.GetItem<Control> (row);
				string sampleListPathString = NSBundle.MainBundle.BundlePath+"/SampleList.plist";
				sampleDict 					= new NSDictionary();
				sampleDict 					= NSDictionary.FromFile(sampleListPathString);

				NSMutableArray dictArray	= sampleDict.ValueForKey (new NSString (ctrl.name)) as NSMutableArray;
				NSMutableArray sampArray 	= new NSMutableArray ();

				for (nuint i = 0; i < dictArray.Count; i++) {
					NSDictionary dict = dictArray.GetItem<NSDictionary> (i);
					sampArray.Add(dict.ValueForKey( new NSString("SampleName")));
				}


				SampleViewController sampleController 	= new SampleViewController();
				sampleController.selectedControl 		= ctrl.name;
				sampleController.sampleDictionaryArray 	= dictArray;
				sampleController.sampleArray 			= sampArray;

				controller.NavigationController.PushViewController(sampleController,true);
			}
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:25,代码来源:AllControlsViewController.cs

示例15: SaveImage

 void SaveImage(NSDictionary obj)
 {
     var picture = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
     var documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
     _imagePath = System.IO.Path.Combine(documentsDirectory, "picture.jpg"); // hardcoded filename, overwritten each time
     //_croppedImagePath = System.IO.Path.Combine(documentsDirectory, "picture-cropped.jpg");
     NSData imgData = picture.AsJPEG();
     NSError err = null;
     if (imgData.Save(_imagePath, false, out err))
     {
         SetCropper();
         //SetPicture(_imagePath);
     }
     else
     {
         Console.WriteLine("NOT saved as " + _imagePath + " because" + err.LocalizedDescription);
     }
 }
开发者ID:nielscup,项目名称:ImageCrop,代码行数:18,代码来源:ViewController.cs


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