Add EnumValueObject
See original GitHub issueHey together,
before creating a pull request I wanted to retrieve some feedback for the following new type: EnumValueObject
The basic idea is that have a better enumeration type in the eco-system of the CSharpFunctionalExtensions.
It has the following construct when used:
public class Language : EnumValueObject<Language>
{
public static readonly Language German = new Language("de");
public static readonly Language English = new Language("en");
protected Language(string key) : base(key)
{
}
}
The main advantage over a “normal” enum would be:
- Type-Safety (the Create method returns a
Result<TEnumValueObject>) - Extendable without extension methods
To see the reference implementation which I would like to merge in this repository head over to my repository: EnumValueObject
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:22 (18 by maintainers)
Top Results From Across the Web
Use object literal as TypeScript enum values
TypeScript supports numeric or string-based enums only, so you have to emulate object enums with a class (which will allow you to use...
Read more >Attaching Values to Java Enum
The Enum constructor can accept multiple values. Similarly, we can add any values we want to the enum, such as the proper case...
Read more >TypeScript: Handbook - Enums
Enums allow a developer to define a set of named constants. Using enums can make it easier to document intent, or create a...
Read more >Enum in TypeScript
Enum in TypeScript supports reverse mapping. It means we can access the value of a member and also a member name from its...
Read more >How To Use Enums in TypeScript
Enums in TypeScript are usually used to represent a determined number of options for a given value. This data is arranged in a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, I plan to do a full-blown documentation of all features, including this one. Issue for tracking: https://github.com/vkhorikov/CSharpFunctionalExtensions/issues/255
Great! Pushing this with v2.15.0.
Not closing the issue as a reminder to see if the code can be refactored toward inheritance.