Skip to content

Make Value updateable post initialization #17

@jon49

Description

@jon49

I would like to do something like this:

    public class MessageHandler : SmartEnum<MessageHandler, Action<string>>
    {

        protected MessageHandler(string name, Action<string> value) : base(name, value)
        {
        }

        public void Update(Action<string> value)
        {
            this.Value = value;
        }

        public static MessageHandler ToBeDefinedLater =
            new MessageHandler(nameof(ToBeDefinedLater), _ => { });
    }

Which would be called like this:

MessageHandler.ToBeDefinedLater.Update(s => { "ugh" });

This would allow me to define MessageHandler in one project use it in another and inject the item I would like to work with from the parent project without having to share resources.

I'm not sure if this would cause any problems. But it would definitely make like simpler!

If you know of any workarounds that would be nice. I'm still working on figure it out.

I enjoy your podcast by-the-way. That is how I heard of your library!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions