本文整理汇总了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;
}
示例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");
}
}
示例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;
}
示例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;
}
}
示例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()));
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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.");
}
}
示例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);
}