| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.#if WINDOWSPHONE7#if DEBUG_NO_AGENT_SUPPORTusing Microsoft.Phone.Shell;#elseusing System.Reactive.PlatformServices.Phone.Shell;#endifnamespace System.Reactive.PlatformServices{    internal class HostLifecycleNotifications : IHostLifecycleNotifications    {        private EventHandler<ActivatedEventArgs> _activated;        private EventHandler<DeactivatedEventArgs> _deactivated;        public event EventHandler<HostSuspendingEventArgs> Suspending        {            add            {                _deactivated = (o, e) => value(o, new HostSuspendingEventArgs());                var current = PhoneApplicationService.Current;                if (current != null)                    current.Deactivated += _deactivated;            }            remove            {                var current = PhoneApplicationService.Current;                if (current != null)                    current.Deactivated -= _deactivated;            }        }        public event EventHandler<HostResumingEventArgs> Resuming        {            add            {                _activated = (o, e) =>                {                    if (e.IsApplicationInstancePreserved)                    {                        value(o, new HostResumingEventArgs());                    }                };                var current = PhoneApplicationService.Current;                if (current != null)                    current.Activated += _activated;            }            remove            {                var current = PhoneApplicationService.Current;                if (current != null)                    current.Activated -= _activated;            }        }    }}#endif
 |