Skip to content

Instantly share code, notes, and snippets.

@xtrmstep
Last active November 15, 2020 15:08
Show Gist options
  • Select an option

  • Save xtrmstep/1698213f3123f8272b4d0e30f16d8e70 to your computer and use it in GitHub Desktop.

Select an option

Save xtrmstep/1698213f3123f8272b4d0e30f16d8e70 to your computer and use it in GitHub Desktop.
Using Feature Flags and Externalized configuration .NET Core app with Flagsmith - 1
// 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