Skip to content

Generating string constants to a class from an enum type.

License

Notifications You must be signed in to change notification settings

nagybalint001/enum-constants

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EnumConstants

license NuGet downloads

Generating string constants to a class from an enum type.

Sample code:

[AutoConstants(typeof(OtherSampleEnum))]
public partial class Sample
{
    [AutoConstants(typeof(SampleEnum), "Asd")]
    public partial class SubClass
    {
        [AutoConstants(typeof(SampleEnum))]
        public partial class SubSubClass
        {
        }
    }

    public void Foo()
    {
        var foo = Sample.Value2; // Value2
        var bar = Sample.SubClass.Value1; // AsdValue1
        var baz = Sample.SubClass.SubSubClass.Value2; // Value2
    }
}

public enum SampleEnum
{
    Value1,
    Value2,
    Value3,
}

public enum OtherSampleEnum
{
    Value1,
    Value2,
    Value3,
}

About

Generating string constants to a class from an enum type.

Resources

License

Stars

Watchers

Forks

Languages