From e4be5e7e7c1df2001a902de422b39ec7c9fbd97d Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 16 Jan 2018 13:05:35 -0500 Subject: [PATCH] Whitespace --- ICD.Common.Utils/PathUtils.cs | 315 +++++++++---------- ICD.Common.Utils/RecursionUtils.cs | 4 +- ICD.Common.Utils/Services/ServiceProvider.cs | 2 - ICD.Common.Utils/StringUtils.cs | 26 +- 4 files changed, 170 insertions(+), 177 deletions(-) diff --git a/ICD.Common.Utils/PathUtils.cs b/ICD.Common.Utils/PathUtils.cs index eaae550..7a691e1 100644 --- a/ICD.Common.Utils/PathUtils.cs +++ b/ICD.Common.Utils/PathUtils.cs @@ -6,188 +6,185 @@ using ICD.Common.Utils.IO; namespace ICD.Common.Utils { - /// - /// Provides util methods for working with file/directory paths. - /// - public static class PathUtils - { - #region Properties + /// + /// Provides util methods for working with file/directory paths. + /// + public static class PathUtils + { + #region Properties - /// - /// Gets the path to the root directory of the processor. - /// - [PublicAPI] - public static string RootPath { get { return IcdDirectory.GetDirectoryRoot("\\"); } } + /// + /// Gets the path to the root directory of the processor. + /// + [PublicAPI] + public static string RootPath { get { return IcdDirectory.GetDirectoryRoot("\\"); } } - /// - /// Gets the path to the program directory - /// - [PublicAPI] - public static string ProgramPath - { - get { return IcdDirectory.GetApplicationDirectory(); } - } + /// + /// Gets the path to the program directory + /// + [PublicAPI] + public static string ProgramPath { get { return IcdDirectory.GetApplicationDirectory(); } } - /// - /// Gets the path to the NVRAM directory. - /// - [PublicAPI] - public static string NvramPath { get { return Join(RootPath, "NVRAM"); } } + /// + /// Gets the path to the NVRAM directory. + /// + [PublicAPI] + public static string NvramPath { get { return Join(RootPath, "NVRAM"); } } - /// - /// Returns the absolute path to the configuration directory. - /// - /// - [PublicAPI] - public static string ProgramConfigPath - { - get - { - string directoryName = string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber); - return Join(NvramPath, directoryName); - } - } + /// + /// Returns the absolute path to the configuration directory. + /// + /// + [PublicAPI] + public static string ProgramConfigPath + { + get + { + string directoryName = string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber); + return Join(NvramPath, directoryName); + } + } - /// - /// Returns the absolute path to the common configuration directory. - /// - [PublicAPI] - public static string CommonConfigPath { get { return Join(NvramPath, "CommonConfig"); } } + /// + /// Returns the absolute path to the common configuration directory. + /// + [PublicAPI] + public static string CommonConfigPath { get { return Join(NvramPath, "CommonConfig"); } } - /// - /// Returns the absolute path to the common config library directory. - /// - [PublicAPI] - public static string CommonLibPath { get { return Join(CommonConfigPath, "Lib"); } } + /// + /// Returns the absolute path to the common config library directory. + /// + [PublicAPI] + public static string CommonLibPath { get { return Join(CommonConfigPath, "Lib"); } } - /// - /// Returns the absolute path to the program config library directory. - /// - [PublicAPI] - public static string ProgramLibPath { get { return Join(ProgramConfigPath, "Lib"); } } + /// + /// Returns the absolute path to the program config library directory. + /// + [PublicAPI] + public static string ProgramLibPath { get { return Join(ProgramConfigPath, "Lib"); } } - #endregion + #endregion - #region Methods + #region Methods - /// - /// Creates a path from the given path nodes. - /// - /// - /// - public static string Join(params string[] items) - { - return items.Length > 1 - ? items.Skip(1).Aggregate(items.First(), IcdPath.Combine) - : items.FirstOrDefault(string.Empty); - } + /// + /// Creates a path from the given path nodes. + /// + /// + /// + public static string Join(params string[] items) + { + return items.Length > 1 + ? items.Skip(1).Aggregate(items.First(), IcdPath.Combine) + : items.FirstOrDefault(string.Empty); + } - /// - /// Gets the full path for the given path. - /// - /// - /// - public static string GetFullPath(string path) - { - return Join(IcdDirectory.GetApplicationDirectory(), path); - } + /// + /// Gets the full path for the given path. + /// + /// + /// + public static string GetFullPath(string path) + { + return Join(IcdDirectory.GetApplicationDirectory(), path); + } - /// - /// Replaces the filename while leaving the directory and extension intact. - /// - /// - /// - /// - public static string ChangeFilenameWithoutExt(string path, string newName) - { - string dir = IcdPath.GetDirectoryName(path); - string ext = IcdPath.GetExtension(path); + /// + /// Replaces the filename while leaving the directory and extension intact. + /// + /// + /// + /// + public static string ChangeFilenameWithoutExt(string path, string newName) + { + string dir = IcdPath.GetDirectoryName(path); + string ext = IcdPath.GetExtension(path); - return Join(dir, newName + ext); - } + return Join(dir, newName + ext); + } - /// - /// Removes the extension from the given path. - /// - /// - /// - public static string GetPathWithoutExtension(string path) - { - string dir = IcdPath.GetDirectoryName(path); - string filename = IcdPath.GetFileNameWithoutExtension(path); + /// + /// Removes the extension from the given path. + /// + /// + /// + public static string GetPathWithoutExtension(string path) + { + string dir = IcdPath.GetDirectoryName(path); + string filename = IcdPath.GetFileNameWithoutExtension(path); - return Join(dir, filename); - } + return Join(dir, filename); + } - /// - /// Recurses over the file paths at the given directory. - /// - /// - /// - public static IEnumerable RecurseFilePaths(string path) - { - if (!IcdDirectory.Exists(path)) - return Enumerable.Empty(); + /// + /// Recurses over the file paths at the given directory. + /// + /// + /// + public static IEnumerable RecurseFilePaths(string path) + { + if (!IcdDirectory.Exists(path)) + return Enumerable.Empty(); - return RecursionUtils.BreadthFirstSearch(path, IcdDirectory.GetDirectories) - .SelectMany(p => IcdDirectory.GetFiles(p)); - } + return RecursionUtils.BreadthFirstSearch(path, IcdDirectory.GetDirectories) + .SelectMany(p => IcdDirectory.GetFiles(p)); + } - /// - /// Searches the program config path, common config path, and application path to - /// find the first config that exists with the given local path. - /// - /// - /// - [PublicAPI] - public static string GetDefaultConfigPath(params string[] localPath) - { - string local = Join(localPath); + /// + /// Searches the program config path, common config path, and application path to + /// find the first config that exists with the given local path. + /// + /// + /// + [PublicAPI] + public static string GetDefaultConfigPath(params string[] localPath) + { + string local = Join(localPath); - // Program slot configuration - string programPath = GetProgramConfigPath(localPath); - if (PathExists(programPath)) - return programPath; + // Program slot configuration + string programPath = GetProgramConfigPath(localPath); + if (PathExists(programPath)) + return programPath; - // Common program configuration - string commonPath = GetCommonConfigPath(local); - if (PathExists(commonPath)) - return commonPath; + // Common program configuration + string commonPath = GetCommonConfigPath(local); + if (PathExists(commonPath)) + return commonPath; - return Join(IcdDirectory.GetApplicationDirectory(), local); // Installation defaults - } + return Join(IcdDirectory.GetApplicationDirectory(), local); // Installation defaults + } - /// - /// Appends the local path to the common config path. - /// - /// - public static string GetCommonConfigPath(params string[] localPath) - { - string local = Join(localPath); - return Join(CommonConfigPath, local); - } + /// + /// Appends the local path to the common config path. + /// + /// + public static string GetCommonConfigPath(params string[] localPath) + { + string local = Join(localPath); + return Join(CommonConfigPath, local); + } - /// - /// Appends the local path to the program config path. - /// - /// - public static string GetProgramConfigPath(params string[] localPath) - { - string local = Join(localPath); - return Join(ProgramConfigPath, local); - } + /// + /// Appends the local path to the program config path. + /// + /// + public static string GetProgramConfigPath(params string[] localPath) + { + string local = Join(localPath); + return Join(ProgramConfigPath, local); + } - /// - /// Returns true if the given path exists. - /// - /// - /// - [PublicAPI] - public static bool PathExists(string path) - { - return IcdFile.Exists(path) || IcdDirectory.Exists(path); - } + /// + /// Returns true if the given path exists. + /// + /// + /// + [PublicAPI] + public static bool PathExists(string path) + { + return IcdFile.Exists(path) || IcdDirectory.Exists(path); + } - #endregion - } + #endregion + } } diff --git a/ICD.Common.Utils/RecursionUtils.cs b/ICD.Common.Utils/RecursionUtils.cs index 4139a15..7708a17 100644 --- a/ICD.Common.Utils/RecursionUtils.cs +++ b/ICD.Common.Utils/RecursionUtils.cs @@ -135,7 +135,7 @@ namespace ICD.Common.Utils // Edge case, root is the destination foreach (T destination in - destinationsToBeProcessed.Where(destination => comparer.Equals(root, destination))) + destinationsToBeProcessed.Where(destination => comparer.Equals(root, destination))) { destinationsProcessed.Add(destination); pathsToReturn.Add(destination, new[] {root}); @@ -163,7 +163,7 @@ namespace ICD.Common.Utils T closureNode = node; foreach (T destination in - destinationsToBeProcessed.Where(destination => comparer.Equals(closureNode, destination))) + destinationsToBeProcessed.Where(destination => comparer.Equals(closureNode, destination))) { destinationsProcessed.Add(destination); pathsToReturn.Add(destination, GetPath(destination, root, nodeParents, comparer).Reverse()); diff --git a/ICD.Common.Utils/Services/ServiceProvider.cs b/ICD.Common.Utils/Services/ServiceProvider.cs index 8b3e7de..fd3bab6 100644 --- a/ICD.Common.Utils/Services/ServiceProvider.cs +++ b/ICD.Common.Utils/Services/ServiceProvider.cs @@ -308,9 +308,7 @@ namespace ICD.Common.Utils.Services m_ServicesSection.Enter(); if (m_Services.ContainsKey(tService)) - { return false; - } m_Services.Add(tService, service); } diff --git a/ICD.Common.Utils/StringUtils.cs b/ICD.Common.Utils/StringUtils.cs index df05254..6086721 100644 --- a/ICD.Common.Utils/StringUtils.cs +++ b/ICD.Common.Utils/StringUtils.cs @@ -523,20 +523,18 @@ namespace ICD.Common.Utils return text == null ? null : new string(text.Where(c => !Char.IsWhiteSpace(c)).ToArray()); } - /// - /// Returns true if the string is entirely whitespace characters, or empty, or null. - /// - /// - /// - public static bool IsNullOrWhitespace(string text) - { - if (string.IsNullOrEmpty(text)) - { - return true; - } - var trimmed = text.Trim(); - return trimmed.Length == 0; - } + /// + /// Returns true if the string is entirely whitespace characters, or empty, or null. + /// + /// + /// + public static bool IsNullOrWhitespace(string text) + { + if (string.IsNullOrEmpty(text)) + return true; + string trimmed = text.Trim(); + return trimmed.Length == 0; + } /// /// Returns the password as a series of *s