Last active
November 15, 2020 15:08
-
-
Save xtrmstep/1698213f3123f8272b4d0e30f16d8e70 to your computer and use it in GitHub Desktop.
Using Feature Flags and Externalized configuration .NET Core app with Flagsmith - 1
This file contains hidden or 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
| // main interface | |
| public interface IRemoteConfiguration | |
| { | |
| Task<List<Feature>> GetFeatures(); | |
| Task<List<Setting>> GetSettings(List<string> keys = null); | |
| Task<bool> IsFeatureEnabled(string key); | |
| Task<string> GetSettingValue(string key); | |
| } | |
| // other classes | |
| public abstract class RemoteConfigEntry | |
| { | |
| public string Name { get; set; } | |
| public abstract TValue GetValue<TValue>(); | |
| } | |
| public abstract class RemoteConfigEntry<T> : RemoteConfigEntry | |
| { | |
| public T Value { get; set; } | |
| public override TValue GetValue<TValue>() | |
| { | |
| return (TValue) Convert.ChangeType(Value, typeof(TValue)); | |
| } | |
| } | |
| public sealed class Feature : RemoteConfigEntry<bool> | |
| { | |
| } | |
| public sealed class Setting : RemoteConfigEntry<string> | |
| { | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment