-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #588 from Microsoft/develop
Merge develop into master
- Loading branch information
Showing
111 changed files
with
1,200 additions
and
899 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Apps/Contoso.Forms.Puppet/Contoso.Forms.Puppet.Droid/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
Apps/Contoso.Forms.Puppet/Contoso.Forms.Puppet.UWP/EventFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
using Microsoft.AppCenter; | ||
using Microsoft.AppCenter.Analytics.Ingestion.Models; | ||
using Microsoft.AppCenter.Channel; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Contoso.Forms.Puppet.UWP | ||
{ | ||
public class EventFilter : AppCenterService | ||
{ | ||
#region static | ||
|
||
private static readonly object EventFilterLock = new object(); | ||
|
||
private static EventFilter _instanceField; | ||
|
||
public static EventFilter Instance | ||
{ | ||
get | ||
{ | ||
lock (EventFilterLock) | ||
{ | ||
return _instanceField ?? (_instanceField = new EventFilter()); | ||
} | ||
} | ||
set | ||
{ | ||
lock (EventFilterLock) | ||
{ | ||
_instanceField = value; //for testing | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Check whether the EventFilter service is enabled or not. | ||
/// </summary> | ||
/// <returns>A task with result being true if enabled, false if disabled.</returns> | ||
public static Task<bool> IsEnabledAsync() | ||
{ | ||
lock (EventFilterLock) | ||
{ | ||
return Task.FromResult(Instance.InstanceEnabled); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Enable or disable the EventFilter service. | ||
/// </summary> | ||
/// <returns>A task to monitor the operation.</returns> | ||
public static Task SetEnabledAsync(bool enabled) | ||
{ | ||
lock (EventFilterLock) | ||
{ | ||
Instance.InstanceEnabled = enabled; | ||
return Task.FromResult(default(object)); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region instance | ||
|
||
public override bool InstanceEnabled | ||
{ | ||
get | ||
{ | ||
return base.InstanceEnabled; | ||
} | ||
|
||
set | ||
{ | ||
lock (_serviceLock) | ||
{ | ||
var prevValue = InstanceEnabled; | ||
base.InstanceEnabled = value; | ||
if (value != prevValue) | ||
{ | ||
ApplyEnabledState(value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
protected override string ChannelName => "event_filter"; | ||
|
||
public override string ServiceName => "EventFilter"; | ||
|
||
public Type BindingType { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
|
||
public override void OnChannelGroupReady(IChannelGroup channelGroup, string appSecret) | ||
{ | ||
lock (_serviceLock) | ||
{ | ||
base.OnChannelGroupReady(channelGroup, appSecret); | ||
ApplyEnabledState(InstanceEnabled); | ||
} | ||
} | ||
|
||
private void ApplyEnabledState(bool enabled) | ||
{ | ||
lock (_serviceLock) | ||
{ | ||
if (ChannelGroup != null) | ||
{ | ||
if (enabled) | ||
{ | ||
ChannelGroup.FilteringLog += FilterLog; | ||
} | ||
else | ||
{ | ||
ChannelGroup.FilteringLog -= FilterLog; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void FilterLog(object sender, FilteringLogEventArgs e) | ||
{ | ||
if (e.Log is EventLog) | ||
{ | ||
e.FilterRequested = true; | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Apps/Contoso.Forms.Puppet/Contoso.Forms.Puppet.UWP/EventFilterWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Contoso.Forms.Puppet.UWP | ||
{ | ||
internal class EventFilterWrapper : EventFilterHolder.IImplementation | ||
{ | ||
public Type BindingType => typeof(EventFilter); | ||
|
||
public Task<bool> IsEnabledAsync() => EventFilter.IsEnabledAsync(); | ||
|
||
public Task SetEnabledAsync(bool enabled) => EventFilter.SetEnabledAsync(enabled); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Apps/Contoso.Forms.Puppet/Contoso.Forms.Puppet/EventFilterHolder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Contoso.Forms.Puppet | ||
{ | ||
public static class EventFilterHolder | ||
{ | ||
public interface IImplementation | ||
{ | ||
Type BindingType { get; } | ||
|
||
Task<bool> IsEnabledAsync(); | ||
|
||
Task SetEnabledAsync(bool enabled); | ||
} | ||
|
||
public static IImplementation Implementation { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.