Skip to content

Commit

Permalink
Remove Helpers and create Core namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Boggin committed Sep 2, 2019
1 parent 4975cf4 commit 7dcc693
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 36 deletions.
2 changes: 1 addition & 1 deletion FeatureFlagger.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FeatureFlagger", "src\FeatureFlagger\FeatureFlagger.csproj", "{9D15A2B6-FAEB-4A28-A25E-C58BCF327CC2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FeatureFlagger.Core", "src\FeatureFlagger\FeatureFlagger.Core.csproj", "{9D15A2B6-FAEB-4A28-A25E-C58BCF327CC2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FeatureFlagger.Behaviours", "src\FeatureFlagger.Behaviours\FeatureFlagger.Behaviours.csproj", "{0F866C20-3765-41C8-9A10-BBE4F1F08AD4}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 1,6 @@
namespace FeatureFlagger.Example.Console
using FeatureFlagger.Core;

namespace FeatureFlagger.Example.Console
{
public class ExampleFeatureFlag : IFeatureFlagger
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 5,6 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\FeatureFlagger\FeatureFlagger.csproj">
<Private>true</Private>
</ProjectReference>
<ProjectReference Include="..\..\src\FeatureFlagger\FeatureFlagger.Core.csproj" />
</ItemGroup>
</Project>
4 changes: 3 additions & 1 deletion examples/FeatureFlagger.Example.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 1,6 @@
namespace FeatureFlagger.Example.Console
using FeatureFlagger.Core;

namespace FeatureFlagger.Example.Console
{
public class Program
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 9,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FeatureFlagger\FeatureFlagger.csproj" />
<ProjectReference Include="..\FeatureFlagger\FeatureFlagger.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 1,6 @@
namespace FeatureFlagger.Authorisation
{
using FeatureFlagger.Core;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
14 changes: 13 additions & 1 deletion src/FeatureFlagger.ConfigurationReaders/ConfigReader.cs
Original file line number Diff line number Diff line change
@@ -1,15 1,27 @@
namespace FeatureFlagger.ConfigurationReaders
{
using System;
using System.Collections.Generic;
using System.Composition;
using System.Configuration;

using System.Linq;
using FeatureFlagger.Domain;

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

public IEnumerable<Feature> ReadAll()
{
var features = (List<Feature>)ConfigurationManager.GetSection("features");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,8 @@

public interface IConfigurationReader
{
Feature Read(string featureName, IEnumerable<Feature> features);

/// <summary>
/// Read the configuration.
/// </summary>
Expand Down
14 changes: 13 additions & 1 deletion src/FeatureFlagger.ConfigurationReaders/StoreReader.cs
Original file line number Diff line number Diff line change
@@ -1,5 1,6 @@
namespace FeatureFlagger.ConfigurationReaders
{
using System;
using System.Collections.Generic;
using System.Composition;
using System.Configuration;
Expand All @@ -12,9 13,20 @@ namespace FeatureFlagger.ConfigurationReaders
[ExportMetadata("Reader", Constants.Store)]
public class StoreReader : IConfigurationReader
{
public Feature Read(string featureName, IEnumerable<Feature> features)
{
return
features.ToList()
.Find(
f =>
f.Name.Equals(
featureName,
StringComparison.OrdinalIgnoreCase));
}

public IEnumerable<Feature> ReadAll()
{
var connectionString = ConfigurationManager.ConnectionStrings["FeatureFlagger_DB"].ConnectionString;
var connectionString = ConfigurationManager.ConnectionStrings["FeatureFlagger"].ConnectionString;

const string QueryString =
"SELECT Features.Name, Flags.Name, FlagProperties.PropertyKey, FlagProperties.PropertyValue "
Expand Down
6 changes: 3 additions & 3 deletions src/FeatureFlagger/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,9 1,9 @@
namespace FeatureFlagger
namespace FeatureFlagger.Core
{
public static class Constants
{
public const string Config = "CONFIG";
public const string Config = "CONFIG";
public const string Feature = "FEATURE";
public const string Store = "STORE";
public const string Store = "STORE";
}
}
4 changes: 2 additions & 2 deletions src/FeatureFlagger/FeatureFlagExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
namespace FeatureFlagger
namespace FeatureFlagger.Core
{
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -30,7 30,7 @@ private static IEnumerable<Flag> GetFlags(IFeatureFlagger featureFlagger)
featureFlagger.GetType().Name
.Replace("FeatureFlagger", string.Empty);

var feature = Helpers.Read(featureName);
var feature = FeatureFlagger.Reader.Read(featureName, FeatureFlagger.Features);

// add the feature name to each flag as a property
// (as long as it's not been added already).
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/FeatureFlagger/FeatureFlagger.cs
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
namespace FeatureFlagger
namespace FeatureFlagger.Core
{
using System;
using System.Collections.Generic;
Expand Down
19 changes: 0 additions & 19 deletions src/FeatureFlagger/Helpers.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/FeatureFlagger/IFeatureFlag.cs
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
namespace FeatureFlagger
namespace FeatureFlagger.Core
{
public interface IFeatureFlagger
{
Expand Down
2 changes: 2 additions & 0 deletions tests/FeatureFlagger.Tests/DisabledFeatureFlagger.cs
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
namespace FeatureFlagger.Tests
{
using FeatureFlagger.Core;

public class DisabledFeatureFlagger : IFeatureFlagger
{
}
Expand Down
2 changes: 2 additions & 0 deletions tests/FeatureFlagger.Tests/ExampleFeatureFlagger.cs
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
namespace FeatureFlagger.Tests
{
using FeatureFlagger.Core;

public class ExampleFeatureFlagger : IFeatureFlagger
{
}
Expand Down
2 changes: 1 addition & 1 deletion tests/FeatureFlagger.Tests/FeatureFlagger.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 24,6 @@
<ItemGroup>
<ProjectReference Include="..\..\src\FeatureFlagger.Authorisation\FeatureFlagger.Authorisation.csproj" />
<ProjectReference Include="..\..\src\FeatureFlagger.ConfigurationReaders\FeatureFlagger.ConfigurationReaders.csproj" />
<ProjectReference Include="..\..\src\FeatureFlagger\FeatureFlagger.csproj" />
<ProjectReference Include="..\..\src\FeatureFlagger\FeatureFlagger.Core.csproj" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions tests/FeatureFlagger.Tests/FeatureFlaggerTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 1,6 @@
namespace FeatureFlagger.Tests
{
using FeatureFlagger.Core;
using Shouldly;
using Xunit;

Expand Down
2 changes: 2 additions & 0 deletions tests/FeatureFlagger.Tests/FromFeatureFlagger.cs
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
namespace FeatureFlagger.Tests
{
using FeatureFlagger.Core;

public class FromFeatureFlagger : IFeatureFlagger
{
}
Expand Down
2 changes: 2 additions & 0 deletions tests/FeatureFlagger.Tests/UnuserFeatureFlagger.cs
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
namespace FeatureFlagger.Tests
{
using FeatureFlagger.Core;

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unuser", Justification = "No, really")]
public class UnuserFeatureFlagger : IFeatureFlagger
{
Expand Down
2 changes: 2 additions & 0 deletions tests/FeatureFlagger.Tests/UserFeatureFlagger.cs
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
namespace FeatureFlagger.Tests
{
using FeatureFlagger.Core;

public class UserFeatureFlagger : IFeatureFlagger
{
}
Expand Down

0 comments on commit 7dcc693

Please sign in to comment.