diff --git a/ICD.Common.Utils/AttributeUtils.cs b/ICD.Common.Utils/AttributeUtils.cs index 1201088..15f1f05 100644 --- a/ICD.Common.Utils/AttributeUtils.cs +++ b/ICD.Common.Utils/AttributeUtils.cs @@ -83,7 +83,7 @@ namespace ICD.Common.Utils e.Message); } - foreach (var type in types) + foreach (CType type in types) CacheType(type); } diff --git a/ICD.Common.Utils/EnumUtils.cs b/ICD.Common.Utils/EnumUtils.cs index aefcfb4..e928728 100644 --- a/ICD.Common.Utils/EnumUtils.cs +++ b/ICD.Common.Utils/EnumUtils.cs @@ -31,7 +31,7 @@ namespace ICD.Common.Utils #if !SIMPLSHARP .GetTypeInfo() #endif - .IsEnum; + .IsEnum; } /// @@ -225,14 +225,14 @@ namespace ICD.Common.Utils .IsDefined(typeof(FlagsAttribute), false); } - /// - /// Gets the overlapping values of the given enum flags. - /// - /// + /// + /// Gets the overlapping values of the given enum flags. + /// + /// /// - /// + /// public static T GetFlagsIntersection(params T[] values) - { + { if (values.Length == 0) return GetNoneValue(); @@ -240,8 +240,8 @@ namespace ICD.Common.Utils foreach (T item in values.Skip(1)) output &= (int)(object)item; - return (T)Enum.ToObject(typeof(T), output); - } + return (T)Enum.ToObject(typeof(T), output); + } /// /// Gets all of the set flags on the given enum. @@ -374,27 +374,27 @@ namespace ICD.Common.Utils /// /// [PublicAPI] - public static bool HasAnyFlags(T value) - { - return GetFlagsExceptNone(value).Any(); - } + public static bool HasAnyFlags(T value) + { + return GetFlagsExceptNone(value).Any(); + } - /// - /// Returns true if the enum contains any of the given flag values. - /// - /// - /// - /// - [PublicAPI] - public static bool HasAnyFlags(T value, T other) - { - T intersection = GetFlagsIntersection(value, other); - return HasAnyFlags(intersection); - } + /// + /// Returns true if the enum contains any of the given flag values. + /// + /// + /// + /// + [PublicAPI] + public static bool HasAnyFlags(T value, T other) + { + T intersection = GetFlagsIntersection(value, other); + return HasAnyFlags(intersection); + } - #endregion + #endregion - #region Conversion + #region Conversion /// /// Shorthand for parsing string to enum. @@ -442,71 +442,71 @@ namespace ICD.Common.Utils } } - /// - /// Shorthand for parsing string to enum. - /// Will fail if the resulting value is not defined as part of the enum. - /// - /// - /// - /// - /// - public static T ParseStrict(string data, bool ignoreCase) - { - if (!IsEnumType()) - throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name)); + /// + /// Shorthand for parsing string to enum. + /// Will fail if the resulting value is not defined as part of the enum. + /// + /// + /// + /// + /// + public static T ParseStrict(string data, bool ignoreCase) + { + if (!IsEnumType()) + throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name)); - T output; + T output; - try - { - output = Parse(data, ignoreCase); - } - catch (Exception e) - { - throw new FormatException( - string.Format("Failed to parse {0} as {1}", StringUtils.ToRepresentation(data), typeof(T).Name), e); - } + try + { + output = Parse(data, ignoreCase); + } + catch (Exception e) + { + throw new FormatException( + string.Format("Failed to parse {0} as {1}", StringUtils.ToRepresentation(data), typeof(T).Name), e); + } - if (!IsDefined(output)) - throw new ArgumentOutOfRangeException(string.Format("{0} is not a valid {1}", output, typeof(T).Name)); + if (!IsDefined(output)) + throw new ArgumentOutOfRangeException(string.Format("{0} is not a valid {1}", output, typeof(T).Name)); - return output; - } + return output; + } - /// - /// Shorthand for parsing a string to enum. Returns false if the parse failed. - /// Will fail if the resulting value is not defined as part of the enum. - /// - /// - /// - /// - /// - /// - public static bool TryParseStrict(string data, bool ignoreCase, out T result) - { - if (!IsEnumType()) - throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name)); + /// + /// Shorthand for parsing a string to enum. Returns false if the parse failed. + /// Will fail if the resulting value is not defined as part of the enum. + /// + /// + /// + /// + /// + /// + public static bool TryParseStrict(string data, bool ignoreCase, out T result) + { + if (!IsEnumType()) + throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name)); - result = default(T); + result = default(T); - try - { - result = ParseStrict(data, ignoreCase); - return true; - } - catch (Exception) - { - return false; - } - } + try + { + result = ParseStrict(data, ignoreCase); + return true; + } + catch (Exception) + { + return false; + } + } - /// - /// Converts the given enum value to an Enum. - /// - /// - /// - /// - public static Enum ToEnum(T value) + /// + /// Converts the given enum value to an Enum. + /// + /// + /// + /// + public static Enum ToEnum(T value) { if (!IsEnum(value)) // ReSharper disable once CompareNonConstrainedGenericWithNull diff --git a/ICD.Common.Utils/Extensions/ByteExtensions.cs b/ICD.Common.Utils/Extensions/ByteExtensions.cs index 6a31ef9..46a04fc 100644 --- a/ICD.Common.Utils/Extensions/ByteExtensions.cs +++ b/ICD.Common.Utils/Extensions/ByteExtensions.cs @@ -35,4 +35,4 @@ namespace ICD.Common.Utils.Extensions return (byte)(b & ~(1 << n)); } } -} \ No newline at end of file +} diff --git a/ICD.Common.Utils/Extensions/DateTimeExtensions.cs b/ICD.Common.Utils/Extensions/DateTimeExtensions.cs index 1805810..85c1ac0 100644 --- a/ICD.Common.Utils/Extensions/DateTimeExtensions.cs +++ b/ICD.Common.Utils/Extensions/DateTimeExtensions.cs @@ -8,15 +8,15 @@ namespace ICD.Common.Utils.Extensions /// public static class DateTimeExtensions { - /// - /// Replacement for missing DateTime.ToShortTimeString() absent from NetStandard. - /// - /// - /// - public static string ToShortTimeString(this DateTime extends) - { - return extends.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern); - } + /// + /// Replacement for missing DateTime.ToShortTimeString() absent from NetStandard. + /// + /// + /// + public static string ToShortTimeString(this DateTime extends) + { + return extends.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern); + } /// /// Gets a string representation of the DateTime with millisecond precision. diff --git a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs index f131204..6a54fe3 100644 --- a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs +++ b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs @@ -314,8 +314,8 @@ namespace ICD.Common.Utils.Extensions /// [PublicAPI] public static bool DictionaryEqual(this IDictionary extends, - IDictionary other, - Func valueComparer) + IDictionary other, + Func valueComparer) { if (extends == null) throw new ArgumentNullException("extends"); diff --git a/ICD.Common.Utils/Extensions/StringExtensions.cs b/ICD.Common.Utils/Extensions/StringExtensions.cs index 4e0e172..782d0ad 100644 --- a/ICD.Common.Utils/Extensions/StringExtensions.cs +++ b/ICD.Common.Utils/Extensions/StringExtensions.cs @@ -126,7 +126,7 @@ namespace ICD.Common.Utils.Extensions throw new InvalidOperationException("chunkSize must be greater than 0"); return Enumerable.Range(0, (int)Math.Ceiling(extends.Length / (double)chunkSize)) - .Select(i => extends.Substring(i * chunkSize, Math.Min(chunkSize, extends.Length - (i * chunkSize)))); + .Select(i => extends.Substring(i * chunkSize, Math.Min(chunkSize, extends.Length - (i * chunkSize)))); } /// @@ -209,8 +209,6 @@ namespace ICD.Common.Utils.Extensions .SelectMany(s => s.Split(delimitersArray.Skip(1))); } - - /// /// Removes whitespace from the string. /// diff --git a/ICD.Common.Utils/Extensions/TypeExtensions.cs b/ICD.Common.Utils/Extensions/TypeExtensions.cs index 98e7b0d..08affe0 100644 --- a/ICD.Common.Utils/Extensions/TypeExtensions.cs +++ b/ICD.Common.Utils/Extensions/TypeExtensions.cs @@ -6,59 +6,59 @@ using System.Collections.Generic; namespace ICD.Common.Utils.Extensions { - public static class TypeExtensions - { - public static bool IsAssignableTo(this Type from, Type to) - { - if (from == null) - throw new ArgumentNullException("from"); + public static class TypeExtensions + { + public static bool IsAssignableTo(this Type from, Type to) + { + if (from == null) + throw new ArgumentNullException("from"); - if (to == null) - throw new ArgumentNullException("to"); + if (to == null) + throw new ArgumentNullException("to"); - return to.IsAssignableFrom(from); - } + return to.IsAssignableFrom(from); + } - /// - /// Returns the given type, all base types, and all implemented interfaces. - /// - /// - /// - public static IEnumerable GetAllTypes(this Type extends) - { - if (extends == null) - throw new ArgumentNullException("extends"); + /// + /// Returns the given type, all base types, and all implemented interfaces. + /// + /// + /// + public static IEnumerable GetAllTypes(this Type extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); - yield return extends; + yield return extends; - foreach (Type type in extends.GetBaseTypes()) - yield return type; + foreach (Type type in extends.GetBaseTypes()) + yield return type; - foreach (Type type in extends.GetInterfaces()) - yield return type; - } + foreach (Type type in extends.GetInterfaces()) + yield return type; + } - /// - /// Returns all base types for the given type. - /// - /// - /// - public static IEnumerable GetBaseTypes(this Type extends) - { - if (extends == null) - throw new ArgumentNullException("extends"); + /// + /// Returns all base types for the given type. + /// + /// + /// + public static IEnumerable GetBaseTypes(this Type extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); - do - { - extends = extends + do + { + extends = extends #if !SIMPLSHARP .GetTypeInfo() #endif - .BaseType; + .BaseType; - if (extends != null) - yield return extends; - } while (extends != null); - } - } -} \ No newline at end of file + if (extends != null) + yield return extends; + } while (extends != null); + } + } +} diff --git a/ICD.Common.Utils/IO/IcdTextWriter.cs b/ICD.Common.Utils/IO/IcdTextWriter.cs index 8a70a18..18aa606 100644 --- a/ICD.Common.Utils/IO/IcdTextWriter.cs +++ b/ICD.Common.Utils/IO/IcdTextWriter.cs @@ -2,6 +2,7 @@ #if SIMPLSHARP using Crestron.SimplSharp.CrestronIO; using GC = Crestron.SimplSharp.CrestronEnvironment.GC; + #else using System.IO; using GC = System.GC; @@ -46,9 +47,7 @@ namespace ICD.Common.Utils.IO return; if (disposing) - { m_TextWriter.Dispose(); - } m_Disposed = true; } } diff --git a/ICD.Common.Utils/IcdConsole.cs b/ICD.Common.Utils/IcdConsole.cs index 5505eb6..43213c5 100644 --- a/ICD.Common.Utils/IcdConsole.cs +++ b/ICD.Common.Utils/IcdConsole.cs @@ -35,7 +35,7 @@ namespace ICD.Common.Utils [PublicAPI] public static void ConsoleCommandResponse(string message, params object[] args) { - if(args != null && args.Any()) + if (args != null && args.Any()) message = string.Format(message, args); #if SIMPLSHARP @@ -113,4 +113,4 @@ namespace ICD.Common.Utils return true; } } -} \ No newline at end of file +} diff --git a/ICD.Common.Utils/ProgramUtils.SimplSharp.cs b/ICD.Common.Utils/ProgramUtils.SimplSharp.cs index 48bf278..c86198d 100644 --- a/ICD.Common.Utils/ProgramUtils.SimplSharp.cs +++ b/ICD.Common.Utils/ProgramUtils.SimplSharp.cs @@ -10,8 +10,8 @@ using System.Linq; namespace ICD.Common.Utils { - public static partial class ProgramUtils - { + public static partial class ProgramUtils + { private const string APPLICATION_NAME_KEY = "Application Name"; private const string APPLICATION_NAME_SIMPL_KEY = "System Name"; private const string PROGRAM_FILE_KEY = "Program File"; @@ -34,13 +34,7 @@ namespace ICD.Common.Utils /// Gets the program number. /// [PublicAPI] - public static uint ProgramNumber - { - get - { - return InitialParametersClass.ApplicationNumber; - } - } + public static uint ProgramNumber { get { return InitialParametersClass.ApplicationNumber; } } /// /// Gets the compile date of the program. @@ -108,7 +102,7 @@ namespace ICD.Common.Utils return output; } - foreach (string line in progInfo.Split(new[] { "\n\r", "\r\n", "\n", "\r" })) + foreach (string line in progInfo.Split(new[] {"\n\r", "\r\n", "\n", "\r"})) { if (string.IsNullOrEmpty(line)) continue; @@ -118,7 +112,7 @@ namespace ICD.Common.Utils if (pair.Length < 2) { ServiceProvider.GetService() - .AddEntry(eSeverity.Warning, "Failed to parse prog comments line - {0}", line); + .AddEntry(eSeverity.Warning, "Failed to parse prog comments line - {0}", line); continue; } diff --git a/ICD.Common.Utils/ReprBuilder.cs b/ICD.Common.Utils/ReprBuilder.cs index c03e83f..6204d52 100644 --- a/ICD.Common.Utils/ReprBuilder.cs +++ b/ICD.Common.Utils/ReprBuilder.cs @@ -10,8 +10,8 @@ namespace ICD.Common.Utils { private readonly object m_Instance; - private readonly List m_PropertyOrder; - private readonly Dictionary m_PropertyValues; + private readonly List m_PropertyOrder; + private readonly Dictionary m_PropertyValues; /// /// Constructor. diff --git a/ICD.Common.Utils/ThreadingUtils.cs b/ICD.Common.Utils/ThreadingUtils.cs index f19848c..2ef5ccf 100644 --- a/ICD.Common.Utils/ThreadingUtils.cs +++ b/ICD.Common.Utils/ThreadingUtils.cs @@ -12,11 +12,11 @@ namespace ICD.Common.Utils { public static class ThreadingUtils { - /// - /// Executes the callback as a short-lived, threaded task. - /// - /// - [PublicAPI] + /// + /// Executes the callback as a short-lived, threaded task. + /// + /// + [PublicAPI] public static object SafeInvoke(Action callback) { return SafeInvoke(unused => callback(), null); @@ -36,7 +36,7 @@ namespace ICD.Common.Utils #else return Task.Run(GetHandledCallback(callback, param)); #endif - } + } /// /// Wraps the given callback in a try/catch to avoid crashing crestron programs. @@ -46,19 +46,19 @@ namespace ICD.Common.Utils /// /// private static Action GetHandledCallback(Action callback, T param) - { - return () => - { - try - { - callback(param); - } - catch (Exception e) - { - ServiceProvider.TryGetService() - .AddEntry(eSeverity.Error, e, e.Message); - } - }; - } + { + return () => + { + try + { + callback(param); + } + catch (Exception e) + { + ServiceProvider.TryGetService() + .AddEntry(eSeverity.Error, e, e.Message); + } + }; + } } } diff --git a/ICD.Common.Utils/Xml/XmlReaderExtensions.cs b/ICD.Common.Utils/Xml/XmlReaderExtensions.cs index f2b09b8..3ca946b 100644 --- a/ICD.Common.Utils/Xml/XmlReaderExtensions.cs +++ b/ICD.Common.Utils/Xml/XmlReaderExtensions.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using ICD.Common.Utils.EventArguments; using ICD.Common.Properties; +using ICD.Common.Utils.EventArguments; #if SIMPLSHARP using Crestron.SimplSharp.CrestronXml; #else diff --git a/ICD.Common.Utils/Xml/XmlUtils.cs b/ICD.Common.Utils/Xml/XmlUtils.cs index 5fb8b34..9615bf0 100644 --- a/ICD.Common.Utils/Xml/XmlUtils.cs +++ b/ICD.Common.Utils/Xml/XmlUtils.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using ICD.Common.Utils.EventArguments; using ICD.Common.Properties; +using ICD.Common.Utils.EventArguments; using ICD.Common.Utils.Extensions; using ICD.Common.Utils.IO;