Unity.Platform.IPhone.IPhoneServiceLocator.GetInstance C# (CSharp) Method

GetInstance() public static method

Hides the AbstractServiceLocator class static method by using the keyword new.
public static GetInstance ( ) : IServiceLocator
return IServiceLocator
        public new static IServiceLocator GetInstance() 
        {
            if (singletonServiceLocator == null)
            {
                singletonServiceLocator = new IPhoneServiceLocator();

				// initialize UIApplication weak delegates
				var tsEnumerator = typedServices.GetEnumerator ();
				while (tsEnumerator.MoveNext())
				{
					var typedService = tsEnumerator.Current;
					if (typedService.Value is IWeakDelegateManager) {
						IPhoneServiceLocator.UIApplicationWeakDelegate.RegisterWeakDelegate((typedService.Value as IWeakDelegateManager), typedService.Key);
					}
				}

				NSUrlProtocol.RegisterClass (new ObjCRuntime.Class (typeof (IPhoneNSUrlProtocol)));

            }
            return singletonServiceLocator;
        }

Usage Example

Example #1
0
        void HandleMailFinished(object sender, MFComposeResultEventArgs e)
        {
            UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                if (e.Result == MFMailComposeResult.Sent)
                {
                    // No action required
                }
                else if (e.Result == MFMailComposeResult.Cancelled)
                {
                    // No action required
                }
                else if (e.Result == MFMailComposeResult.Failed)
                {
                    INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance().GetService("notify");
                    if (notificationService != null)
                    {
                        notificationService.StartNotifyAlert("Mail Error", "Failed to send mail.\n" + e.Error, "OK");
                    }
                }
                else if (e.Result == MFMailComposeResult.Saved)
                {
                    INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance().GetService("notify");
                    if (notificationService != null)
                    {
                        notificationService.StartNotifyAlert("Mail Alert", "Mail saved to draft.", "OK");
                    }
                }

                // method reviewed (15 April 2014).
                e.Controller.DismissViewController(true, null);

                // deprecated --> e.Controller.DismissModalViewController (true);
            });
        }
All Usage Examples Of Unity.Platform.IPhone.IPhoneServiceLocator::GetInstance