| 1 |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. |
| 2 |
|
| 3 |
#if WINDOWSPHONE7 |
| 4 |
|
| 5 |
#if DEBUG_NO_AGENT_SUPPORT |
| 6 |
using Microsoft.Phone.Shell; |
| 7 |
#else |
| 8 |
using System.Reactive.PlatformServices.Phone.Shell; |
| 9 |
#endif |
| 10 |
|
| 11 |
namespace System.Reactive.PlatformServices |
| 12 |
{ |
| 13 |
internal class HostLifecycleNotifications : IHostLifecycleNotifications |
| 14 |
{ |
| 15 |
private EventHandler<ActivatedEventArgs> _activated; |
| 16 |
private EventHandler<DeactivatedEventArgs> _deactivated; |
| 17 |
|
| 18 |
public event EventHandler<HostSuspendingEventArgs> Suspending |
| 19 |
{ |
| 20 |
add |
| 21 |
{ |
| 22 |
_deactivated = (o, e) => value(o, new HostSuspendingEventArgs()); |
| 23 |
|
| 24 |
var current = PhoneApplicationService.Current; |
| 25 |
if (current != null) |
| 26 |
current.Deactivated += _deactivated; |
| 27 |
} |
| 28 |
|
| 29 |
remove |
| 30 |
{ |
| 31 |
var current = PhoneApplicationService.Current; |
| 32 |
if (current != null) |
| 33 |
current.Deactivated -= _deactivated; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
public event EventHandler<HostResumingEventArgs> Resuming |
| 38 |
{ |
| 39 |
add |
| 40 |
{ |
| 41 |
_activated = (o, e) => |
| 42 |
{ |
| 43 |
if (e.IsApplicationInstancePreserved) |
| 44 |
{ |
| 45 |
value(o, new HostResumingEventArgs()); |
| 46 |
} |
| 47 |
}; |
| 48 |
|
| 49 |
var current = PhoneApplicationService.Current; |
| 50 |
if (current != null) |
| 51 |
current.Activated += _activated; |
| 52 |
} |
| 53 |
|
| 54 |
remove |
| 55 |
{ |
| 56 |
var current = PhoneApplicationService.Current; |
| 57 |
if (current != null) |
| 58 |
current.Activated -= _activated; |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
#endif |