diff --git a/appveyor.yml b/appveyor.yml index 0f25904..b4ad735 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.1.0-{build} +version: 1.1.1-{build} build: verbosity: minimal configuration: diff --git a/src/StevenVolckaert.Core/Globalization/CultureManager.cs b/src/StevenVolckaert.Core/Globalization/CultureManager.cs index a94d4dd..aed6af6 100644 --- a/src/StevenVolckaert.Core/Globalization/CultureManager.cs +++ b/src/StevenVolckaert.Core/Globalization/CultureManager.cs @@ -9,7 +9,7 @@ /// /// Manages cultures of an application. /// - public class CultureManager + public class CultureManager : ICultureManager { private string _currentCultureName; /// @@ -147,16 +147,19 @@ public CultureManager(string defaultCultureName, params string[] supportedCultur : _supportedCultures.First().Key; _currentCultureName = SetDefaultCulture(); - _supportedCultures = _supportedCultures.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); + _supportedCultures = + _supportedCultures.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); } /// - /// Returns an instance of the class based on the culture specified by name, - /// or null if the culture is not supported by the current operating system. + /// Returns an instance of the class based on the culture specified by + /// name, or null if the culture is not supported by the current operating system. /// /// The name of a culture. - /// is null. - public static CultureInfo GetCultureInfo(string cultureName) + /// + /// is null. + /// + public CultureInfo GetCultureInfo(string cultureName) { try { @@ -165,7 +168,11 @@ public static CultureInfo GetCultureInfo(string cultureName) catch (ArgumentNullException) { Debug.WriteLine( - message: string.Format(CultureInfo.CurrentCulture, Resources.ValueNull, nameof(cultureName)), + message: string.Format( + CultureInfo.CurrentCulture, + Resources.ValueNull, + nameof(cultureName) + ), callerMemberName: nameof(GetCultureInfo) ); return null; @@ -177,7 +184,11 @@ public static CultureInfo GetCultureInfo(string cultureName) #endif { Debug.WriteLine( - message: string.Format(CultureInfo.CurrentCulture, Resources.IllegalCultureName, cultureName), + message: string.Format( + CultureInfo.CurrentCulture, + Resources.IllegalCultureName, + cultureName + ), callerMemberName: nameof(GetCultureInfo) ); return null; @@ -187,9 +198,13 @@ public static CultureInfo GetCultureInfo(string cultureName) /// /// Convert a given culture name to the name of it's associated neutral culture. /// - /// The name of the culture, representing a specific or neutral culture. - /// The name of the neutral culture, or null if the culture is not supported. - public static string GetNeutralCultureName(string cultureName) + /// + /// The name of the culture, representing a specific or neutral culture. + /// + /// + /// The name of the neutral culture, or null if the culture is not supported. + /// + public string GetNeutralCultureName(string cultureName) { if (cultureName.IsNullOrWhiteSpace()) return null; @@ -209,7 +224,9 @@ public static string GetNeutralCultureName(string cultureName) /// Returns a value that indicates whether a given culture, or its associated neutral culture, /// is supported by this culture manager. /// - /// The name of the culture, representing a specific or neutral culture. + /// + /// The name of the culture, representing a specific or neutral culture. + /// public bool IsCultureSupported(string cultureName) { if (IsSpecificCultureSupported(cultureName)) @@ -248,11 +265,13 @@ public bool IsCultureSelected(string cultureName) /// Sets the application's current culture. /// If the given culture is not supported, the manager's default culture is selected. /// - /// If a given specific culture is not supported, its associated neutral culture is selected - /// (if it exists). + /// If a given specific culture is not supported, its associated neutral culture is selected + /// (if it exists). /// /// - /// The name of the culture, representing a specific or neutral culture. + /// + /// The name of the culture, representing a specific or neutral culture. + /// /// The name of the manager's culture when the operation finishes. /// /// is null, empty, or white space. @@ -275,7 +294,9 @@ public string SetCulture(string cultureName) /// /// An array that contains zero or more culture names. /// The name of the manager's culture when the operation finishes. - /// is null. + /// + /// is null. + /// public string SetCulture(params string[] cultureNames) { if (cultureNames == null) diff --git a/src/StevenVolckaert.Core/Globalization/ICultureManager.cs b/src/StevenVolckaert.Core/Globalization/ICultureManager.cs new file mode 100644 index 0000000..6867de9 --- /dev/null +++ b/src/StevenVolckaert.Core/Globalization/ICultureManager.cs @@ -0,0 +1,118 @@ +namespace StevenVolckaert.Globalization +{ +using System; +using System.Collections.Generic; +using System.Globalization; + + /// + /// Manages cultures of an application. + /// + public interface ICultureManager + { + /// + /// Gets the manager's current culture. + /// + CultureInfo CurrentCulture { get; } + /// + /// Gets or sets the name of the current culture in the format + /// "<languagecode2>-<country/regioncode2>". + /// + /// + /// The current culture name in the format "<languagecode2>-<country/regioncode2>", + /// where "<languagecode2>" is a lowercase two-letter code derived from ISO 639-1 + /// and "<country/regioncode2>" is an uppercase two-letter code derived from ISO 3166. + /// + string CurrentCultureName { get; set; } + /// + /// Gets the name of the manager's default culture. + /// + string DefaultCultureName { get; } + /// + /// Gets a dictionary of cultures that are supported by this culture manager. + /// + Dictionary SupportedCultures { get; } + /// + /// Occurs when the manager's culture has changed. + /// + event EventHandler CurrentCultureChanged; + /// + /// Returns an instance of the class based on the culture specified by + /// name, or null if the culture is not supported by the current operating system. + /// + /// The name of a culture. + /// + /// is null. + /// + CultureInfo GetCultureInfo(string cultureName); + /// + /// Convert a given culture name to the name of it's associated neutral culture. + /// + /// + /// The name of the culture, representing a specific or neutral culture. + /// + /// + /// The name of the neutral culture, or null if the culture is not supported. + /// + string GetNeutralCultureName(string cultureName); + /// + /// Returns a value that indicates whether a given culture, or it's associated neutral culture, + /// is currently selected. + /// + /// The name of the culture. + bool IsCultureSelected(string cultureName); + /// + /// Returns a value that indicates whether a given culture, or its associated neutral culture, + /// is supported by this culture manager. + /// + /// + /// The name of the culture, representing a specific or neutral culture. + /// + bool IsCultureSupported(string cultureName); + /// + /// Returns a value that indicates whether a given specific culture is supported + /// by this culture manager. + /// + /// The name of the culture. + /// true if the culture is supported, false otherwise. + bool IsSpecificCultureSupported(string cultureName); + /// + /// Sets the application's current culture, given an array of culture names. + /// The manager selects the first culture that is supported, or the default culture + /// if none of the specified cultures are supported. + /// + /// An array that contains zero or more culture names. + /// The name of the manager's culture when the operation finishes. + /// + /// is null. + /// + string SetCulture(params string[] cultureNames); + /// + /// Sets the application's current culture. + /// If the given culture is not supported, the manager's default culture is selected. + /// + /// If a given specific culture is not supported, its associated neutral culture is selected + /// (if it exists). + /// + /// + /// + /// The name of the culture, representing a specific or neutral culture. + /// + /// The name of the manager's culture when the operation finishes. + /// + /// is null, empty, or white space. + /// + string SetCulture(string cultureName); + /// + /// Sets the application's current culture to the manager's default culture. + /// + /// The name of the manager's culture when the operation finishes. + string SetDefaultCulture(); + /// + /// Sets the application's current culture to a specific culture. + /// If the given culture is not supported, the manager's default culture is selected. + /// + /// The name of the culture. + /// The name of the manager's culture when the operation finishes. + string SetSpecificCulture(string cultureName); + } +} diff --git a/src/StevenVolckaert.Core/IEnumerableExtensions.cs b/src/StevenVolckaert.Core/IEnumerableExtensions.cs index 31dfb48..4b83f37 100644 --- a/src/StevenVolckaert.Core/IEnumerableExtensions.cs +++ b/src/StevenVolckaert.Core/IEnumerableExtensions.cs @@ -82,24 +82,6 @@ public static bool IsEmpty(this IEnumerable source) return !source.Any(); } - /// - /// Determines whether a sequence contains no elements. - /// - /// The type of the elements of . - /// The instance to check for emptiness. - /// - /// true if the source sequence contains no elements; otherwise, false. - /// - /// is null. - [Obsolete("Use of this method is deprecated. Use IEnumerable.IsEmpty() instead.")] - public static bool Empty(this IEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return !source.Any(); - } - /// /// Determines whether none of the elements of a sequence satisfies a condition. /// diff --git a/src/StevenVolckaert.Core/README.md b/src/StevenVolckaert.Core/README.md index 29867fd..ad0960f 100644 --- a/src/StevenVolckaert.Core/README.md +++ b/src/StevenVolckaert.Core/README.md @@ -6,7 +6,10 @@ developers with writing less code that's easier to read. The core assembly, named `StevenVolckaert.Core`, contains commonly used functions extending types defined in the `System` namespace. -`StevenVolckaert.Core` targets the [.NET Standard Library][1] version 1.6. +`StevenVolckaert.Core` targets [.NETStandard 1.5][1] and .NETFramework 4.5.2. +## External links + +* [.NET Standard Library][1] [1]: https://docs.microsoft.com/en-us/dotnet/articles/standard/library diff --git a/src/StevenVolckaert.Core/Resources.Designer.cs b/src/StevenVolckaert.Core/Resources.Designer.cs index 79c22e2..6822369 100644 --- a/src/StevenVolckaert.Core/Resources.Designer.cs +++ b/src/StevenVolckaert.Core/Resources.Designer.cs @@ -14,12 +14,13 @@ namespace StevenVolckaert { /// - /// A strongly-typed resource class, for looking up localized strings, etc. + /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -28,17 +29,18 @@ public class Resources { private static global::System.Globalization.CultureInfo resourceCulture; + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// - /// Returns the cached ResourceManager instance used by this class. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StevenVolckaert.Core.Resources", typeof(Resources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StevenVolckaert.Resources", typeof(Resources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; @@ -46,8 +48,8 @@ public class Resources { } /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] public static global::System.Globalization.CultureInfo Culture { @@ -60,7 +62,7 @@ public class Resources { } /// - /// Looks up a localized string similar to day. + /// Looks up a localized string similar to day. /// public static string Day { get { @@ -69,7 +71,7 @@ public class Resources { } /// - /// Looks up a localized string similar to days. + /// Looks up a localized string similar to days. /// public static string Days { get { @@ -78,7 +80,7 @@ public class Resources { } /// - /// Looks up a localized string similar to [{0}] Exception in {1}: {2}. + /// Looks up a localized string similar to [{0}] Exception in {1}: {2}. /// public static string DebugExceptionMessageFormat { get { @@ -87,7 +89,7 @@ public class Resources { } /// - /// Looks up a localized string similar to [{0}] {1}: {2}. + /// Looks up a localized string similar to [{0}] {1}: {2}. /// public static string DebugMessageFormat { get { @@ -96,7 +98,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Encountered an exception of type '{0}'.. + /// Looks up a localized string similar to Encountered an exception of type '{0}'.. /// public static string EncounteredExceptionOfType { get { @@ -105,7 +107,7 @@ public class Resources { } /// - /// Looks up a localized string similar to File '{0}' not found.. + /// Looks up a localized string similar to File '{0}' not found.. /// public static string FileNotFound { get { @@ -114,7 +116,7 @@ public class Resources { } /// - /// Looks up a localized string similar to hour. + /// Looks up a localized string similar to hour. /// public static string Hour { get { @@ -123,7 +125,7 @@ public class Resources { } /// - /// Looks up a localized string similar to hours. + /// Looks up a localized string similar to hours. /// public static string Hours { get { @@ -132,7 +134,7 @@ public class Resources { } /// - /// Looks up a localized string similar to '{0}' is not a valid culture name.. + /// Looks up a localized string similar to '{0}' is not a valid culture name.. /// public static string IllegalCultureName { get { @@ -141,7 +143,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Illegal enum value '{0}'.. + /// Looks up a localized string similar to Illegal enum value '{0}'.. /// public static string IllegalEnumValue { get { @@ -150,7 +152,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Illegal target type '{0}'.. + /// Looks up a localized string similar to Illegal target type '{0}'.. /// public static string IllegalTargetType { get { @@ -159,7 +161,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Illegal type '{0}'. Expected type '{1}'.. + /// Looks up a localized string similar to Illegal type '{0}'. Expected type '{1}'.. /// public static string IllegalType { get { @@ -168,7 +170,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Illegal value '{0}'.. + /// Looks up a localized string similar to Illegal value '{0}'.. /// public static string IllegalValue { get { @@ -177,7 +179,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Key '{0}' not found.. + /// Looks up a localized string similar to Key '{0}' not found.. /// public static string KeyNotFound { get { @@ -186,7 +188,7 @@ public class Resources { } /// - /// Looks up a localized string similar to less than a minute. + /// Looks up a localized string similar to less than a minute. /// public static string LessThanOneMinute { get { @@ -195,7 +197,7 @@ public class Resources { } /// - /// Looks up a localized string similar to minute. + /// Looks up a localized string similar to minute. /// public static string Minute { get { @@ -204,7 +206,7 @@ public class Resources { } /// - /// Looks up a localized string similar to minutes. + /// Looks up a localized string similar to minutes. /// public static string Minutes { get { @@ -213,7 +215,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Value contains no elements.. + /// Looks up a localized string similar to Value contains no elements.. /// public static string ValueContainsNoElements { get { @@ -222,7 +224,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Value contains no supported elements.. + /// Looks up a localized string similar to Value contains no supported elements.. /// public static string ValueContainsNoSupportedElements { get { @@ -231,7 +233,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Value with ID '{0}' not found.. + /// Looks up a localized string similar to Value with ID '{0}' not found.. /// public static string ValueNotFound { get { @@ -240,7 +242,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Value '{0}' is not supported.. + /// Looks up a localized string similar to Value '{0}' is not supported.. /// public static string ValueNotSupported { get { @@ -249,7 +251,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Value of parameter '{0}' is null.. + /// Looks up a localized string similar to Value of parameter '{0}' is null.. /// public static string ValueNull { get { @@ -258,7 +260,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Value is null, empty, or white space.. + /// Looks up a localized string similar to Value is null, empty, or white space.. /// public static string ValueNullEmptyOrWhiteSpace { get { @@ -267,7 +269,7 @@ public class Resources { } /// - /// Looks up a localized string similar to Value is null or empty.. + /// Looks up a localized string similar to Value is null or empty.. /// public static string ValueNullOrEmpty { get { diff --git a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj index 945dc9c..bac2198 100644 --- a/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj +++ b/src/StevenVolckaert.Core/StevenVolckaert.Core.csproj @@ -4,14 +4,12 @@ StevenVolckaert.Core Steven Volckaert's Enterprise Library - Core en-US - 1.0.1 - alpha Copyright (c) 2016, 2017 Steven Volckaert Steven Volckaert's Enterprise Library contains reusable software components designed to assist software developers with writing less and semantically more meaningful code. See https://github.com/stevenvolckaert/enterprise-library for more information. Steven Volckaert - net452;netstandard1.5 + netstandard1.5;net452 true StevenVolckaert.Core https://github.com/stevenvolckaert/enterprise-library @@ -23,9 +21,9 @@ See https://github.com/stevenvolckaert/enterprise-library for more information.< false false StevenVolckaert - 1.1.0.0 - 1.1.0.0 - 1.1.0 + 1.1.1.0 + 1.1.1.0 + 1.1.1 @@ -37,4 +35,19 @@ See https://github.com/stevenvolckaert/enterprise-library for more information.< + + + True + True + Resources.resx + + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + diff --git a/src/StevenVolckaert.Core/StringExtensions.cs b/src/StevenVolckaert.Core/StringExtensions.cs index a36154d..597a5af 100644 --- a/src/StevenVolckaert.Core/StringExtensions.cs +++ b/src/StevenVolckaert.Core/StringExtensions.cs @@ -49,20 +49,6 @@ public static bool IsNullOrWhiteSpace(this string value) #endif } - /// - /// Returns the string, or a default value if the string is null or empty. - /// - /// The value this extension method affects. - /// The default value. - /// - /// The string, or the default value if the string is null or empty. - /// - [Obsolete("Use of this method is deprecated. Use string.FallbackIfNullOrEmpty(string) instead.")] - public static string DefaultIfNullOrEmpty(this string value, string defaultValue) - { - return value.FallbackIfNullOrWhiteSpace(defaultValue); - } - /// /// Returns the string, or a specified fallback value if the string is null or empty. /// @@ -76,20 +62,6 @@ public static string FallbackIfNullOrEmpty(this string value, string fallbackVal return string.IsNullOrEmpty(value) ? fallbackValue : value; } - /// - /// Returns the string, or a default value if the string is null, empty, or white space. - /// - /// The value this extension method affects. - /// The default value. - /// - /// The string, or the default value if the string is null, empty, or white space. - /// - [Obsolete("Use of this method is deprecated. Use string.FallbackIfNullOrWhiteSpace(string) instead.")] - public static string DefaultIfNullOrWhiteSpace(this string value, string defaultValue) - { - return value.FallbackIfNullOrWhiteSpace(defaultValue); - } - /// /// Returns the string, /// or a specified fallback value if the string is null, empty, or white space. diff --git a/test/StevenVolckaert.Core.Tests/ResourcesTests.cs b/test/StevenVolckaert.Core.Tests/ResourcesTests.cs new file mode 100644 index 0000000..1633edd --- /dev/null +++ b/test/StevenVolckaert.Core.Tests/ResourcesTests.cs @@ -0,0 +1,17 @@ +namespace StevenVolckaert.Tests +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class ResourcesTests + { + [TestMethod] + public void CanAccessResources() + { + var resourceManager = Resources.ResourceManager; + + Assert.IsNotNull(resourceManager); + Assert.IsNotNull(Resources.ValueNullEmptyOrWhiteSpace); + } + } +} diff --git a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj index ec8e296..86056b3 100644 --- a/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj +++ b/test/StevenVolckaert.Core.Tests/StevenVolckaert.Core.Tests.csproj @@ -3,13 +3,13 @@ netcoreapp1.1 StevenVolckaert.Tests - 1.1.0 + 1.1.1 - - - + + +