Skip to content

Commit

Permalink
Merge pull request #1547 from Microsoft/nmetulev/cleanup
Browse files Browse the repository at this point in the history
Added comments and fixed stylecop warnings
  • Loading branch information
nmetulev authored Oct 12, 2017
2 parents 596ef81 + 9257fa5 commit 92ca411
Show file tree
Hide file tree
Showing 106 changed files with 810 additions and 343 deletions.
6 changes: 3 additions & 3 deletions Microsoft.Toolkit.Services/Core/DataProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Toolkit.Services.Exceptions;
using System.Net.Http;

namespace Microsoft.Toolkit.Services
{
Expand All @@ -26,7 +26,7 @@ namespace Microsoft.Toolkit.Services
public abstract class DataProviderBase<TConfig>
{
/// <summary>
/// Constructor
/// Initializes a new instance of the <see cref="DataProviderBase{TConfig}"/> class.
/// </summary>
public DataProviderBase()
{
Expand Down Expand Up @@ -71,7 +71,7 @@ public async Task<IEnumerable<TSchema>> LoadDataAsync<TSchema>(TConfig config, i
private static HttpClient httpClient;

/// <summary>
/// Static instance of HttpClient.
/// Gets or sets static instance of HttpClient.
/// </summary>
public static HttpClient HttpClient
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Toolkit.Services.Core;
using Microsoft.Toolkit.Services.Exceptions;
using System.Net.Http;

namespace Microsoft.Toolkit.Services.Bing
{
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Toolkit.Services/Services/Bing/BingParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using Microsoft.Toolkit.Services.Rss;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Toolkit.Services.Rss;

namespace Microsoft.Toolkit.Services.Bing
{
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Toolkit.Services/Services/Bing/BingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Toolkit.Services.Core;
using Microsoft.Toolkit.Collections;
using Microsoft.Toolkit.Services.Core;

namespace Microsoft.Toolkit.Services.Bing
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private void DeviceWatcher_EnumerationCompleted(DeviceWatcher sender, object arg
StopEnumeration();

EnumerationCompleted?.Invoke(sender, EventArgs.Empty);
}
}
}

/// <summary>
Expand All @@ -341,7 +341,6 @@ private async Task AddDeviceToList(DeviceInformation deviceInfo)
(device.DeviceInfo.Properties.Keys.Contains("System.Devices.Aep.IsConnected") &&
(bool)device.DeviceInfo.Properties["System.Devices.Aep.IsConnected"]);


if (connectable)
{
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
Expand All @@ -41,29 +41,36 @@ public class ObservableBluetoothLEDevice : INotifyPropertyChanged, IEquatable<Ob
/// </summary>
public class RSSIComparer : IComparer
{
/// <summary>
/// Compares two ObservableBluettothLEDevices and returns a value indicating
/// whether one is less than, equal to, or greater than the other.
/// </summary>
/// <param name="x">First object to compare</param>
/// <param name="y">Second object to compare</param>
/// <returns>Returns 0 if equal</returns>
public int Compare(object x, object y)
{
ObservableBluetoothLEDevice a = x as ObservableBluetoothLEDevice;
ObservableBluetoothLEDevice b = y as ObservableBluetoothLEDevice;

if( a == null || b == null)
if (a == null || b == null)
{
throw new InvalidOperationException("Compared objects are not ObservableBluetoothLEDevice");
}

// If they're equal
if(a.RSSI == b.RSSI)
if (a.RSSI == b.RSSI)
{
return 0;
}

// RSSI == 0 means we don't know it. Always make that the end.
if(b.RSSI == 0)
if (b.RSSI == 0)
{
return -1;
}

if(a.RSSI < b.RSSI || a.RSSI == 0)
if (a.RSSI < b.RSSI || a.RSSI == 0)
{
return 1;
}
Expand Down Expand Up @@ -113,17 +120,17 @@ public int Compare(object x, object y)
/// result of finding all the services
/// </summary>
private GattDeviceServicesResult _result;
/// <summary>
/// Queue to store the last 10 observed RSSI values
/// </summary>
private Queue<int> _rssiValue = new Queue<int>(10);

/// <summary>
/// Queue to store the last 10 observed RSSI values
/// </summary>
private Queue<int> _rssiValue = new Queue<int>(10);

/// <summary>
/// Source for <see cref="RSSI"/>
/// </summary>
private int _rssi;

/// <summary>
/// Source for <see cref="ServiceCount" />
/// </summary>
Expand Down Expand Up @@ -325,7 +332,6 @@ private set
}
}


/// <summary>
/// Gets the RSSI value of this device
/// </summary>
Expand All @@ -342,10 +348,11 @@ private set
{
_rssiValue.Dequeue();
}

_rssiValue.Enqueue(value);

int newValue = (int)Math.Round(_rssiValue.Average(), 0);

if (_rssi != newValue)
{
_rssi = newValue;
Expand Down Expand Up @@ -380,9 +387,9 @@ bool IEquatable<ObservableBluetoothLEDevice>.Equals(ObservableBluetoothLEDevice

private void ObservableBluetoothLEDevice_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if(e.PropertyName == "DeviceInfo")
if (e.PropertyName == "DeviceInfo")
{
if(DeviceInfo.Properties.ContainsKey("System.Devices.Aep.SignalStrength") && DeviceInfo.Properties["System.Devices.Aep.SignalStrength"] != null)
if (DeviceInfo.Properties.ContainsKey("System.Devices.Aep.SignalStrength") && DeviceInfo.Properties["System.Devices.Aep.SignalStrength"] != null)
{
RSSI = (int)DeviceInfo.Properties["System.Devices.Aep.SignalStrength"];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static void OnIsActiveChanged(DependencyObject d, DependencyPropertyChan
private TextBlock controlFirstParentWithName;

/// <summary>
/// Gets or sets a boolean indicating whether the tracker is running or not.
/// Gets or sets a value indicating whether the tracker is running or not.
/// </summary>
public bool IsActive
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ namespace Microsoft.Toolkit.Uwp.Notifications
public sealed class AdaptiveGroup : ITileBindingContentAdaptiveChild, IAdaptiveChild, IToastBindingGenericChild
{
/// <summary>
/// The only valid children of groups are <see cref="AdaptiveSubgroup"/>. Each subgroup is displayed as a separate vertical column. Note that you must include at least one subgroup in your group, otherwise an <see cref="InvalidOperationException"/> will be thrown when you try to retrieve the XML for the notification.
/// Gets the only valid children of groups are <see cref="AdaptiveSubgroup"/>.
/// Each subgroup is displayed as a separate vertical column. Note that you must
/// include at least one subgroup in your group, otherwise an <see cref="InvalidOperationException"/>
/// will be thrown when you try to retrieve the XML for the notification.
/// </summary>
public IList<AdaptiveSubgroup> Children { get; private set; } = new List<AdaptiveSubgroup>();

Expand Down
23 changes: 17 additions & 6 deletions Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,30 @@ public sealed class AdaptiveImage
IAdaptiveSubgroupChild
{
/// <summary>
/// Control the desired cropping of the image. Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// Gets or sets the desired cropping of the image.
/// Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// </summary>
public AdaptiveImageCrop HintCrop { get; set; }

/// <summary>
/// By default, images have an 8px margin around them. You can remove this margin by setting this property to true. Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// Gets or sets a value whether a margin is removed. images have an 8px margin around them.
/// You can remove this margin by setting this property to true.
/// Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// </summary>
public bool? HintRemoveMargin { get; set; }

/// <summary>
/// The horizontal alignment of the image. For Toast, this is only supported when inside an <see cref="AdaptiveSubgroup"/>.
/// Gets or sets the horizontal alignment of the image.
/// For Toast, this is only supported when inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public AdaptiveImageAlign HintAlign { get; set; }

private string _source;

/// <summary>
/// Required. The URI of the image. Can be from your application package, application data, or the internet. Internet images must be less than 200 KB in size.
/// Gets or sets the URI of the image (Required).
/// Can be from your application package, application data, or the internet.
/// Internet images must be less than 200 KB in size.
/// </summary>
public string Source
{
Expand All @@ -51,12 +57,17 @@ public string Source
}

/// <summary>
/// A description of the image, for users of assistive technologies.
/// Gets or sets a description of the image, for users of assistive technologies.
/// </summary>
public string AlternateText { get; set; }

/// <summary>
/// Set to true to allow Windows to append a query string to the image URI supplied in the Tile notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language.
/// Gets or sets set to true to allow Windows to append a query string to the image URI
/// supplied in the Tile notification. Use this attribute if your server hosts
/// images and can handle query strings, either by retrieving an image variant based
/// on the query strings or by ignoring the query string and returning the image
/// as specified without the query string. This query string specifies scale,
/// contrast setting, and language.
/// </summary>
public bool? AddImageQuery { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public sealed class AdaptiveProgressBar : IToastBindingGenericChild
ValueStringOverride { get; set; }

/// <summary>
/// Required. Gets or sets a status string, which is displayed underneath the progress bar. This string should reflect the status of the operation, like "Downloading..." or "Installing..."
/// Gets or sets a status string (Required), which is displayed underneath the progress bar. This string should reflect the status of the operation, like "Downloading..." or "Installing..."
/// </summary>
public
#if WINRT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public sealed class AdaptiveProgressBarValue
public double Value { get; set; }

/// <summary>
/// Gets or sets whether the progress bar is indeterminate.
/// Gets or sets a value indicating whether the progress bar is indeterminate.
/// </summary>
public bool IsIndeterminate { get; set; }

/// <summary>
/// Private constructor
/// Initializes a new instance of the <see cref="AdaptiveProgressBarValue"/> class.
/// </summary>
private AdaptiveProgressBarValue()
{
Expand All @@ -47,7 +47,7 @@ internal string ToXmlString()
}

/// <summary>
/// Returns an indeterminate progress bar value.
/// Gets an indeterminate progress bar value.
/// </summary>
public static AdaptiveProgressBarValue Indeterminate
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ namespace Microsoft.Toolkit.Uwp.Notifications
public sealed class AdaptiveSubgroup
{
/// <summary>
/// <see cref="AdaptiveText"/> and <see cref="AdaptiveImage"/> are valid children of subgroups.
/// Gets a list of Children. <see cref="AdaptiveText"/> and <see cref="AdaptiveImage"/> are valid children of subgroups.
/// </summary>
public IList<IAdaptiveSubgroupChild> Children { get; private set; } = new List<IAdaptiveSubgroupChild>();

private int? _hintWeight;

/// <summary>
/// Control the width of this subgroup column by specifying the weight, relative to the other subgroups.
/// Gets or sets the width of this subgroup column by specifying the weight, relative to the other subgroups.
/// </summary>
public int? HintWeight
{
Expand All @@ -47,7 +47,7 @@ public int? HintWeight
}

/// <summary>
/// Control the vertical alignment of this subgroup's content.
/// Gets or sets the vertical alignment of this subgroup's content.
/// </summary>
public AdaptiveSubgroupTextStacking HintTextStacking { get; set; } = Element_AdaptiveSubgroup.DEFAULT_TEXT_STACKING;

Expand Down
28 changes: 21 additions & 7 deletions Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public sealed class AdaptiveText
#endif

/// <summary>
/// The text to display. Data binding support added in Creators Update, only works for toast top-level text elements.
/// Gets or sets the text to display. Data binding support added in Creators Update,
/// only works for toast top-level text elements.
/// </summary>
public
#if WINRT
Expand All @@ -45,24 +46,35 @@ public sealed class AdaptiveText
Text { get; set; }

/// <summary>
/// The target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR". The locale specified here overrides any other specified locale, such as that in binding or visual. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string.
/// Gets or sets the target locale of the XML payload, specified as a BCP-47 language tags
/// such as "en-US" or "fr-FR". The locale specified here overrides any other specified
/// locale, such as that in binding or visual. If this value is a literal string,
/// this attribute defaults to the user's UI language. If this value is a string reference,
/// this attribute defaults to the locale chosen by Windows Runtime in resolving the string.
/// </summary>
public string Language { get; set; }

/// <summary>
/// The style controls the text's font size, weight, and opacity. Note that for Toast, the style will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// Gets or sets the style that controls the text's font size, weight, and opacity.
/// Note that for Toast, the style will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public AdaptiveTextStyle HintStyle { get; set; }

/// <summary>
/// Set this to true to enable text wrapping. For Tiles, this is false by default. For Toasts, this is true on top-level text elements, and false inside an <see cref="AdaptiveSubgroup"/>. Note that for Toast, setting wrap will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/> (you can use HintMaxLines = 1 to prevent top-level text elements from wrapping).
/// Gets or sets a value whether text wrapping is enabled. For Tiles, this is false by default.
/// For Toasts, this is true on top-level text elements, and false inside an <see cref="AdaptiveSubgroup"/>.
/// Note that for Toast, setting wrap will only take effect if the text is inside an
/// <see cref="AdaptiveSubgroup"/> (you can use HintMaxLines = 1 to prevent top-level text elements from wrapping).
/// </summary>
public bool? HintWrap { get; set; }

private int? _hintMaxLines;

/// <summary>
/// The maximum number of lines the text element is allowed to display. For Tiles, this is infinity by default. For Toasts, top-level text elements will have varying max line amounts (and in the Anniversary Update you can change the max lines). Text on a Toast inside an <see cref="AdaptiveSubgroup"/> will behave identically to Tiles (default to infinity).
/// Gets or sets the maximum number of lines the text element is allowed to display.
/// For Tiles, this is infinity by default. For Toasts, top-level text elements will
/// have varying max line amounts (and in the Anniversary Update you can change the max lines).
/// Text on a Toast inside an <see cref="AdaptiveSubgroup"/> will behave identically to Tiles (default to infinity).
/// </summary>
public int? HintMaxLines
{
Expand All @@ -85,7 +97,8 @@ public int? HintMaxLines
private int? _hintMinLines;

/// <summary>
/// The minimum number of lines the text element must display. Note that for Toast, this property will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// Gets or sets the minimum number of lines the text element must display.
/// Note that for Toast, this property will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public int? HintMinLines
{
Expand All @@ -106,7 +119,8 @@ public int? HintMinLines
}

/// <summary>
/// The horizontal alignment of the text. Note that for Toast, this property will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// Gets or sets the horizontal alignment of the text. Note that for Toast, this property will
/// only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public AdaptiveTextAlign HintAlign { get; set; }

Expand Down
Loading

0 comments on commit 92ca411

Please sign in to comment.