Skip to content

Commit

Permalink
Update from Core 2.0 to 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Boggin committed May 26, 2021
1 parent 7dcc693 commit 48f311b
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 26 deletions.
4 changes: 4 additions & 0 deletions examples/FeatureFlagger.Example.Console/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,10 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="FeatureFlagger.Reader" value="CONFIG"/>
<add key="FeatureFlagger.Writer" value="CONFIG"/>
</appSettings>
<features>
<feature name="example" enabled="true">
<from date="2015-03-20" />
Expand Down
6 changes: 3 additions & 3 deletions examples/FeatureFlagger.Example.Console/ExampleFeatureFlag.cs
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
using FeatureFlagger.Core;

namespace FeatureFlagger.Example.Console
namespace FeatureFlagger.Example.Console
{
using FeatureFlagger.Core;

public class ExampleFeatureFlag : IFeatureFlagger
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\FeatureFlagger\FeatureFlagger.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 5,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7">
<NoWarn>NU1701</NoWarn>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions src/FeatureFlagger.ConfigurationReaders/ConfigReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 24,15 @@ public Feature Read(string featureName, IEnumerable<Feature> features)

public IEnumerable<Feature> ReadAll()
{
var features = (List<Feature>)ConfigurationManager.GetSection("features");
Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);

return features;
var sectionName = "features";

FeaturesSection section = config.GetSection(sectionName) as FeaturesSection;

return null;
}
}
}
2 changes: 1 addition & 1 deletion src/FeatureFlagger.ConfigurationReaders/FeaturesSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 9,7 @@

using FeatureFlagger.Domain;

public class FeaturesSection : ConfigurationSection
public sealed class FeaturesSection : ConfigurationSection
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", MessageId = "System.Xml.XmlNode", Justification = "Standard method")]
public object Create(
Expand Down
38 changes: 38 additions & 0 deletions src/FeatureFlagger.ConfigurationReaders/TestReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 1,38 @@
namespace FeatureFlagger.ConfigurationReaders
{
using System;
using System.Collections.Generic;
using System.Composition;
using System.Linq;
using FeatureFlagger.Domain;

[Export(typeof(IConfigurationReader))]
[ExportMetadata("Reader", "TEST")]
public class TestReader : IConfigurationReader
{
public Feature Read(string featureName, IEnumerable<Feature> features)
{
return
features.ToList()
.Find(
f =>
f.Name.Equals(
featureName,
StringComparison.OrdinalIgnoreCase));
}

public IEnumerable<Feature> ReadAll()
{
List<Feature> features = new List<Feature>();

var properties =
new Dictionary<string, string> { { "enabled", "true" } };
var flag = new Flag("Enabled", properties);
var feature = new Feature("example", new List<Flag> { flag });

features.Add(feature);

return features;
}
}
}
4 changes: 2 additions & 2 deletions src/FeatureFlagger/FeatureFlagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 46,7 @@ private static IConfigurationReader SetReader()
{
// set the configuration reader based on an AppSetting.
var source =
ConfigurationManager.AppSettings["FeatureFlaggerSource"]
ConfigurationManager.AppSettings["FeatureFlagger.Reader"]
?? Constants.Config;

var reader =
Expand All @@ -66,7 66,7 @@ private static IConfigurationWriter SetWriter()
{
// set the configuration writer based on an AppSetting.
var source =
ConfigurationManager.AppSettings["FeatureFlaggerSource"];
ConfigurationManager.AppSettings["FeatureFlagger.Writer"];

// if a writer isn't required then don't proceed.
if (string.IsNullOrEmpty(source))
Expand Down
18 changes: 3 additions & 15 deletions tests/FeatureFlagger.Tests/App.config
Original file line number Diff line number Diff line change
@@ -1,18 1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="features" type="FeatureFlagger.ConfigurationReaders.FeaturesSection, FeatureFlagger.ConfigurationReaders" />
</configSections>
<features>
<feature name="example" enabled="true"></feature>
<feature name="disabled" enabled="false"></feature>
<feature name="from" enabled="true">
<from date="2015-03-20" />
</feature>
<feature name="test" enabled="true">
<from date="2015-03-20" />
<rollout percentage="25" basis="user" name="barndoor" />
<fullmoon />
</feature>
</features>
<appSettings>
<add key="FeatureFlagger.Reader" value="TEST"/>
</appSettings>
</configuration>
2 changes: 1 addition & 1 deletion tests/FeatureFlagger.Tests/FeatureFlagger.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ApplicationIcon />
<Win32Resource />
</PropertyGroup>
Expand Down

0 comments on commit 48f311b

Please sign in to comment.