Skip to content

Commit

Permalink
Merge pull request #4 from stevenvolckaert/vNext
Browse files Browse the repository at this point in the history
Merging v1.0.0.
  • Loading branch information
stevenvolckaert authored Mar 1, 2017
2 parents 471e208 + 12e3f97 commit d7834aa
Show file tree
Hide file tree
Showing 14 changed files with 443 additions and 34 deletions.
3 changes: 3 additions & 0 deletions StevenVolckaert.EnterpriseLibrary.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{887100A5-0
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StevenVolckaert.Core.Tests", "test\StevenVolckaert.Core.Tests\StevenVolckaert.Core.Tests.xproj", "{A97F5579-7D70-4FD4-8D6B-DC12E4909AD2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{54EC9438-05ED-4ACD-AEF6-B31B353069EA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -38,6 +40,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3E5DE170-18C8-4B09-90A6-7D158A6C54C5} = {54EC9438-05ED-4ACD-AEF6-B31B353069EA}
{A97F5579-7D70-4FD4-8D6B-DC12E4909AD2} = {887100A5-003F-4148-85D8-9D9C9E7E5125}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 0.1.1-{build}
version: 1.0.0-{build}
build:
verbosity: minimal
configuration:
Expand Down
25 changes: 25 additions & 0 deletions src/StevenVolckaert.Core/CountryCodes.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace StevenVolckaert
{
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
#if !NET35
using System.Collections.ObjectModel;
#endif
Expand Down Expand Up @@ -190,5 +192,28 @@ public static class CountryCodes
//Republic of Code used for North Yemen before 1990 YT Mayotte 1993 .yt ISO 3166-2:YT ZA South Africa
//1974 .za ISO 3166-2:ZA Code taken from name in Dutch: Zuid-Afrika ZM Zambia 1974 .zm ISO 3166-2:ZM ZW
//Zimbabwe

private static readonly Regex _beneluxUnionMemberStateCountryCodeRegex =
new Regex(RegexValidationPatterns.BeneluxUnionMemberStateCountryCode, RegexOptions.IgnoreCase);

/// <summary>
/// Returns a value that indicates whether the specified ISO 3166-1 alpha-2 country code represents
/// a member state of the Benelux Union.
/// </summary>
/// <param name="countryCode">The ISO 3166-1 alpha-2 country code representing the country.</param>
/// <returns>
/// <c>true</c> if <paramref name="countryCode"/> represents a Benelux Union member state;
/// otherwise, <c>false</c>.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="countryCode"/> is <c>null</c>, empty, or white space.
/// </exception>
public static bool IsBeneluxUnionMemberState(string countryCode)
{
if (countryCode.IsNullOrWhiteSpace())
throw new ArgumentException(Resources.ValueNullEmptyOrWhiteSpace, nameof(countryCode));

return _beneluxUnionMemberStateCountryCodeRegex.IsMatch(countryCode);
}
}
}
26 changes: 26 additions & 0 deletions src/StevenVolckaert.Core/Hyperlink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace StevenVolckaert
{
using System;

/// <summary>
/// Represents a hyperlink.
/// </summary>
public struct Hyperlink
{
/// <summary>
/// Gets or sets the browsing context name of the hyperlink.
/// </summary>
/// <remarks>
/// See http://w3c.github.io/html/browsers.html#browsing-context-names for more information.
/// </remarks>
public string BrowsingContextName { get; set; }
/// <summary>
/// Gets or sets the label of the hyperlink.
/// </summary>
public string Label { get; set; }
/// <summary>
/// Gets or sets the URI of the hyperlink.
/// </summary>
public Uri Uri { get; set; }
}
}
30 changes: 30 additions & 0 deletions src/StevenVolckaert.Core/Int32Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace StevenVolckaert
{
using System;
using System.Globalization;

/// <summary>
Expand All @@ -25,6 +26,35 @@ public static bool IsOdd(this int value)
return !value.IsEven();
}

/// <summary>
/// Returns a string that represents a number of bytes in a human-readable format,
/// using the <see cref="UnitOfInformationPrefix.Binary"/> prefix.
/// </summary>
/// <param name="value">The <see cref="int"/> value, in bytes.</param>
/// <returns>
/// A human-readable string representation of <paramref name="value"/>, using powers of 1024.
/// </returns>
public static string BytesToString(this int value)
{
return ((ulong)value).BytesToString();
}

/// <summary>
/// Returns a string that represent the <see cref="int"/> value in a human-readable format.
/// </summary>
/// <param name="value">The <see cref="int"/> value, in bytes.</param>
/// <param name="prefix">The prefix to be used in the string representation.</param>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="prefix"/> has an illegal value.
/// </exception>
/// <returns>
/// A human-readable string representation of <paramref name="value"/>.
/// </returns>
public static string BytesToString(this int value, UnitOfInformationPrefix prefix)
{
return ((ulong)value).BytesToString(prefix);
}

/// <summary>
/// Returns a string that represents the <see cref="int"/> value in a human-readable format.
/// </summary>
Expand Down
34 changes: 13 additions & 21 deletions src/StevenVolckaert.Core/Int64Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@
using System.Globalization;
using System.Linq;

/// <summary>
/// Specifies a prefix that is used in combination with a unit of information (e.g. byte).
/// </summary>
public enum UnitOfInformationPrefix
{
/// <summary>
/// No prefix, indicating a power of 1.
/// </summary>
None = 0,

/// <summary>
/// A decimal prefix, indicating a power of 1000.
/// </summary>
Decimal = 1000,

/// <summary>
/// A binary prefix, indicating a power of 1024.
/// </summary>
Binary = 1024
}

/// <summary>
/// Provides extension methods for <see cref="long"/> and <see cref="ulong"/> values.
/// </summary>
Expand All @@ -36,6 +15,19 @@ public static class Int64Extensions
private static readonly string[] _decimalUnitSymbols =
new string[] { "B", "kB", "MB", "GB", "TB", "PB" };

/// <summary>
/// Returns a string that represents a number of bytes in a human-readable format,
/// using the <see cref="UnitOfInformationPrefix.Binary"/> prefix.
/// </summary>
/// <param name="value">The <see cref="ulong"/> value, in bytes.</param>
/// <returns>
/// A human-readable string representation of <paramref name="value"/>, using powers of 1024.
/// </returns>
public static string BytesToString(this ulong value)
{
return value.BytesToString(UnitOfInformationPrefix.Binary);
}

/// <summary>
/// Returns a string that represents a number of bytes in a human-readable format.
/// </summary>
Expand Down
20 changes: 13 additions & 7 deletions src/StevenVolckaert.Core/RegexValidationPatterns.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
namespace StevenVolckaert
{
/// <summary>
/// Provides access to regular expression patterns that are used to validate strings.
/// Provides regular expression patterns that are used to validate strings.
/// </summary>
public static class RegexValidationPatterns
{
/// <summary>
/// A regular expression pattern used to validate strings that represent
/// a single ISO 3166-1 alpha-2 country code.
/// A regular expression pattern used to validate strings that represent
/// a single ISO 3166-1 alpha-2 country code.
/// </summary>
public const string CountryCode = @"^[A-Z]{2}$";

/// <summary>
/// A regular expression pattern used to validate strings that represent
/// a single culture name, as used by the <see cref="System.Globalization.CultureInfo"/> class.
/// A regular expression pattern used to validate strings that represent
/// an ISO 3166-1 alpha-2 country code of a Benelux Union member state.
/// </summary>
public const string BeneluxUnionMemberStateCountryCode = @"BE|NL|LU";

/// <summary>
/// A regular expression pattern used to validate strings that represent
/// a single culture name, as used by the <see cref="System.Globalization.CultureInfo"/> class.
/// </summary>
public const string CultureName = @"[a-z]{2}(-[A-Za-z]{2,8})?";

/// <summary>
/// A regular expression pattern used to validate strings that represent a single email address.
/// A regular expression pattern used to validate strings that represent a single email address.
/// </summary>
public const string EmailAddress =
@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

/// <summary>
/// A regular expression pattern used to validate strings that represent a 32-bit signed integer.
/// A regular expression pattern used to validate strings that represent a 32-bit signed integer.
/// </summary>
public const string Int32 = @"^(-)?[0-9]+$";
}
Expand Down
26 changes: 26 additions & 0 deletions src/StevenVolckaert.Core/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ public static bool IsDecimal(this string value)
}
}

/// <summary>
/// Returns a value that indicates whether the string represents a <see cref="Guid"/> value.
/// </summary>
/// <param name="value">The <see cref="string"/> value this extension method affects.</param>
/// <returns>
/// <c>true</c> if <paramref name="value"/> represents a <see cref="Guid"/> value;
/// otherwise, <c>false</c>.
/// </returns>
public static bool IsGuid(this string value)
{
#if NET35
try
{
var guid = new Guid(value);
return true;
}
catch (Exception)
{
return false;
}
#else
Guid guid;
return Guid.TryParse(value, out guid);
#endif
}

/// <summary>
/// Returns a value that indicates whether the string represents a 32-bit signed integer.
/// </summary>
Expand Down
21 changes: 21 additions & 0 deletions src/StevenVolckaert.Core/UnitOfInformationPrefix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace StevenVolckaert
{
/// <summary>
/// Specifies a prefix that is used in combination with a unit of information (e.g. byte).
/// </summary>
public enum UnitOfInformationPrefix
{
/// <summary>
/// No prefix, indicating a power of 1.
/// </summary>
None = 0,
/// <summary>
/// A decimal prefix, indicating a power of 1000.
/// </summary>
Decimal = 1000,
/// <summary>
/// A binary prefix, indicating a power of 1024.
/// </summary>
Binary = 1024
}
}
2 changes: 1 addition & 1 deletion src/StevenVolckaert.Core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"copyright": "Copyright (c) 2016 Steven Volckaert",
"description": "Steven Volckaert's Enterprise Library contains reusable software components designed to assist software developers with writing less and semantically more meaningful code.\n\nSee https://github.com/stevenvolckaert/enterprise-library for more information.",
"language": "en-US",
"version": "0.1.1-*",
"version": "1.0.0-*",
"authors": [ "Steven Volckaert" ],
"frameworks": {
"net35": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
[TestClass]
public class CultureManagerTests
{
/* TODO Implement the unit tests. For instance: Calling any of the SetCulture methods should return the
* name of the culture after execution, which must equal the CurrentCultureName property of the culture
* manager (after execution). Steven Volckaert. December 13, 2016.
/* TODO Implement the unit tests. For instance: Calling any of the SetCulture methods should return
* the name of the culture after execution, which must equal the CurrentCultureName property of the
* culture manager (after execution). Steven Volckaert. December 13, 2016.
*/

//[TestMethod]
Expand Down
Loading

0 comments on commit d7834aa

Please sign in to comment.