remove regions

pull/3390/head
telans 5 years ago
parent 8de6452967
commit 8e3d874802
No known key found for this signature in database
GPG Key ID: 195444EE92DBCB20

@ -19,8 +19,6 @@ namespace Emby.Dlna.PlayTo
{ {
public class Device : IDisposable public class Device : IDisposable
{ {
#region Fields & Properties
private Timer _timer; private Timer _timer;
public DeviceInfo Properties { get; set; } public DeviceInfo Properties { get; set; }
@ -53,10 +51,10 @@ namespace Emby.Dlna.PlayTo
public bool IsStopped => TransportState == TRANSPORTSTATE.STOPPED; public bool IsStopped => TransportState == TRANSPORTSTATE.STOPPED;
#endregion
private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
public Action OnDeviceUnavailable { get; set; } public Action OnDeviceUnavailable { get; set; }
@ -142,8 +140,6 @@ namespace Emby.Dlna.PlayTo
} }
} }
#region Commanding
public Task VolumeDown(CancellationToken cancellationToken) public Task VolumeDown(CancellationToken cancellationToken)
{ {
var sendVolume = Math.Max(Volume - 5, 0); var sendVolume = Math.Max(Volume - 5, 0);
@ -402,11 +398,8 @@ namespace Emby.Dlna.PlayTo
RestartTimer(true); RestartTimer(true);
} }
#endregion
#region Get data
private int _connectFailureCount; private int _connectFailureCount;
private async void TimerCallback(object sender) private async void TimerCallback(object sender)
{ {
if (_disposed) if (_disposed)
@ -870,10 +863,6 @@ namespace Emby.Dlna.PlayTo
return new string[4]; return new string[4];
} }
#endregion
#region From XML
private async Task<TransportCommands> GetAVProtocolAsync(CancellationToken cancellationToken) private async Task<TransportCommands> GetAVProtocolAsync(CancellationToken cancellationToken)
{ {
if (AvCommands != null) if (AvCommands != null)
@ -1068,8 +1057,6 @@ namespace Emby.Dlna.PlayTo
return new Device(deviceProperties, httpClient, logger, config); return new Device(deviceProperties, httpClient, logger, config);
} }
#endregion
private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
private static DeviceIcon CreateIcon(XElement element) private static DeviceIcon CreateIcon(XElement element)
{ {
@ -1193,8 +1180,6 @@ namespace Emby.Dlna.PlayTo
}); });
} }
#region IDisposable
bool _disposed; bool _disposed;
public void Dispose() public void Dispose()
@ -1221,8 +1206,6 @@ namespace Emby.Dlna.PlayTo
_disposed = true; _disposed = true;
} }
#endregion
public override string ToString() public override string ToString()
{ {
return string.Format("{0} - {1}", Properties.Name, Properties.BaseUrl); return string.Format("{0} - {1}", Properties.Name, Properties.BaseUrl);

@ -224,8 +224,6 @@ namespace MediaBrowser.Controller.Library
public string CollectionType { get; set; } public string CollectionType { get; set; }
#region Equality Overrides
/// <summary> /// <summary>
/// Determines whether the specified <see cref="object" /> is equal to this instance. /// Determines whether the specified <see cref="object" /> is equal to this instance.
/// </summary> /// </summary>
@ -260,8 +258,5 @@ namespace MediaBrowser.Controller.Library
return false; return false;
} }
#endregion
} }
} }

@ -37,7 +37,6 @@ namespace MediaBrowser.Controller.Library
_stopwatch = new Stopwatch(); _stopwatch = new Stopwatch();
_stopwatch.Start(); _stopwatch.Start();
} }
#region IDisposable Members
/// <summary> /// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
@ -71,7 +70,5 @@ namespace MediaBrowser.Controller.Library
_logger.LogInformation(message); _logger.LogInformation(message);
} }
} }
#endregion
} }
} }

@ -10,14 +10,9 @@ namespace Rssdp
{ {
public IPAddress LocalIpAddress { get; set; } public IPAddress LocalIpAddress { get; set; }
#region Fields
private readonly DiscoveredSsdpDevice _DiscoveredDevice; private readonly DiscoveredSsdpDevice _DiscoveredDevice;
private readonly bool _IsNewlyDiscovered;
#endregion private readonly bool _IsNewlyDiscovered;
#region Constructors
/// <summary> /// <summary>
/// Full constructor. /// Full constructor.
@ -33,10 +28,6 @@ namespace Rssdp
_IsNewlyDiscovered = isNewlyDiscovered; _IsNewlyDiscovered = isNewlyDiscovered;
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Returns true if the device was discovered due to an alive notification, or a search and was not already in the cache. Returns false if the item came from the cache but matched the current search request. /// Returns true if the device was discovered due to an alive notification, or a search and was not already in the cache. Returns false if the item came from the cache but matched the current search request.
/// </summary> /// </summary>
@ -52,7 +43,5 @@ namespace Rssdp
{ {
get { return _DiscoveredDevice; } get { return _DiscoveredDevice; }
} }
#endregion
} }
} }

@ -7,15 +7,8 @@ namespace Rssdp
/// </summary> /// </summary>
public sealed class DeviceEventArgs : EventArgs public sealed class DeviceEventArgs : EventArgs
{ {
#region Fields
private readonly SsdpDevice _Device; private readonly SsdpDevice _Device;
#endregion
#region Constructors
/// <summary> /// <summary>
/// Constructs a new instance for the specified <see cref="SsdpDevice"/>. /// Constructs a new instance for the specified <see cref="SsdpDevice"/>.
/// </summary> /// </summary>
@ -28,10 +21,6 @@ namespace Rssdp
_Device = device; _Device = device;
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Returns the <see cref="SsdpDevice"/> instance the event being raised for. /// Returns the <see cref="SsdpDevice"/> instance the event being raised for.
/// </summary> /// </summary>
@ -39,7 +28,5 @@ namespace Rssdp
{ {
get { return _Device; } get { return _Device; }
} }
#endregion
} }
} }

@ -7,15 +7,9 @@ namespace Rssdp
/// </summary> /// </summary>
public sealed class DeviceUnavailableEventArgs : EventArgs public sealed class DeviceUnavailableEventArgs : EventArgs
{ {
#region Fields
private readonly DiscoveredSsdpDevice _DiscoveredDevice; private readonly DiscoveredSsdpDevice _DiscoveredDevice;
private readonly bool _Expired;
#endregion
#region Constructors private readonly bool _Expired;
/// <summary> /// <summary>
/// Full constructor. /// Full constructor.
@ -31,10 +25,6 @@ namespace Rssdp
_Expired = expired; _Expired = expired;
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Returns true if the device is considered unavailable because it's cached information expired before a new alive notification or search result was received. Returns false if the device is unavailable because it sent an explicit notification of it's unavailability. /// Returns true if the device is considered unavailable because it's cached information expired before a new alive notification or search result was received. Returns false if the device is unavailable because it sent an explicit notification of it's unavailability.
/// </summary> /// </summary>
@ -50,7 +40,5 @@ namespace Rssdp
{ {
get { return _DiscoveredDevice; } get { return _DiscoveredDevice; }
} }
#endregion
} }
} }

@ -10,15 +10,8 @@ namespace Rssdp
/// <seealso cref="Infrastructure.ISsdpDeviceLocator"/> /// <seealso cref="Infrastructure.ISsdpDeviceLocator"/>
public sealed class DiscoveredSsdpDevice public sealed class DiscoveredSsdpDevice
{ {
#region Fields
private DateTimeOffset _AsAt; private DateTimeOffset _AsAt;
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Sets or returns the type of notification, being either a uuid, device type, service type or upnp:rootdevice. /// Sets or returns the type of notification, being either a uuid, device type, service type or upnp:rootdevice.
/// </summary> /// </summary>
@ -60,10 +53,6 @@ namespace Rssdp
/// </summary> /// </summary>
public HttpHeaders ResponseHeaders { get; set; } public HttpHeaders ResponseHeaders { get; set; }
#endregion
#region Public Methods
/// <summary> /// <summary>
/// Returns true if this device information has expired, based on the current date/time, and the <see cref="CacheLifetime"/> &amp; <see cref="AsAt"/> properties. /// Returns true if this device information has expired, based on the current date/time, and the <see cref="CacheLifetime"/> &amp; <see cref="AsAt"/> properties.
/// </summary> /// </summary>
@ -73,10 +62,6 @@ namespace Rssdp
return this.CacheLifetime == TimeSpan.Zero || this.AsAt.Add(this.CacheLifetime) <= DateTimeOffset.Now; return this.CacheLifetime == TimeSpan.Zero || this.AsAt.Add(this.CacheLifetime) <= DateTimeOffset.Now;
} }
#endregion
#region Overrides
/// <summary> /// <summary>
/// Returns the device's <see cref="Usn"/> value. /// Returns the device's <see cref="Usn"/> value.
/// </summary> /// </summary>
@ -85,7 +70,5 @@ namespace Rssdp
{ {
return this.Usn; return this.Usn;
} }
#endregion
} }
} }

@ -9,9 +9,6 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public abstract class DisposableManagedObjectBase : IDisposable public abstract class DisposableManagedObjectBase : IDisposable
{ {
#region Public Methods
/// <summary> /// <summary>
/// Override this method and dispose any objects you own the lifetime of if disposing is true; /// Override this method and dispose any objects you own the lifetime of if disposing is true;
/// </summary> /// </summary>
@ -29,10 +26,6 @@ namespace Rssdp.Infrastructure
if (this.IsDisposed) throw new ObjectDisposedException(this.GetType().FullName); if (this.IsDisposed) throw new ObjectDisposedException(this.GetType().FullName);
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Sets or returns a boolean indicating whether or not this instance has been disposed. /// Sets or returns a boolean indicating whether or not this instance has been disposed.
/// </summary> /// </summary>
@ -42,9 +35,6 @@ namespace Rssdp.Infrastructure
get; get;
private set; private set;
} }
#endregion
public string BuildMessage(string header, Dictionary<string, string> values) public string BuildMessage(string header, Dictionary<string, string> values)
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
@ -63,8 +53,6 @@ namespace Rssdp.Infrastructure
return builder.ToString(); return builder.ToString();
} }
#region IDisposable Members
/// <summary> /// <summary>
/// Disposes this object instance and all internally managed resources. /// Disposes this object instance and all internally managed resources.
/// </summary> /// </summary>
@ -79,7 +67,5 @@ namespace Rssdp.Infrastructure
Dispose(true); Dispose(true);
} }
#endregion
} }
} }

@ -11,16 +11,9 @@ namespace Rssdp.Infrastructure
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public abstract class HttpParserBase<T> where T : new() public abstract class HttpParserBase<T> where T : new()
{ {
#region Fields
private readonly string[] LineTerminators = new string[] { "\r\n", "\n" }; private readonly string[] LineTerminators = new string[] { "\r\n", "\n" };
private readonly char[] SeparatorCharacters = new char[] { ',', ';' }; private readonly char[] SeparatorCharacters = new char[] { ',', ';' };
#endregion
#region Public Methods
/// <summary> /// <summary>
/// Parses the <paramref name="data"/> provided into either a <see cref="HttpRequestMessage"/> or <see cref="HttpResponseMessage"/> object. /// Parses the <paramref name="data"/> provided into either a <see cref="HttpRequestMessage"/> or <see cref="HttpResponseMessage"/> object.
/// </summary> /// </summary>
@ -81,10 +74,6 @@ namespace Rssdp.Infrastructure
return Version.Parse(versionData.Substring(versionSeparatorIndex + 1)); return Version.Parse(versionData.Substring(versionSeparatorIndex + 1));
} }
#endregion
#region Private Methods
/// <summary> /// <summary>
/// Parses a line from an HTTP request or response message containing a header name and value pair. /// Parses a line from an HTTP request or response message containing a header name and value pair.
/// </summary> /// </summary>
@ -202,8 +191,5 @@ namespace Rssdp.Infrastructure
else else
return trimmedSegment; return trimmedSegment;
} }
#endregion
} }
} }

@ -9,18 +9,11 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public sealed class HttpRequestParser : HttpParserBase<HttpRequestMessage> public sealed class HttpRequestParser : HttpParserBase<HttpRequestMessage>
{ {
#region Fields & Constants
private readonly string[] ContentHeaderNames = new string[] private readonly string[] ContentHeaderNames = new string[]
{ {
"Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified" "Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"
}; };
#endregion
#region Public Methods
/// <summary> /// <summary>
/// Parses the specified data into a <see cref="HttpRequestMessage"/> instance. /// Parses the specified data into a <see cref="HttpRequestMessage"/> instance.
/// </summary> /// </summary>
@ -45,10 +38,6 @@ namespace Rssdp.Infrastructure
} }
} }
#endregion
#region Overrides
/// <summary> /// <summary>
/// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the <paramref name="message"/>. /// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the <paramref name="message"/>.
/// </summary> /// </summary>
@ -83,7 +72,5 @@ namespace Rssdp.Infrastructure
{ {
return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase); return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase);
} }
#endregion
} }
} }

@ -10,18 +10,11 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public sealed class HttpResponseParser : HttpParserBase<HttpResponseMessage> public sealed class HttpResponseParser : HttpParserBase<HttpResponseMessage>
{ {
#region Fields & Constants
private readonly string[] ContentHeaderNames = new string[] private readonly string[] ContentHeaderNames = new string[]
{ {
"Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified" "Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"
}; };
#endregion
#region Public Methods
/// <summary> /// <summary>
/// Parses the specified data into a <see cref="HttpResponseMessage"/> instance. /// Parses the specified data into a <see cref="HttpResponseMessage"/> instance.
/// </summary> /// </summary>
@ -47,10 +40,6 @@ namespace Rssdp.Infrastructure
} }
} }
#endregion
#region Overrides Methods
/// <summary> /// <summary>
/// Returns a boolean indicating whether the specified HTTP header name represents a content header (true), or a message header (false). /// Returns a boolean indicating whether the specified HTTP header name represents a content header (true), or a message header (false).
/// </summary> /// </summary>
@ -87,7 +76,5 @@ namespace Rssdp.Infrastructure
message.ReasonPhrase = parts[2].Trim(); message.ReasonPhrase = parts[2].Trim();
} }
} }
#endregion
} }
} }

@ -10,9 +10,6 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public interface ISsdpCommunicationsServer : IDisposable public interface ISsdpCommunicationsServer : IDisposable
{ {
#region Events
/// <summary> /// <summary>
/// Raised when a HTTPU request message is received by a socket (unicast or multicast). /// Raised when a HTTPU request message is received by a socket (unicast or multicast).
/// </summary> /// </summary>
@ -23,10 +20,6 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
event EventHandler<ResponseReceivedEventArgs> ResponseReceived; event EventHandler<ResponseReceivedEventArgs> ResponseReceived;
#endregion
#region Methods
/// <summary> /// <summary>
/// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications. /// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications.
/// </summary> /// </summary>
@ -48,10 +41,6 @@ namespace Rssdp.Infrastructure
Task SendMulticastMessage(string message, IPAddress fromLocalIpAddress, CancellationToken cancellationToken); Task SendMulticastMessage(string message, IPAddress fromLocalIpAddress, CancellationToken cancellationToken);
Task SendMulticastMessage(string message, int sendCount, IPAddress fromLocalIpAddress, CancellationToken cancellationToken); Task SendMulticastMessage(string message, int sendCount, IPAddress fromLocalIpAddress, CancellationToken cancellationToken);
#endregion
#region Properties
/// <summary> /// <summary>
/// Gets or sets a boolean value indicating whether or not this instance is shared amongst multiple <see cref="SsdpDeviceLocatorBase"/> and/or <see cref="ISsdpDevicePublisher"/> instances. /// Gets or sets a boolean value indicating whether or not this instance is shared amongst multiple <see cref="SsdpDeviceLocatorBase"/> and/or <see cref="ISsdpDevicePublisher"/> instances.
/// </summary> /// </summary>
@ -59,7 +48,5 @@ namespace Rssdp.Infrastructure
/// <para>If true, disposing an instance of a <see cref="SsdpDeviceLocatorBase"/>or a <see cref="ISsdpDevicePublisher"/> will not dispose this comms server instance. The calling code is responsible for managing the lifetime of the server.</para> /// <para>If true, disposing an instance of a <see cref="SsdpDeviceLocatorBase"/>or a <see cref="ISsdpDevicePublisher"/> will not dispose this comms server instance. The calling code is responsible for managing the lifetime of the server.</para>
/// </remarks> /// </remarks>
bool IsShared { get; set; } bool IsShared { get; set; }
#endregion
} }
} }

@ -13,9 +13,6 @@ namespace Rssdp.Infrastructure
/// <seealso cref="ISsdpDevicePublisher"/> /// <seealso cref="ISsdpDevicePublisher"/>
public interface ISsdpDeviceLocator public interface ISsdpDeviceLocator
{ {
#region Events
/// <summary> /// <summary>
/// Event raised when a device becomes available or is found by a search request. /// Event raised when a device becomes available or is found by a search request.
/// </summary> /// </summary>
@ -34,10 +31,6 @@ namespace Rssdp.Infrastructure
/// <seealso cref="StopListeningForNotifications"/> /// <seealso cref="StopListeningForNotifications"/>
event EventHandler<DeviceUnavailableEventArgs> DeviceUnavailable; event EventHandler<DeviceUnavailableEventArgs> DeviceUnavailable;
#endregion
#region Properties
/// <summary> /// <summary>
/// Sets or returns a string containing the filter for notifications. Notifications not matching the filter will not raise the <see cref="DeviceAvailable"/> or <see cref="DeviceUnavailable"/> events. /// Sets or returns a string containing the filter for notifications. Notifications not matching the filter will not raise the <see cref="DeviceAvailable"/> or <see cref="DeviceUnavailable"/> events.
/// </summary> /// </summary>
@ -58,12 +51,6 @@ namespace Rssdp.Infrastructure
set; set;
} }
#endregion
#region Methods
#region SearchAsync Overloads
/// <summary> /// <summary>
/// Aynchronously performs a search for all devices using the default search timeout, and returns an awaitable task that can be used to retrieve the results. /// Aynchronously performs a search for all devices using the default search timeout, and returns an awaitable task that can be used to retrieve the results.
/// </summary> /// </summary>
@ -108,8 +95,6 @@ namespace Rssdp.Infrastructure
/// <returns>A task whose result is an <see cref="System.Collections.Generic.IEnumerable{T}"/> of <see cref="DiscoveredSsdpDevice" /> instances, representing all found devices.</returns> /// <returns>A task whose result is an <see cref="System.Collections.Generic.IEnumerable{T}"/> of <see cref="DiscoveredSsdpDevice" /> instances, representing all found devices.</returns>
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<DiscoveredSsdpDevice>> SearchAsync(TimeSpan searchWaitTime); System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<DiscoveredSsdpDevice>> SearchAsync(TimeSpan searchWaitTime);
#endregion
/// <summary> /// <summary>
/// Starts listening for broadcast notifications of service availability. /// Starts listening for broadcast notifications of service availability.
/// </summary> /// </summary>
@ -134,8 +119,5 @@ namespace Rssdp.Infrastructure
/// <seealso cref="DeviceUnavailable"/> /// <seealso cref="DeviceUnavailable"/>
/// <seealso cref="NotificationFilter"/> /// <seealso cref="NotificationFilter"/>
void StopListeningForNotifications(); void StopListeningForNotifications();
#endregion
} }
} }

@ -9,17 +9,12 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public sealed class RequestReceivedEventArgs : EventArgs public sealed class RequestReceivedEventArgs : EventArgs
{ {
#region Fields
private readonly HttpRequestMessage _Message; private readonly HttpRequestMessage _Message;
private readonly IPEndPoint _ReceivedFrom;
#endregion private readonly IPEndPoint _ReceivedFrom;
public IPAddress LocalIpAddress { get; private set; } public IPAddress LocalIpAddress { get; private set; }
#region Constructors
/// <summary> /// <summary>
/// Full constructor. /// Full constructor.
/// </summary> /// </summary>
@ -30,10 +25,6 @@ namespace Rssdp.Infrastructure
LocalIpAddress = localIpAddress; LocalIpAddress = localIpAddress;
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// The <see cref="HttpRequestMessage"/> that was received. /// The <see cref="HttpRequestMessage"/> that was received.
/// </summary> /// </summary>
@ -49,7 +40,5 @@ namespace Rssdp.Infrastructure
{ {
get { return _ReceivedFrom; } get { return _ReceivedFrom; }
} }
#endregion
} }
} }

@ -9,17 +9,11 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public sealed class ResponseReceivedEventArgs : EventArgs public sealed class ResponseReceivedEventArgs : EventArgs
{ {
public IPAddress LocalIpAddress { get; set; } public IPAddress LocalIpAddress { get; set; }
#region Fields
private readonly HttpResponseMessage _Message; private readonly HttpResponseMessage _Message;
private readonly IPEndPoint _ReceivedFrom;
#endregion
#region Constructors private readonly IPEndPoint _ReceivedFrom;
/// <summary> /// <summary>
/// Full constructor. /// Full constructor.
@ -30,10 +24,6 @@ namespace Rssdp.Infrastructure
_ReceivedFrom = receivedFrom; _ReceivedFrom = receivedFrom;
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// The <see cref="HttpResponseMessage"/> that was received. /// The <see cref="HttpResponseMessage"/> that was received.
/// </summary> /// </summary>
@ -49,7 +39,5 @@ namespace Rssdp.Infrastructure
{ {
get { return _ReceivedFrom; } get { return _ReceivedFrom; }
} }
#endregion
} }
} }

@ -19,9 +19,6 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public sealed class SsdpCommunicationsServer : DisposableManagedObjectBase, ISsdpCommunicationsServer public sealed class SsdpCommunicationsServer : DisposableManagedObjectBase, ISsdpCommunicationsServer
{ {
#region Fields
/* We could technically use one socket listening on port 1900 for everything. /* We could technically use one socket listening on port 1900 for everything.
* This should get both multicast (notifications) and unicast (search response) messages, however * This should get both multicast (notifications) and unicast (search response) messages, however
* this often doesn't work under Windows because the MS SSDP service is running. If that service * this often doesn't work under Windows because the MS SSDP service is running. If that service
@ -55,10 +52,6 @@ namespace Rssdp.Infrastructure
private bool _IsShared; private bool _IsShared;
private readonly bool _enableMultiSocketBinding; private readonly bool _enableMultiSocketBinding;
#endregion
#region Events
/// <summary> /// <summary>
/// Raised when a HTTPU request message is received by a socket (unicast or multicast). /// Raised when a HTTPU request message is received by a socket (unicast or multicast).
/// </summary> /// </summary>
@ -69,10 +62,6 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public event EventHandler<ResponseReceivedEventArgs> ResponseReceived; public event EventHandler<ResponseReceivedEventArgs> ResponseReceived;
#endregion
#region Constructors
/// <summary> /// <summary>
/// Minimum constructor. /// Minimum constructor.
/// </summary> /// </summary>
@ -109,10 +98,6 @@ namespace Rssdp.Infrastructure
_enableMultiSocketBinding = enableMultiSocketBinding; _enableMultiSocketBinding = enableMultiSocketBinding;
} }
#endregion
#region Public Methods
/// <summary> /// <summary>
/// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications. /// Causes the server to begin listening for multicast messages, being SSDP search requests and notifications.
/// </summary> /// </summary>
@ -298,10 +283,6 @@ namespace Rssdp.Infrastructure
} }
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Gets or sets a boolean value indicating whether or not this instance is shared amongst multiple <see cref="SsdpDeviceLocatorBase"/> and/or <see cref="ISsdpDevicePublisher"/> instances. /// Gets or sets a boolean value indicating whether or not this instance is shared amongst multiple <see cref="SsdpDeviceLocatorBase"/> and/or <see cref="ISsdpDevicePublisher"/> instances.
/// </summary> /// </summary>
@ -315,10 +296,6 @@ namespace Rssdp.Infrastructure
set { _IsShared = value; } set { _IsShared = value; }
} }
#endregion
#region Overrides
/// <summary> /// <summary>
/// Stops listening for requests, disposes this instance and all internal resources. /// Stops listening for requests, disposes this instance and all internal resources.
/// </summary> /// </summary>
@ -333,10 +310,6 @@ namespace Rssdp.Infrastructure
} }
} }
#endregion
#region Private Methods
private Task SendMessageIfSocketNotDisposed(byte[] messageData, IPEndPoint destination, IPAddress fromLocalIpAddress, CancellationToken cancellationToken) private Task SendMessageIfSocketNotDisposed(byte[] messageData, IPEndPoint destination, IPAddress fromLocalIpAddress, CancellationToken cancellationToken)
{ {
var sockets = _sendSockets; var sockets = _sendSockets;
@ -506,8 +479,5 @@ namespace Rssdp.Infrastructure
LocalIpAddress = localIpAddress LocalIpAddress = localIpAddress
}); });
} }
#endregion
} }
} }

@ -15,9 +15,6 @@ namespace Rssdp
/// <seealso cref="SsdpEmbeddedDevice"/> /// <seealso cref="SsdpEmbeddedDevice"/>
public abstract class SsdpDevice public abstract class SsdpDevice
{ {
#region Fields
private string _Udn; private string _Udn;
private string _DeviceType; private string _DeviceType;
private string _DeviceTypeNamespace; private string _DeviceTypeNamespace;
@ -25,10 +22,6 @@ namespace Rssdp
private IList<SsdpDevice> _Devices; private IList<SsdpDevice> _Devices;
#endregion
#region Events
/// <summary> /// <summary>
/// Raised when a new child device is added. /// Raised when a new child device is added.
/// </summary> /// </summary>
@ -43,10 +36,6 @@ namespace Rssdp
/// <seealso cref="DeviceRemoved"/> /// <seealso cref="DeviceRemoved"/>
public event EventHandler<DeviceEventArgs> DeviceRemoved; public event EventHandler<DeviceEventArgs> DeviceRemoved;
#endregion
#region Constructors
/// <summary> /// <summary>
/// Derived type constructor, allows constructing a device with no parent. Should only be used from derived types that are or inherit from <see cref="SsdpRootDevice"/>. /// Derived type constructor, allows constructing a device with no parent. Should only be used from derived types that are or inherit from <see cref="SsdpRootDevice"/>.
/// </summary> /// </summary>
@ -60,8 +49,6 @@ namespace Rssdp
this.Devices = new ReadOnlyCollection<SsdpDevice>(_Devices); this.Devices = new ReadOnlyCollection<SsdpDevice>(_Devices);
} }
#endregion
public SsdpRootDevice ToRootDevice() public SsdpRootDevice ToRootDevice()
{ {
var device = this; var device = this;
@ -73,10 +60,6 @@ namespace Rssdp
return rootDevice; return rootDevice;
} }
#region Public Properties
#region UPnP Device Description Properties
/// <summary> /// <summary>
/// Sets or returns the core device type (not including namespace, version etc.). Required. /// Sets or returns the core device type (not including namespace, version etc.). Required.
/// </summary> /// </summary>
@ -252,8 +235,6 @@ namespace Rssdp
/// </remarks> /// </remarks>
public Uri PresentationUrl { get; set; } public Uri PresentationUrl { get; set; }
#endregion
/// <summary> /// <summary>
/// Returns a read-only enumerable set of <see cref="SsdpDevice"/> objects representing children of this device. Child devices are optional. /// Returns a read-only enumerable set of <see cref="SsdpDevice"/> objects representing children of this device. Child devices are optional.
/// </summary> /// </summary>
@ -265,10 +246,6 @@ namespace Rssdp
private set; private set;
} }
#endregion
#region Public Methods
/// <summary> /// <summary>
/// Adds a child device to the <see cref="Devices"/> collection. /// Adds a child device to the <see cref="Devices"/> collection.
/// </summary> /// </summary>
@ -351,7 +328,5 @@ namespace Rssdp
if (handlers != null) if (handlers != null)
handlers(this, new DeviceEventArgs(device)); handlers(this, new DeviceEventArgs(device));
} }
#endregion
} }
} }

@ -13,9 +13,6 @@ namespace Rssdp.Infrastructure
/// </summary> /// </summary>
public class SsdpDeviceLocator : DisposableManagedObjectBase public class SsdpDeviceLocator : DisposableManagedObjectBase
{ {
#region Fields & Constants
private List<DiscoveredSsdpDevice> _Devices; private List<DiscoveredSsdpDevice> _Devices;
private ISsdpCommunicationsServer _CommunicationsServer; private ISsdpCommunicationsServer _CommunicationsServer;
@ -25,10 +22,6 @@ namespace Rssdp.Infrastructure
private readonly TimeSpan DefaultSearchWaitTime = TimeSpan.FromSeconds(4); private readonly TimeSpan DefaultSearchWaitTime = TimeSpan.FromSeconds(4);
private readonly TimeSpan OneSecond = TimeSpan.FromSeconds(1); private readonly TimeSpan OneSecond = TimeSpan.FromSeconds(1);
#endregion
#region Constructors
/// <summary> /// <summary>
/// Default constructor. /// Default constructor.
/// </summary> /// </summary>
@ -42,10 +35,6 @@ namespace Rssdp.Infrastructure
_Devices = new List<DiscoveredSsdpDevice>(); _Devices = new List<DiscoveredSsdpDevice>();
} }
#endregion
#region Events
/// <summary> /// <summary>
/// Raised for when /// Raised for when
/// <list type="bullet"> /// <list type="bullet">
@ -76,12 +65,6 @@ namespace Rssdp.Infrastructure
/// <seealso cref="StopListeningForNotifications"/> /// <seealso cref="StopListeningForNotifications"/>
public event EventHandler<DeviceUnavailableEventArgs> DeviceUnavailable; public event EventHandler<DeviceUnavailableEventArgs> DeviceUnavailable;
#endregion
#region Public Methods
#region Search Overloads
public void RestartBroadcastTimer(TimeSpan dueTime, TimeSpan period) public void RestartBroadcastTimer(TimeSpan dueTime, TimeSpan period)
{ {
lock (_timerLock) lock (_timerLock)
@ -167,8 +150,6 @@ namespace Rssdp.Infrastructure
return BroadcastDiscoverMessage(searchTarget, SearchTimeToMXValue(searchWaitTime), cancellationToken); return BroadcastDiscoverMessage(searchTarget, SearchTimeToMXValue(searchWaitTime), cancellationToken);
} }
#endregion
/// <summary> /// <summary>
/// Starts listening for broadcast notifications of service availability. /// Starts listening for broadcast notifications of service availability.
/// </summary> /// </summary>
@ -236,10 +217,6 @@ namespace Rssdp.Infrastructure
handlers(this, new DeviceUnavailableEventArgs(device, expired)); handlers(this, new DeviceUnavailableEventArgs(device, expired));
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Sets or returns a string containing the filter for notifications. Notifications not matching the filter will not raise the <see cref="ISsdpDeviceLocator.DeviceAvailable"/> or <see cref="ISsdpDeviceLocator.DeviceUnavailable"/> events. /// Sets or returns a string containing the filter for notifications. Notifications not matching the filter will not raise the <see cref="ISsdpDeviceLocator.DeviceAvailable"/> or <see cref="ISsdpDeviceLocator.DeviceUnavailable"/> events.
/// </summary> /// </summary>
@ -261,10 +238,6 @@ namespace Rssdp.Infrastructure
set; set;
} }
#endregion
#region Overrides
/// <summary> /// <summary>
/// Disposes this object and all internal resources. Stops listening for all network messages. /// Disposes this object and all internal resources. Stops listening for all network messages.
/// </summary> /// </summary>
@ -285,12 +258,6 @@ namespace Rssdp.Infrastructure
} }
} }
#endregion
#region Private Methods
#region Discovery/Device Add
private void AddOrUpdateDiscoveredDevice(DiscoveredSsdpDevice device, IPAddress localIpAddress) private void AddOrUpdateDiscoveredDevice(DiscoveredSsdpDevice device, IPAddress localIpAddress)
{ {
bool isNewDevice = false; bool isNewDevice = false;
@ -326,10 +293,6 @@ namespace Rssdp.Infrastructure
|| device.NotificationType == this.NotificationFilter; || device.NotificationType == this.NotificationFilter;
} }
#endregion
#region Network Message Processing
private Task BroadcastDiscoverMessage(string serviceType, TimeSpan mxValue, CancellationToken cancellationToken) private Task BroadcastDiscoverMessage(string serviceType, TimeSpan mxValue, CancellationToken cancellationToken)
{ {
var values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); var values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@ -429,8 +392,6 @@ namespace Rssdp.Infrastructure
} }
} }
#region Header/Message Processing Utilities
private string GetFirstHeaderStringValue(string headerName, HttpResponseMessage message) private string GetFirstHeaderStringValue(string headerName, HttpResponseMessage message)
{ {
string retVal = null; string retVal = null;
@ -498,12 +459,6 @@ namespace Rssdp.Infrastructure
return (TimeSpan)(headerValue.MaxAge ?? headerValue.SharedMaxAge ?? TimeSpan.Zero); return (TimeSpan)(headerValue.MaxAge ?? headerValue.SharedMaxAge ?? TimeSpan.Zero);
} }
#endregion
#endregion
#region Expiry and Device Removal
private void RemoveExpiredDevicesFromCache() private void RemoveExpiredDevicesFromCache()
{ {
if (this.IsDisposed) return; if (this.IsDisposed) return;
@ -560,8 +515,6 @@ namespace Rssdp.Infrastructure
return false; return false;
} }
#endregion
private TimeSpan SearchTimeToMXValue(TimeSpan searchWaitTime) private TimeSpan SearchTimeToMXValue(TimeSpan searchWaitTime)
{ {
if (searchWaitTime.TotalSeconds < 2 || searchWaitTime == TimeSpan.Zero) if (searchWaitTime.TotalSeconds < 2 || searchWaitTime == TimeSpan.Zero)
@ -598,10 +551,6 @@ namespace Rssdp.Infrastructure
return list; return list;
} }
#endregion
#region Event Handlers
private void CommsServer_ResponseReceived(object sender, ResponseReceivedEventArgs e) private void CommsServer_ResponseReceived(object sender, ResponseReceivedEventArgs e)
{ {
ProcessSearchResponseMessage(e.Message, e.LocalIpAddress); ProcessSearchResponseMessage(e.Message, e.LocalIpAddress);
@ -611,7 +560,5 @@ namespace Rssdp.Infrastructure
{ {
ProcessNotificationMessage(e.Message, e.LocalIpAddress); ProcessNotificationMessage(e.Message, e.LocalIpAddress);
} }
#endregion
} }
} }

@ -5,14 +5,8 @@ namespace Rssdp
/// </summary> /// </summary>
public class SsdpEmbeddedDevice : SsdpDevice public class SsdpEmbeddedDevice : SsdpDevice
{ {
#region Fields
private SsdpRootDevice _RootDevice; private SsdpRootDevice _RootDevice;
#endregion
#region Constructors
/// <summary> /// <summary>
/// Default constructor. /// Default constructor.
/// </summary> /// </summary>
@ -20,10 +14,6 @@ namespace Rssdp
{ {
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Returns the <see cref="SsdpRootDevice"/> that is this device's first ancestor. If this device is itself an <see cref="SsdpRootDevice"/>, then returns a reference to itself. /// Returns the <see cref="SsdpRootDevice"/> that is this device's first ancestor. If this device is itself an <see cref="SsdpRootDevice"/>, then returns a reference to itself.
/// </summary> /// </summary>
@ -46,7 +36,5 @@ namespace Rssdp
} }
} }
} }
#endregion
} }
} }

@ -12,14 +12,8 @@ namespace Rssdp
/// </remarks> /// </remarks>
public class SsdpRootDevice : SsdpDevice public class SsdpRootDevice : SsdpDevice
{ {
#region Fields
private Uri _UrlBase; private Uri _UrlBase;
#endregion
#region Constructors
/// <summary> /// <summary>
/// Default constructor. /// Default constructor.
/// </summary> /// </summary>
@ -27,10 +21,6 @@ namespace Rssdp
{ {
} }
#endregion
#region Public Properties
/// <summary> /// <summary>
/// Specifies how long clients can cache this device's details for. Optional but defaults to <see cref="TimeSpan.Zero"/> which means no-caching. Recommended value is half an hour. /// Specifies how long clients can cache this device's details for. Optional but defaults to <see cref="TimeSpan.Zero"/> which means no-caching. Recommended value is half an hour.
/// </summary> /// </summary>
@ -77,7 +67,5 @@ namespace Rssdp
_UrlBase = value; _UrlBase = value;
} }
} }
#endregion
} }
} }

Loading…
Cancel
Save