Last active
August 29, 2015 14:24
-
-
Save fontanka16/17624143daf12dbff602 to your computer and use it in GitHub Desktop.
Type Safe Enum example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace Viola.CallSlipFetching | |
{ | |
public sealed class CallSlipDeliveryTypes | |
{ | |
private readonly string _name; | |
private static readonly Dictionary<string, CallSlipDeliveryTypes> Instance = new Dictionary<string, CallSlipDeliveryTypes>(); | |
private CallSlipDeliveryTypes(string name) | |
{ | |
_name = name; | |
Instance[name] = this; | |
} | |
public static explicit operator CallSlipDeliveryTypes(string str) | |
{ | |
CallSlipDeliveryTypes result; | |
if (Instance.TryGetValue(str, out result)) | |
return result; | |
else | |
throw new InvalidCastException(); | |
} | |
/// <summary> | |
/// FJärrut | |
/// </summary> | |
public static readonly CallSlipDeliveryTypes ILLOUT = new CallSlipDeliveryTypes("Fjärrut fysiskt material"); | |
/// <summary> | |
/// Kopia | |
/// </summary> | |
public static readonly CallSlipDeliveryTypes COPY = new CallSlipDeliveryTypes("Fjärrut kopia"); | |
/// <summary> | |
/// Magasinsbeställning | |
/// </summary> | |
public static readonly CallSlipDeliveryTypes STACKCALL = new CallSlipDeliveryTypes("Magasin"); | |
/// <summary> | |
/// Direktleverans | |
/// </summary> | |
public static readonly CallSlipDeliveryTypes DIRECTDELIVERY = new CallSlipDeliveryTypes("Direktleverans"); | |
/// <summary> | |
/// Sakanade | |
/// </summary> | |
public static readonly CallSlipDeliveryTypes MISSING = new CallSlipDeliveryTypes("Saknade"); | |
///<summary> | |
/// Saknade | |
/// </summary> | |
public static readonly CallSlipDeliveryTypes MISSINGSEARCHEDONCE = new CallSlipDeliveryTypes("MissingSearchedOnce"); | |
public override String ToString() | |
{ | |
return _name; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment