StringEnum by Gerardo Grignoli

<PackageReference Include="StringEnum" Version="0.0.2" />

.NET API 10,240 bytes

 StringEnum 0.0.2

StringEnum is a base class for creating string-valued enums in .NET. Features - Your StringEnum interface looks somewhat similar to a regular enum: - Intellisense will suggest the enum name if the class is annotated with the xml comment `<completitionlist>`. (Works in both C# and VB) Usage: ///<completionlist cref="HexColor"/> class HexColor : StringEnum<HexColor> { public static readonly HexColor Blue = New("#FF0000"); public static readonly HexColor Green = New("#00FF00"); public static readonly HexColor Red = New("#000FF"); } // Static Parse Method HexColor.Parse("#FF0000") // => HexColor.Red HexColor.Parse("#ff0000", caseSensitive: false) // => HexColor.Red HexColor.Parse("invalid") // => throws InvalidOperationException // Static TryParse method. HexColor.TryParse("#FF0000") // => HexColor.Red HexColor.TryParse("#ff0000", caseSensitive: false) // => HexColor.Red HexColor.TryParse("invalid") // => null // Conversion from your `StringEnum` to `string` string myString1 = HexColor.Red.ToString(); // => "#FF0000" string myString2 = HexColor.Red; // => "#FF0000" (implicit cast)

<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>StringEnum</id>
    <version>0.0.2</version>
    <authors>Gerardo Grignoli</authors>
    <owners>Gerardo Grignoli</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <license type="expression">MIT</license>
    <licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
    <projectUrl>https://github.com/gerardog/StringEnum</projectUrl>
    <description>StringEnum is a base class for creating string-valued enums in .NET.

 Features
- Your StringEnum interface looks somewhat similar to a regular enum:
- Intellisense will suggest the enum name if the class is annotated with the xml comment `&lt;completitionlist&gt;`. (Works in both C# and VB)

Usage:

///&lt;completionlist cref="HexColor"/&gt; 
class HexColor : StringEnum&lt;HexColor&gt;
{
    public static readonly HexColor Blue = New("#FF0000");
    public static readonly HexColor Green = New("#00FF00");
    public static readonly HexColor Red = New("#000FF");
}

// Static Parse Method
HexColor.Parse("#FF0000") // =&gt; HexColor.Red
HexColor.Parse("#ff0000", caseSensitive: false) // =&gt; HexColor.Red
HexColor.Parse("invalid") // =&gt; throws InvalidOperationException

// Static TryParse method.
HexColor.TryParse("#FF0000") // =&gt; HexColor.Red
HexColor.TryParse("#ff0000", caseSensitive: false) // =&gt; HexColor.Red
HexColor.TryParse("invalid") // =&gt; null

// Conversion from your `StringEnum` to `string`
string myString1 = HexColor.Red.ToString(); // =&gt; "#FF0000"
string myString2 = HexColor.Red; // =&gt; "#FF0000" (implicit cast)</description>
    <copyright>2019 Gerardo Grignoli</copyright>
    <tags>string valued enum enumstring stringenum</tags>
    <repository type="git" url="https://github.com/gerardog/StringEnum" />
    <dependencies>
      <group targetFramework=".NETStandard1.0">
        <dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" />
      </group>
    </dependencies>
  </metadata>
</package>