System Library Common Framework
Search Results for

    *.Benchmark*,*.Tests*,*.ApiTests*,*.BaseTest*,DelegateJsonConverter,CalleeCancelledRequestException,ClientResponse,ContentType,OutputCachePolicy
    Show / Hide Table of Contents Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Framework SystemLibrary.Common.Framework.Net.dll

    Decorate the enum key with text.

    EnumTextAttribute

    [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class EnumTextAttribute : Attribute

    Inheritance
    object
    Attribute
    EnumTextAttribute
    Examples
    X
    enum Color 
    {
        [EnumText("Black Colored Text")]
        Black,
        White
    }
    
    var color = Color.Black;
    
    var value = color.ToText();
    
    var value2 = Color.White.ToText();
    
    // 'value' is now "Black Colored Text"
    // 'value2' is now "White", 
    // Note: .ToText() falls back to the ToString() representation of the enum key.
    
    var value = Color.White.GetEnumText();
    // 'value' is now null, as 'White' does not contain the EnumTextAttribute.
    
    var value = Color.Black.GetEnumText();
    // 'value' is now a string with the value 'Black Colored Text', as 'Black' has the EnumTextAttribute.
    Arguments
    X

    Constructors

    Decorate the enum key with text.

    public EnumTextAttribute(string text = null)

    X
    Methods arguments
    Type Name Description
    string text

    Sets additional text metadata for the enum key.

    Fields

    Decorate the enum key with text.

    public string Text

    X
    Field Value
    Type Description
    string

    Extension Methods

    ObjectExtensions.Json(object, bool)
    ObjectExtensions.Json(object, JsonSerializerOptions, bool, params JsonConverter[])
    ObjectExtensions.Json(object, params JsonConverter[])
    ObjectExtensions.Xml(object)

    }

    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Framework