Skip to content

Commit

Permalink
Features Section reader WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Boggin committed Aug 30, 2019
1 parent adfca5c commit 4975cf4
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 28 deletions.
8 changes: 4 additions & 4 deletions examples/FeatureFlagger.Example.Console/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 7,14 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<features>
<flag name="example" enabled="true">
<feature name="example" enabled="true">
<from date="2015-03-20" />
</flag>
<flag name="test" enabled="true">
</feature>
<feature name="test" enabled="true">
<from date="2015-03-20" />
<rollout percentage="25" basis="user" name="barndoor" />
<fullmoon />
</flag>
</feature>
</features>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
Expand Down
4 changes: 3 additions & 1 deletion src/FeatureFlagger.ConfigurationReaders/ConfigReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,9 @@ public class ConfigReader : IConfigurationReader
{
public IEnumerable<Feature> ReadAll()
{
return (List<Feature>)ConfigurationManager.GetSection("features");
var features = (List<Feature>)ConfigurationManager.GetSection("features");

return features;
}
}
}
8 changes: 5 additions & 3 deletions src/FeatureFlagger.ConfigurationReaders/FeaturesSection.cs
Original file line number Diff line number Diff line change
@@ -1,13 1,15 @@
namespace IntermediaryManagement.Api.FeatureFlagger
namespace FeatureFlagger.ConfigurationReaders
{
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Linq;
using System.Xml;
using global::FeatureFlagger.Domain;

public class FeaturesSection : IConfigurationSectionHandler
using FeatureFlagger.Domain;

public class FeaturesSection : ConfigurationSection
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", MessageId = "System.Xml.XmlNode", Justification = "Standard method")]
public object Create(
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/FeatureFlagger.ConfigurationWriters/StoreWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 16,7 @@ public class StoreWriter : IConfigurationWriter
[ImportingConstructor]
public StoreWriter()
{
this.connectionString = ConfigurationManager.ConnectionStrings["FeatureFlagger_DB"].ConnectionString;
this.connectionString = ConfigurationManager.ConnectionStrings["FeatureFlagger"].ConnectionString;
}

public void Create(Feature feature)
Expand Down
1 change: 1 addition & 0 deletions src/FeatureFlagger/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 4,6 @@ public static class Constants
{
public const string Config = "CONFIG";
public const string Feature = "FEATURE";
public const string Store = "STORE";
}
}
15 changes: 9 additions & 6 deletions src/FeatureFlagger/FeatureFlagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 44,11 @@ private FeatureFlagger()

private static IConfigurationReader SetReader()
{
// set the configuation reader based on an AppSetting.
// set the configuration reader based on an AppSetting.
var source =
ConfigurationManager.AppSettings["FeatureFlaggerSource"]
?? Constants.Config;

var readers = Readers.ToList();

var reader =
Readers.ToList()
.Find(
Expand All @@ -66,10 64,15 @@ private static IConfigurationReader SetReader()

private static IConfigurationWriter SetWriter()
{
// set the configuation writer based on an AppSetting.
// set the configuration writer based on an AppSetting.
var source =
ConfigurationManager.AppSettings["FeatureFlaggerSource"]
?? Constants.Config;
ConfigurationManager.AppSettings["FeatureFlaggerSource"];

// if a writer isn't required then don't proceed.
if (string.IsNullOrEmpty(source))
{
return null;
}

var writers =
Writers.ToList()
Expand Down
12 changes: 6 additions & 6 deletions tests/FeatureFlagger.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 4,15 @@
<section name="features" type="FeatureFlagger.ConfigurationReaders.FeaturesSection, FeatureFlagger.ConfigurationReaders" />
</configSections>
<features>
<flag name="example" enabled="true"></flag>
<flag name="disabled" enabled="false"></flag>
<flag name="from" enabled="true">
<feature name="example" enabled="true"></feature>
<feature name="disabled" enabled="false"></feature>
<feature name="from" enabled="true">
<from date="2015-03-20" />
</flag>
<flag name="test" enabled="true">
</feature>
<feature name="test" enabled="true">
<from date="2015-03-20" />
<rollout percentage="25" basis="user" name="barndoor" />
<fullmoon />
</flag>
</feature>
</features>
</configuration>
2 changes: 1 addition & 1 deletion tests/FeatureFlagger.Tests/FeaturesData.sql
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
USE [IntermediaryManagement.DB.Test]
USE [FeatureFlagger]
GO
ALTER TABLE [dbo].[UserRole] DROP CONSTRAINT [FK_UserRole_User]
GO
Expand Down

0 comments on commit 4975cf4

Please sign in to comment.