diff --git a/Source/FeatureSwitcher.Configuration/AppConfig.cs b/Source/FeatureSwitcher.Configuration/AppConfig.cs index 599b822..066ccd8 100644 --- a/Source/FeatureSwitcher.Configuration/AppConfig.cs +++ b/Source/FeatureSwitcher.Configuration/AppConfig.cs @@ -63,7 +63,7 @@ private FeaturesSection FeaturesSection get { return _features ?? SectionGroup.GetFeaturesSection(_settings.SectionGroupName, _settings.IgnoreConfigurationErrors); } } - public bool? IsEnabled(string feature) + public bool? IsEnabled(Feature.Name feature) { return Features(feature).GetValueOrDefault(Default(feature).GetValueOrDefault()); } diff --git a/Source/FeatureSwitcher.Configuration/AppConfigDefault.cs b/Source/FeatureSwitcher.Configuration/AppConfigDefault.cs index e0e5819..3fddf2a 100644 --- a/Source/FeatureSwitcher.Configuration/AppConfigDefault.cs +++ b/Source/FeatureSwitcher.Configuration/AppConfigDefault.cs @@ -9,7 +9,7 @@ public AppConfigDefault(DefaultSection defaultSection) _defaultSection = defaultSection; } - public bool? IsEnabled(string feature) + public bool? IsEnabled(Feature.Name feature) { if (_defaultSection == null) return null; diff --git a/Source/FeatureSwitcher.Configuration/AppConfigFeatures.cs b/Source/FeatureSwitcher.Configuration/AppConfigFeatures.cs index 68e3519..57198f0 100644 --- a/Source/FeatureSwitcher.Configuration/AppConfigFeatures.cs +++ b/Source/FeatureSwitcher.Configuration/AppConfigFeatures.cs @@ -9,12 +9,12 @@ public AppConfigFeatures(FeaturesSection features) _features = features; } - public bool? IsEnabled(string feature) + public bool? IsEnabled(Feature.Name feature) { if (_features == null) return null; - var featureElement = _features.Features[feature]; + var featureElement = _features.Features[feature.Value]; if (featureElement == null) return null; diff --git a/Source/FeatureSwitcher.Contexteer/Configuration/FeatureConfigurationFor.cs b/Source/FeatureSwitcher.Contexteer/Configuration/FeatureConfigurationFor.cs index efca674..8a69456 100644 --- a/Source/FeatureSwitcher.Contexteer/Configuration/FeatureConfigurationFor.cs +++ b/Source/FeatureSwitcher.Contexteer/Configuration/FeatureConfigurationFor.cs @@ -7,10 +7,10 @@ namespace FeatureSwitcher.Configuration internal class FeatureConfigurationFor : IConfigureFeaturesFor, IConfigureBehaviorFor, IConfigureNamingFor where TContext : IContext { - private Func _nameOf; - private Func NameOf + private Func _namingConvention; + private Func NamingConvention { - get { return _nameOf ?? (ctx => null); } + get { return _namingConvention ?? (ctx => null); } } private Func _behavior; private Func Behavior @@ -38,19 +38,19 @@ IConfigureFeaturesFor IConfigureFeaturesFor.And get { return this; } } - public IConfigureNaming NamedBy + IConfigureNaming IConfigureFeatures.NamedBy { get { return this; } } - public IConfigureBehavior ConfiguredBy + IConfigureBehavior IConfigureFeatures.ConfiguredBy { get { return this; } } - IConfigureFeaturesFor IConfigureNamingFor.Custom(Func naming) + IConfigureFeaturesFor IConfigureNamingFor.Custom(Func namingConventions) { - _nameOf = naming; + _namingConvention = namingConventions; return this; } @@ -60,9 +60,9 @@ IConfigureFeaturesFor IConfigureBehaviorFor.Custom(Func).Custom(ctx => nameOfs); + return (this as IConfigureNamingFor).Custom(ctx => namingConventions); } IConfigureFeatures IConfigureBehavior.Custom(params Feature.Behavior[] behaviors) @@ -73,7 +73,7 @@ IConfigureFeatures IConfigureBehavior.Custom(params Feature.Behavior[] behaviors public Feature.Configuration For(TContext context) { return new Feature.Configuration( - type => (NameOf(context) ?? new Feature.NameOf[0]).Where(x => x != null).Select(x => x(type)).FirstOrDefault(x => x != null), + type => (NamingConvention(context) ?? new Feature.NamingConvention[0]).Where(x => x != null).Select(x => x(type)).FirstOrDefault(x => x != null), name => (Behavior(context) ?? new Feature.Behavior[0]).Select(x => x(name)).FirstOrDefault(x => x.HasValue), typeof(TContext) != typeof(Default) ? FeatureConfiguration.For(Default.Context) : Feature.Configuration.Current); } diff --git a/Source/FeatureSwitcher.Contexteer/Configuration/IConfigureNamingFor.cs b/Source/FeatureSwitcher.Contexteer/Configuration/IConfigureNamingFor.cs index fcdd96c..6991237 100644 --- a/Source/FeatureSwitcher.Contexteer/Configuration/IConfigureNamingFor.cs +++ b/Source/FeatureSwitcher.Contexteer/Configuration/IConfigureNamingFor.cs @@ -15,6 +15,6 @@ public interface IConfigureNamingFor : IConfigureNaming /// /// The naming conventions to use. /// the extension point for features configuration in contexts of type . - IConfigureFeaturesFor Custom(Func namingConventions); + IConfigureFeaturesFor Custom(Func namingConventions); } } \ No newline at end of file diff --git a/Source/FeatureSwitcher.Specs/Domain/EnableByName.cs b/Source/FeatureSwitcher.Specs/Domain/EnableByName.cs index b57ddfa..aa06161 100644 --- a/Source/FeatureSwitcher.Specs/Domain/EnableByName.cs +++ b/Source/FeatureSwitcher.Specs/Domain/EnableByName.cs @@ -1,21 +1,11 @@ -using System; -using FeatureSwitcher.Configuration; - namespace FeatureSwitcher.Specs.Domain { - public class EnableByName + public static class EnableByName where T : IFeature { - public readonly static EnableByName Instance = new EnableByName(); - - public bool? IsEnabled(string feature) + public static bool? IsEnabled(Feature.Name name) { - return Features.OfType.EnabledByTypeName(feature); - } - - public string For(Type featureType) - { - return Features.OfType.NamedByTypeName(featureType); + return typeof(T).Name == name.Value ? true : (bool?)null; } } } \ No newline at end of file diff --git a/Source/FeatureSwitcher.Specs/When_behavior_is_not_configured_in_context_and_configured_general.cs b/Source/FeatureSwitcher.Specs/When_behavior_is_not_configured_in_context_and_configured_general.cs index 79d4206..957ed04 100644 --- a/Source/FeatureSwitcher.Specs/When_behavior_is_not_configured_in_context_and_configured_general.cs +++ b/Source/FeatureSwitcher.Specs/When_behavior_is_not_configured_in_context_and_configured_general.cs @@ -13,25 +13,25 @@ public class When_behavior_is_not_configured_in_context_and_configured_general : { Features.Are. ConfiguredBy.Custom( - EnableByName.Instance.IsEnabled, - EnableByName.Instance.IsEnabled, - EnableByName.Instance.IsEnabled).And. + EnableByName.IsEnabled, + EnableByName.IsEnabled, + EnableByName.IsEnabled).And. NamedBy.TypeName(); In.Contexts.FeaturesAre(). NamedBy.TypeFullName(); }; - Behaves_like> a_disabled_basic_feature; - Behaves_like> a_disabled_basic_feature_in_default; + Behaves_like> an_enabled_basic_feature; + Behaves_like> an_enabled_basic_feature_in_default; Behaves_like> a_disabled_basic_feature_in_headquarters; - Behaves_like> a_disabled_simple_feature; - Behaves_like> a_disabled_simple_feature_in_default; + Behaves_like> an_enabled_simple_feature; + Behaves_like> an_enabled_simple_feature_in_default; Behaves_like> an_enabled_feature_in_headquarters; - Behaves_like> a_disabled_complex_feature; - Behaves_like> a_disabled_complex_feature_in_default; + Behaves_like> an_enabled_complex_feature; + Behaves_like> an_enabled_complex_feature_in_default; Behaves_like> a_disabled_complex_feature_in_headquarters; } } \ No newline at end of file diff --git a/Source/FeatureSwitcher.Specs/When_chaining_application_configuration_and_partial_configurations.cs b/Source/FeatureSwitcher.Specs/When_chaining_application_configuration_and_partial_configurations.cs index 651e468..bbe5959 100644 --- a/Source/FeatureSwitcher.Specs/When_chaining_application_configuration_and_partial_configurations.cs +++ b/Source/FeatureSwitcher.Specs/When_chaining_application_configuration_and_partial_configurations.cs @@ -12,11 +12,11 @@ public class When_chaining_application_configuration_and_partial_configurations Features.Are .ConfiguredBy.Custom( new AppConfig(true).Features, - EnableByName.Instance.IsEnabled, + EnableByName.IsEnabled, new AppConfig(true).Default).And .NamedBy.Custom( - EnableByName.Instance.For, - Features.OfAnyType.NamedByTypeFullName); + Features.OfType.NamedByTypeName, + Features.OfType.NamedByTypeFullName); Behaves_like> a_disabled_basic_feature; Behaves_like> a_disabled_basic_feature_in_default; diff --git a/Source/FeatureSwitcher.Specs/When_chaining_multiple_partial_configurations.cs b/Source/FeatureSwitcher.Specs/When_chaining_multiple_partial_configurations.cs index ef24725..555cc19 100644 --- a/Source/FeatureSwitcher.Specs/When_chaining_multiple_partial_configurations.cs +++ b/Source/FeatureSwitcher.Specs/When_chaining_multiple_partial_configurations.cs @@ -9,8 +9,8 @@ namespace FeatureSwitcher.Specs public class When_chaining_multiple_partial_configurations : WithCleanUp { Establish ctx = () => Features.Are. - ConfiguredBy.Custom(EnableByName.Instance.IsEnabled, EnableByName.Instance.IsEnabled).And. - NamedBy.Custom(EnableByName.Instance.For, EnableByName.Instance.For); + ConfiguredBy.Custom(EnableByName.IsEnabled, EnableByName.IsEnabled).And. + NamedBy.Custom(Features.OfType.NamedByTypeName, Features.OfType.NamedByTypeName); Behaves_like> a_disabled_basic_feature; Behaves_like> a_disabled_basic_feature_in_default; diff --git a/Source/FeatureSwitcher.Specs/When_chaining_multiple_partial_configurations_and_contexts.cs b/Source/FeatureSwitcher.Specs/When_chaining_multiple_partial_configurations_and_contexts.cs index cc1801f..c435505 100644 --- a/Source/FeatureSwitcher.Specs/When_chaining_multiple_partial_configurations_and_contexts.cs +++ b/Source/FeatureSwitcher.Specs/When_chaining_multiple_partial_configurations_and_contexts.cs @@ -13,16 +13,16 @@ public class When_chaining_multiple_partial_configurations_and_contexts : WithCl Establish ctx = () => { Features.Are - .ConfiguredBy.Custom(EnableByName.Instance.IsEnabled, EnableByName.Instance.IsEnabled).And - .NamedBy.Custom(EnableByName.Instance.For, EnableByName.Instance.For); + .ConfiguredBy.Custom(EnableByName.IsEnabled, EnableByName.IsEnabled).And + .NamedBy.Custom(Features.OfType.NamedByTypeName, Features.OfType.NamedByTypeName); In.Contexts.FeaturesAre() - .AlwaysDisabled().And + .ConfiguredBy.Custom(Features.OfType.Disabled, Features.OfType.Disabled, Features.OfAnyType.Enabled).And .NamedBy.TypeFullName(); In.Contexts.FeaturesAre() - .ConfiguredBy.Custom(EnableByName.Instance.IsEnabled).And - .NamedBy.Custom(EnableByName.Instance.For); + .ConfiguredBy.Custom(EnableByName.IsEnabled).And + .NamedBy.Custom(Features.OfType.NamedByTypeName); }; Behaves_like> an_enabled_feature_simple; @@ -34,7 +34,7 @@ public class When_chaining_multiple_partial_configurations_and_contexts : WithCl Behaves_like> an_enabled_feature_basic_in_headquarters; Behaves_like> an_enabled_feature_complex; - Behaves_like> a_disabled_feature_complex_in_default; - Behaves_like> a_disabled_feature_complex_in_headquarters; + Behaves_like> an_enabled_feature_complex_in_default; + Behaves_like> an_enabled_feature_complex_in_headquarters; } } \ No newline at end of file diff --git a/Source/FeatureSwitcher.Specs/When_naming_is_not_configured_in_context_and_configured_general.cs b/Source/FeatureSwitcher.Specs/When_naming_is_not_configured_in_context_and_configured_general.cs index 7dc63dd..ccebf6b 100644 --- a/Source/FeatureSwitcher.Specs/When_naming_is_not_configured_in_context_and_configured_general.cs +++ b/Source/FeatureSwitcher.Specs/When_naming_is_not_configured_in_context_and_configured_general.cs @@ -14,7 +14,7 @@ public class When_naming_is_not_configured_in_context_and_configured_general : W Features.Are.NamedBy.TypeName(); In.Contexts.FeaturesAre(). - ConfiguredBy.Custom(EnableByName.Instance.IsEnabled); + ConfiguredBy.Custom(Features.OfType.Enabled); }; diff --git a/Source/FeatureSwitcher.Specs/When_using_partial_configuration.cs b/Source/FeatureSwitcher.Specs/When_using_partial_configuration.cs index a7c238e..8f12e1a 100644 --- a/Source/FeatureSwitcher.Specs/When_using_partial_configuration.cs +++ b/Source/FeatureSwitcher.Specs/When_using_partial_configuration.cs @@ -9,8 +9,8 @@ namespace FeatureSwitcher.Specs public class When_using_partial_configuration : WithCleanUp { Establish ctx = () => Features.Are. - ConfiguredBy.Custom(EnableByName.Instance.IsEnabled).And. - NamedBy.Custom(EnableByName.Instance.For); + ConfiguredBy.Custom(EnableByName.IsEnabled).And. + NamedBy.Custom(Features.OfType.NamedByTypeName); Behaves_like> a_disabled_basic_feature; Behaves_like> a_disabled_basic_feature_in_default; diff --git a/Source/FeatureSwitcher.Specs/When_using_partial_configuration_and_contexts.cs b/Source/FeatureSwitcher.Specs/When_using_partial_configuration_and_contexts.cs index 39012af..ca652db 100644 --- a/Source/FeatureSwitcher.Specs/When_using_partial_configuration_and_contexts.cs +++ b/Source/FeatureSwitcher.Specs/When_using_partial_configuration_and_contexts.cs @@ -13,16 +13,16 @@ public class When_using_partial_configuration_and_contexts : WithCleanUp Establish ctx = () => { Features.Are. - ConfiguredBy.Custom(EnableByName.Instance.IsEnabled).And. - NamedBy.Custom(EnableByName.Instance.For); + ConfiguredBy.Custom(EnableByName.IsEnabled).And. + NamedBy.Custom(Features.OfType.NamedByTypeName); In.Contexts.FeaturesAre(). - ConfiguredBy.Custom(EnableByName.Instance.IsEnabled).And. - NamedBy.Custom(EnableByName.Instance.For); + ConfiguredBy.Custom(EnableByName.IsEnabled).And. + NamedBy.Custom(Features.OfType.NamedByTypeName); In.Contexts.FeaturesAre(). - ConfiguredBy.Custom(EnableByName.Instance.IsEnabled).And. - NamedBy.Custom(EnableByName.Instance.For); + ConfiguredBy.Custom(EnableByName.IsEnabled).And. + NamedBy.Custom(Features.OfType.NamedByTypeName); }; Behaves_like> a_disabled_feature_basic; diff --git a/Source/FeatureSwitcher/Configuration/Features.ConfigurationBuilder.cs b/Source/FeatureSwitcher/Configuration/Features.ConfigurationBuilder.cs index d16047a..e8f269f 100644 --- a/Source/FeatureSwitcher/Configuration/Features.ConfigurationBuilder.cs +++ b/Source/FeatureSwitcher/Configuration/Features.ConfigurationBuilder.cs @@ -5,12 +5,12 @@ namespace FeatureSwitcher.Configuration public static partial class Features { /// - /// Builder for features configuration. + /// Builder for feature configuration. /// - public class ConfigurationBuilder : IConfigureFeatures, IConfigureNaming, IConfigureBehavior + private class ConfigurationBuilder : IConfigureFeatures, IConfigureNaming, IConfigureBehavior { private readonly Feature.Configuration _fallback; - private Feature.NameOf _namingConvention; + private Feature.NamingConvention _namingConvention; private Feature.Behavior _behavior; /// @@ -46,7 +46,7 @@ IConfigureBehavior IConfigureFeatures.ConfiguredBy get { return this; } } - IConfigureFeatures IConfigureNaming.Custom(params Feature.NameOf[] namingConventions) + IConfigureFeatures IConfigureNaming.Custom(params Feature.NamingConvention[] namingConventions) { _namingConvention = null; if (namingConventions != null) diff --git a/Source/FeatureSwitcher/Configuration/Features.OfAnyType.cs b/Source/FeatureSwitcher/Configuration/Features.OfAnyType.cs index 2859bd7..73a0468 100644 --- a/Source/FeatureSwitcher/Configuration/Features.OfAnyType.cs +++ b/Source/FeatureSwitcher/Configuration/Features.OfAnyType.cs @@ -1,3 +1,5 @@ +using System; + namespace FeatureSwitcher.Configuration { public static partial class Features @@ -8,28 +10,45 @@ public static partial class Features public static class OfAnyType { /// - /// Gets the behavior which enables any feature. + /// Enables any feature. /// - public static Feature.Behavior Enabled { get; private set; } + /// The name of the feature. + /// always true. + public static bool? Enabled(Feature.Name featureName) + { + return true; + } + /// - /// Gets the behavior which disables any feature. + /// Disables any feature. /// - public static Feature.Behavior Disabled { get; private set; } + /// The name of the feature. + /// always false. + public static bool? Disabled(Feature.Name featureName) + { + return false; + } + /// - /// Gets the naming convention which names any feature by name of the type. + /// Provides the name of the feature. + /// The value of the name is the name of . /// - public static Feature.NameOf NamedByTypeName { get; private set; } + /// The type of the feature. + /// the name of the feature. + public static Feature.Name NamedByTypeName(Type featureType) + { + return new Feature.Name(featureType, featureType.Name); + } + /// - /// Gets the naming convention which names any feature by full name of the type. + /// Provides the name of the feature. + /// The value of the name is the full name of . /// - public static Feature.NameOf NamedByTypeFullName { get; private set; } - - static OfAnyType() + /// The type of the feature. + /// the name of the feature. + public static Feature.Name NamedByTypeFullName(Type featureType) { - Enabled = name => true; - Disabled = name => false; - NamedByTypeName = type => type.Name; - NamedByTypeFullName = type => type.FullName; + return new Feature.Name(featureType, featureType.FullName); } } } diff --git a/Source/FeatureSwitcher/Configuration/Features.OfType.cs b/Source/FeatureSwitcher/Configuration/Features.OfType.cs index f2c3ee6..89970f9 100644 --- a/Source/FeatureSwitcher/Configuration/Features.OfType.cs +++ b/Source/FeatureSwitcher/Configuration/Features.OfType.cs @@ -1,48 +1,56 @@ +using System; + namespace FeatureSwitcher.Configuration { public static partial class Features { /// - /// Provides common behaviors and naming conventions for feature of type . + /// Provides common behaviors and naming conventions for features of type . /// /// The type of the feature. public static class OfType where T: IFeature { /// - /// Gets the behavior which enables the feature when its name matches the name of type . - /// - public static Feature.Behavior EnabledByTypeName { get; private set; } - /// - /// Gets the behavior which enables the feature when its name matches the full name of type . - /// - public static Feature.Behavior EnabledByTypeFullName { get; private set; } - /// - /// Gets the behavior which disables the feature when its name matches the name of type . + /// Enables the feature only when it's of type . /// - public static Feature.Behavior DisabledByTypeName { get; private set; } + /// The name of the feature. + /// true if feature is of type , null otherwise. + public static bool? Enabled(Feature.Name featureName) + { + return typeof(T) == featureName.Type ? true : (bool?)null; + } + /// - /// Gets the behavior which disables the feature when its name matches the full name of type . + /// Disables the feature only when it's of type . /// - public static Feature.Behavior DisabledByTypeFullName { get; private set; } + /// The name of the feature. + /// false if feature is of type , null otherwise. + public static bool? Disabled(Feature.Name featureName) + { + return typeof(T) == featureName.Type ? false : (bool?)null; + } + /// - /// Gets the naming convention which applies only to features of type and names it by the name of type . + /// Provides the name of the feature only if it's of type . + /// The value of the name is the name of type . /// - public static Feature.NameOf NamedByTypeName { get; private set; } + /// The type of the feature. + /// the name of the feature if it's of type , null otherwise. + public static Feature.Name NamedByTypeName(Type featureType) + { + return typeof(T) == featureType ? new Feature.Name(featureType, featureType.Name) : null; + } + /// - /// Gets the naming convention which applies only to features of type and names it by the full name of type . + /// Provides the name of the feature only if it's of type . + /// The value of the name is the full name of type . /// - public static Feature.NameOf NamedByTypeFullName { get; private set; } - - static OfType() + /// The type of the feature. + /// the name of the feature if it's of type , null otherwise. + public static Feature.Name NamedByTypeFullName(Type featureType) { - var featureType = typeof (T); - EnabledByTypeName = name => featureType.Name == name ? true : (bool?) null; - EnabledByTypeFullName = name => featureType.FullName == name ? true : (bool?) null; - DisabledByTypeName = name => featureType.Name != name ? true : (bool?) null; - DisabledByTypeFullName = name => featureType.FullName != name ? true : (bool?) null; - NamedByTypeName = type => featureType == type ? type.Name : null; - NamedByTypeFullName = type => featureType == type ? type.FullName : null; + return typeof(T) == featureType ? new Feature.Name(featureType, featureType.FullName) : null; } } } diff --git a/Source/FeatureSwitcher/Configuration/IConfigureNaming.cs b/Source/FeatureSwitcher/Configuration/IConfigureNaming.cs index 329aaec..f6b436c 100644 --- a/Source/FeatureSwitcher/Configuration/IConfigureNaming.cs +++ b/Source/FeatureSwitcher/Configuration/IConfigureNaming.cs @@ -10,6 +10,6 @@ public interface IConfigureNaming /// /// The naming conventions to use. /// the extension point for features configuration. - IConfigureFeatures Custom(params Feature.NameOf[] namingConventions); + IConfigureFeatures Custom(params Feature.NamingConvention[] namingConventions); } } \ No newline at end of file diff --git a/Source/FeatureSwitcher/Feature.Behavior.cs b/Source/FeatureSwitcher/Feature.Behavior.cs index e670df8..7417020 100644 --- a/Source/FeatureSwitcher/Feature.Behavior.cs +++ b/Source/FeatureSwitcher/Feature.Behavior.cs @@ -7,6 +7,6 @@ public static partial class Feature /// /// The name of the feature. /// true if feature is enabled, false if not, null if the state of the feature can't be determined. - public delegate bool? Behavior(string featureName); + public delegate bool? Behavior(Name featureName); } } \ No newline at end of file diff --git a/Source/FeatureSwitcher/Feature.Configuration.cs b/Source/FeatureSwitcher/Feature.Configuration.cs index 06cbc51..fb71a60 100644 --- a/Source/FeatureSwitcher/Feature.Configuration.cs +++ b/Source/FeatureSwitcher/Feature.Configuration.cs @@ -29,7 +29,7 @@ static Configuration() Provider = () => Default; } - private readonly NameOf _namingConvention; + private readonly NamingConvention _namingConvention; private readonly Behavior _behavior; private readonly Configuration _fallback; @@ -39,7 +39,7 @@ static Configuration() /// The naming convention to use. /// The behavior to use. /// The fallback configuration to use. - public Configuration(NameOf namingConvention, Behavior behavior, Configuration fallback) + public Configuration(NamingConvention namingConvention, Behavior behavior, Configuration fallback) { _namingConvention = namingConvention; _behavior = behavior; @@ -51,7 +51,7 @@ public Configuration(NameOf namingConvention, Behavior behavior, Configuration f /// /// Gets the naming convention for this configuration. /// - public NameOf NamingConvention + public NamingConvention NamingConvention { get { diff --git a/Source/FeatureSwitcher/Feature.Name.cs b/Source/FeatureSwitcher/Feature.Name.cs new file mode 100644 index 0000000..f1b4459 --- /dev/null +++ b/Source/FeatureSwitcher/Feature.Name.cs @@ -0,0 +1,34 @@ +using System; + +namespace FeatureSwitcher +{ + public static partial class Feature + { + /// + /// Represents the name of the feature. + /// + public class Name + { + /// + /// Constructs new feature name with specified and . + /// + /// The type of the feature. + /// The name determined by the naming convention. + public Name(Type type, string value) + { + Type = type; + Value = value; + } + + /// + /// Gets the type of the feature. + /// + public Type Type { get; private set; } + + /// + /// Gets the name of the feature determined by the naming convention. + /// + public string Value { get; private set; } + } + } +} \ No newline at end of file diff --git a/Source/FeatureSwitcher/Feature.NameOf.cs b/Source/FeatureSwitcher/Feature.NamingConvention.cs similarity index 85% rename from Source/FeatureSwitcher/Feature.NameOf.cs rename to Source/FeatureSwitcher/Feature.NamingConvention.cs index e0a847d..44f526e 100644 --- a/Source/FeatureSwitcher/Feature.NameOf.cs +++ b/Source/FeatureSwitcher/Feature.NamingConvention.cs @@ -9,6 +9,6 @@ public static partial class Feature /// /// The type of the feature. /// the name of the feature, null if the name of the feature can't be determined. - public delegate string NameOf(Type featureType); + public delegate Name NamingConvention(Type featureType); } } \ No newline at end of file diff --git a/Source/FeatureSwitcher/FeatureSwitcher.csproj b/Source/FeatureSwitcher/FeatureSwitcher.csproj index 81b22a6..bdeb5af 100644 --- a/Source/FeatureSwitcher/FeatureSwitcher.csproj +++ b/Source/FeatureSwitcher/FeatureSwitcher.csproj @@ -58,7 +58,10 @@ Feature.cs - + + Feature.cs + + Feature.cs