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


C# NSDictionary.TryGetValue方法代码示例

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


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

示例1: FinishedLaunching

 // This method is invoked when the application has loaded its UI and its ready to run
 public override bool FinishedLaunching (UIApplication app, NSDictionary options)
 {
     Console.WriteLine ("something woke me up!");
     
     if (options != null) {
         
         NSObject launchedFromLocation;
         if (options.TryGetValue (UIApplication.LaunchOptionsLocationKey, out launchedFromLocation)) {
             
             if (((NSNumber)launchedFromLocation).BoolValue) {
                 Console.WriteLine ("Launched From Location Event");
                 
                 // wrapper method to ensure the location manager is created
                 // in the case where the app was launched in the background 
                 // due to a location update
                 LocationHelper.Initialize ();
             }
         }
     }
     
     window.AddSubview (locationTableController.View);
     
     window.MakeKeyAndVisible ();
     
     return true;
 }
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:27,代码来源:Main.cs

示例2: ReceivedRemoteNotification

		public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
		{
			NSObject aps, alert, payload;

			if(!userInfo.TryGetValue(new NSString("aps"), out aps))
				return;

			var apsHash = aps as NSDictionary;

			NotificationPayload payloadValue = null;
			if(apsHash.TryGetValue(new NSString("payload"), out payload))
			{
				payloadValue = JsonConvert.DeserializeObject<NotificationPayload>(payload.ToString());
				if(payloadValue != null)
				{
					MessagingCenter.Send(App.Instance, Shared.Messages.IncomingPayloadReceivedInternal, payloadValue);
				}
			}

			var badgeValue = apsHash.ObjectForKey(new NSString("badge"));

			if(badgeValue != null)
			{
				int count;
				if(int.TryParse(new NSString(badgeValue.ToString()), out count))
				{
					//UIApplication.SharedApplication.ApplicationIconBadgeNumber = count;
				}
			}

			if(apsHash.TryGetValue(new NSString("alert"), out alert))
			{
				alert.ToString().ToToast(ToastNotificationType.Info, "Incoming notification");
			}
		}
开发者ID:xamarin,项目名称:Sport,代码行数:35,代码来源:AppDelegate.cs

示例3: WillFinishLaunching

        public override bool WillFinishLaunching(UIApplication application, NSDictionary launchOptions)
        {
            /*
            UILocalNotification tn = new UILocalNotification();
            tn.AlertBody = "WillFinishLaunching";
            UIApplication.SharedApplication.PresentLocationNotificationNow(tn);
            */

            if (launchOptions != null)
            {
                NSObject launchFromLocations;
                if(launchOptions.TryGetValue(UIApplication.LaunchOptionsLocationKey, out launchFromLocations))
                {
                    if(((NSNumber)launchFromLocations).BoolValue)
                    {
                        UILocalNotification ln = new UILocalNotification();
                        ln.AlertBody = "position changed!";
                        ln.AlertAction = "просмотреть";
                        UIApplication.SharedApplication.PresentLocationNotificationNow(ln);
                    }
                }
            }

            return true;
        }
开发者ID:rzaitov,项目名称:ios_location_service,代码行数:25,代码来源:AppDelegate.cs

示例4: UITextAttributes

        internal UITextAttributes(NSDictionary dict)
        {
            if (dict == null)
                return;

            NSObject val;

            if (dict.TryGetValue (UITextAttributesConstants.Font, out val))
                Font = val as UIFont;
            if (dict.TryGetValue (UITextAttributesConstants.TextColor, out val))
                TextColor = val as UIColor;
            if (dict.TryGetValue (UITextAttributesConstants.TextShadowColor, out val))
                TextShadowColor = val as UIColor;
            if (dict.TryGetValue (UITextAttributesConstants.TextShadowOffset, out val)) {
                var value = val as NSValue;
                if (value != null)
                    TextShadowOffset = value.UIOffsetValue;
            }
        }
开发者ID:,项目名称:,代码行数:19,代码来源:

示例5: ReceivedRemoteNotification

        public void ReceivedRemoteNotification(NSDictionary userInfo)
        {
            NSObject inAppMessage;

            bool success = userInfo.TryGetValue(new NSString("inAppMessage"), out inAppMessage);

            if (success)
            {
                if (this.NotificationRecieved != null)
                this.NotificationRecieved(this, new AzureNotificationEventArgs(inAppMessage.ToString()));
            }
        }
开发者ID:pedroccrl,项目名称:Xamarin.Plugins-1,代码行数:12,代码来源:AzureNotifier.cs

示例6: ReceivedRemoteNotification

        public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
        {
            NSObject inAppMessage;

            bool success = userInfo.TryGetValue(new NSString("inAppMessage"), out inAppMessage);

            if (success)
            {
                var alert = new UIAlertView("Got push notification", inAppMessage.ToString(), null, "OK", null);
                alert.Show();
            }
        }
开发者ID:fellipetenorio,项目名称:mobile-services-samples,代码行数:12,代码来源:AppDelegate.cs

示例7: ReceivedRemoteNotification

        public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
        {
            // NOTE: Don't call the base implementation on a Model class
            // see http://docs.xamarin.com/guides/ios/application_fundamentals/delegates,_protocols,_and_events 

            Debug.WriteLine(userInfo.ToString());
            NSObject inAppMessage;

            bool success = userInfo.TryGetValue(new NSString("inAppMessage"), out inAppMessage);

            if (success)
            {
                var alert = new UIAlertView("Got push notification", inAppMessage.ToString(), null, "OK", null);
                alert.Show();
            }
        }
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:16,代码来源:AppDelegate.cs

示例8: ProcessPendingPayload

		void ProcessPendingPayload(NSDictionary userInfo)
		{
			if(userInfo == null)
				return;

			NSObject aps, payload, innerPayload;
			if(userInfo.TryGetValue(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey"), out payload))
			{
				if(((NSDictionary)payload).TryGetValue(new NSString("aps"), out aps))
				{
					if(((NSDictionary)aps).TryGetValue(new NSString("payload"), out innerPayload))
					{
						var notificationPayload = JsonConvert.DeserializeObject<NotificationPayload>(innerPayload.ToString());
						App.Current.OnIncomingPayload(notificationPayload);
					}
				}
			}
		}
开发者ID:denniskorir,项目名称:Sport,代码行数:18,代码来源:AppDelegate.cs

示例9: ReceivedRemoteNotification

		public async override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
		{
			NSObject inAppMessage;

			bool success = userInfo.TryGetValue(new NSString("inAppMessage"), out inAppMessage);

			if (success)
			{
				string[] parsedMessage = inAppMessage.ToString ().Split (',');

				//used for updating chats
				if(parsedMessage[0].Equals("comment")){
					await APushes.CommentPush(parsedMessage);
				}
				else if (parsedMessage[0].Equals("like"))
				{
					await APushes.LikePush(parsedMessage);
				}
				//standard use for notifications
				else if(parsedMessage[0].Equals("medal")){
					APushes.MedalPush(parsedMessage);
				}
				else if (parsedMessage[0].Equals("droplet"))
				{
					await APushes.DropletPush(parsedMessage);
				}
				else if (parsedMessage[0].Equals("dbNotification"))
				{
					APushes.DBNotificationPush(parsedMessage);
				}
				else if (parsedMessage[0].Equals("clubRequest"))
				{
					await APushes.ClubRequestPush(parsedMessage);
				}

			}
		}
开发者ID:bpeck81,项目名称:Cloudclub_v1,代码行数:37,代码来源:AppDelegate.cs

示例10: FinishedLaunching

        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            SensusServiceHelper.Initialize(() => new iOSSensusServiceHelper());

            // facebook settings
            Settings.AppID = "873948892650954";
            Settings.DisplayName = "Sensus";

            Forms.Init();
            FormsMaps.Init();
            MapExtendRenderer.Init();

            ToastNotificatorImplementation.Init();

            App app = new App();
            LoadApplication(app);

            uiApplication.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, new NSSet()));

            _serviceHelper = SensusServiceHelper.Get() as iOSSensusServiceHelper;

            UiBoundSensusServiceHelper.Set(_serviceHelper);
            app.SensusMainPage.DisplayServiceHelper(UiBoundSensusServiceHelper.Get(true));

            if (launchOptions != null)
            {
                NSObject launchOptionValue;
                if (launchOptions.TryGetValue(UIApplication.LaunchOptionsLocalNotificationKey, out launchOptionValue))
                    ServiceNotificationAsync(launchOptionValue as UILocalNotification);
                else if (launchOptions.TryGetValue(UIApplication.LaunchOptionsUrlKey, out launchOptionValue))
                    Protocol.DisplayFromBytesAsync(File.ReadAllBytes((launchOptionValue as NSUrl).Path));
            }

            // service all other notifications whose fire time has passed
            foreach (UILocalNotification notification in uiApplication.ScheduledLocalNotifications)
                if (notification.FireDate.ToDateTime() <= DateTime.UtcNow)
                    ServiceNotificationAsync(notification);

            return base.FinishedLaunching(uiApplication, launchOptions);
        }
开发者ID:cadancai,项目名称:sensus,代码行数:40,代码来源:AppDelegate.cs

示例11: ReceivedRemoteNotification

		public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
		{
			ProcessNotification(userInfo, notiCheck);



			NSObject Type;
			NSObject Id;

			var success = userInfo.TryGetValue(new NSString("type"), out Type);
			if (success)
			{
				success = userInfo.TryGetValue(new NSString("id"), out Id);
				NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;
				string alert = string.Empty;
				if (aps.ContainsKey(new NSString("alert"))) 
					alert = (aps[new NSString("alert")] as NSString).ToString();
				if (success)
				{
					App.notificationController.HandlePushNotification(Type.ToString(), Id.ToString(), notiCheck, alert);
				}
			}
		}
开发者ID:todibbang,项目名称:HowlOutApp,代码行数:23,代码来源:AppDelegate.cs

示例12: DidReceiveRemoteNotificationAsync

        public async Task DidReceiveRemoteNotificationAsync (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
        {
            backgroundFetchHandler = completionHandler;

            try {
                var syncManager = ServiceContainer.Resolve<ISyncManager> ();

                NSObject entryIdObj, modifiedAtObj;
                userInfo.TryGetValue (updatedAtConst, out modifiedAtObj);
                userInfo.TryGetValue (taskIdConst, out entryIdObj);

                var entryId = Convert.ToInt64 (entryIdObj.ToString ());

                var dataStore = ServiceContainer.Resolve<IDataStore> ();
                var rows = await dataStore.Table<TimeEntryData> ()
                           .Where (r => r.RemoteId == entryId)
                           .ToListAsync ();
                var entry = rows.FirstOrDefault();

                var modifiedAt = ParseDate (modifiedAtObj.ToString());

                var localDataNewer = entry != null && modifiedAt <= entry.ModifiedAt.ToUtc ();
                var skipSync = lastSyncTime.HasValue && modifiedAt < lastSyncTime.Value;

                if (syncManager.IsRunning || localDataNewer || skipSync) {
                    return;
                }

                syncManager.Run (SyncMode.Pull);
                if (syncManager.IsRunning) {
                    lastSyncTime = Time.UtcNow;
                }
            } catch (Exception ex) {
                var log = ServiceContainer.Resolve<ILogger> ();
                log.Error (Tag, ex, "Failed to process pushed message.");
            }
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:37,代码来源:APNSManager.cs

示例13: MPNowPlayingInfo

        internal MPNowPlayingInfo(NSDictionary source)
        {
            if (source == null)
                return;

            NSObject result;

            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyElapsedPlaybackTime, out result))
                ElapsedPlaybackTime = (result as NSNumber).DoubleValue;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyPlaybackRate, out result))
                PlaybackRate = (result as NSNumber).DoubleValue;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyPlaybackQueueIndex, out result))
                PlaybackQueueIndex = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyPlaybackQueueCount, out result))
                PlaybackQueueCount = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyChapterNumber, out result))
                ChapterNumber = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyChapterCount, out result))
                ChapterCount = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPNowPlayingInfoCenter.PropertyDefaultPlaybackRate, out result))
                DefaultPlaybackRate = (double) (result as NSNumber).DoubleValue;
            if (source.TryGetValue (MPMediaItem.AlbumTrackCountProperty, out result))
                AlbumTrackCount = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPMediaItem.AlbumTrackNumberProperty, out result))
                AlbumTrackNumber = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPMediaItem.DiscCountProperty, out result))
                DiscCount = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPMediaItem.DiscNumberProperty, out result))
                DiscNumber = (int) (result as NSNumber).UInt32Value;
            if (source.TryGetValue (MPMediaItem.PersistentIDProperty, out result))
                PersistentID = (result as NSNumber).UInt64Value;
            if (source.TryGetValue (MPMediaItem.PlaybackDurationProperty, out result))
                PlaybackDuration = (result as NSNumber).DoubleValue;

            if (source.TryGetValue (MPMediaItem.AlbumTitleProperty, out result))
                AlbumTitle = (string) (result as NSString);
            if (source.TryGetValue (MPMediaItem.ArtistProperty, out result))
                Artist = (string) (result as NSString);
            if (source.TryGetValue (MPMediaItem.ArtworkProperty, out result))
                Artwork = result as MPMediaItemArtwork;
            if (source.TryGetValue (MPMediaItem.ComposerProperty, out result))
                Composer = (string) (result as NSString);
            if (source.TryGetValue (MPMediaItem.GenreProperty, out result))
                Genre = (string) (result as NSString);
            if (source.TryGetValue (MPMediaItem.TitleProperty, out result))
                Title = (string) (result as NSString);
        }
开发者ID:,项目名称:,代码行数:47,代码来源:


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