forked from emailage/feature-management-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeatureManagementConfigurationExtensions.cs
35 lines (32 loc) · 1.29 KB
/
FeatureManagementConfigurationExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Linq;
using FeatureManagementSandbox.ConfigurationSources;
using Microsoft.Extensions.Configuration;
using StackExchange.Redis;
namespace FeatureManagementSandbox
{
public static class FeatureManagementConfigurationExtensions
{
public static IConfigurationBuilder AddFeatureFlagsConfiguration(this IConfigurationBuilder configuration)
{
configuration.Add(new DummyConfigurationSource());
//configuration.Add(new RedisConfigurationSource());
//configuration.Add(new AppConfigConfigurationSource());
return configuration;
}
public static string[] ToStringArray(this RedisValue[] values)
{
if (values == null) return null;
if (values.Length == 0) return new string[0];
return Array.ConvertAll(values, x => (string)x);
}
public static bool ContentEquals<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, Dictionary<TKey, TValue> otherDictionary)
{
return (otherDictionary ?? new Dictionary<TKey, TValue>())
.OrderBy(kvp => kvp.Key)
.SequenceEqual((dictionary ?? new Dictionary<TKey, TValue>())
.OrderBy(kvp => kvp.Key));
}
}
}