Skip to content

Commit

Permalink
Attribute filtering related renames.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmg committed Jan 3, 2017
1 parent 340db3a commit 9753b92
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace Autofac.Features.AttributeFilters
/// <para>
/// When registering your components, the associated key on the
/// dependencies will be used. Be sure to specify the
/// <see cref="RegistrationExtensions.WithAttributeFilter{TLimit, TReflectionActivatorData, TStyle}" />
/// <see cref="RegistrationExtensions.WithAttributeFiltering{TLimit, TReflectionActivatorData, TStyle}" />
/// extension on the type with the filtered constructor parameters.
/// </para>
/// <code lang="C#">
Expand All @@ -97,13 +97,13 @@ namespace Autofac.Features.AttributeFilters
/// </code>
/// </example>
[SuppressMessage("Microsoft.Design", "CA1018:MarkAttributesWithAttributeUsage", Justification = "Allowing the inherited AttributeUsageAttribute to be used avoids accidental override or conflict at this level.")]
public sealed class WithKeyAttribute : ParameterFilterAttribute
public sealed class KeyFilterAttribute : ParameterFilterAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="WithKeyAttribute"/> class.
/// Initializes a new instance of the <see cref="KeyFilterAttribute"/> class.
/// </summary>
/// <param name="key">The key that the dependency should have in order to satisfy the parameter.</param>
public WithKeyAttribute(object key)
public KeyFilterAttribute(object key)
{
Key = key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace Autofac.Features.AttributeFilters
/// </code>
/// <para>
/// When registering your components, the associated metadata on the dependencies will be used.
/// Be sure to specify the <see cref="RegistrationExtensions.WithAttributeFilter{TLimit, TReflectionActivatorData, TStyle}" />
/// Be sure to specify the <see cref="RegistrationExtensions.WithAttributeFiltering{TLimit, TReflectionActivatorData, TStyle}" />
/// extension on the type with the filtered constructor parameters.
/// </para>
/// <code lang="C#">
Expand All @@ -100,18 +100,18 @@ namespace Autofac.Features.AttributeFilters
/// </code>
/// </example>
[SuppressMessage("Microsoft.Design", "CA1018:MarkAttributesWithAttributeUsage", Justification = "Allowing the inherited AttributeUsageAttribute to be used avoids accidental override or conflict at this level.")]
public sealed class WithMetadataAttribute : ParameterFilterAttribute
public sealed class MetadataFilterAttribute : ParameterFilterAttribute
{
private static readonly MethodInfo FilterOneMethod = typeof(WithMetadataAttribute).GetTypeInfo().GetDeclaredMethod(nameof(FilterOne));
private static readonly MethodInfo FilterOneMethod = typeof(MetadataFilterAttribute).GetTypeInfo().GetDeclaredMethod(nameof(FilterOne));

private static readonly MethodInfo FilterAllMethod = typeof(WithMetadataAttribute).GetTypeInfo().GetDeclaredMethod(nameof(FilterAll));
private static readonly MethodInfo FilterAllMethod = typeof(MetadataFilterAttribute).GetTypeInfo().GetDeclaredMethod(nameof(FilterAll));

/// <summary>
/// Initializes a new instance of the <see cref="WithMetadataAttribute"/> class.
/// Initializes a new instance of the <see cref="MetadataFilterAttribute"/> class.
/// </summary>
/// <param name="key">The metadata key that the dependency should have in order to satisfy the parameter.</param>
/// <param name="value">The metadata value that the dependency should have in order to satisfy the parameter.</param>
public WithMetadataAttribute(string key, object value)
public MetadataFilterAttribute(string key, object value)
{
Key = key;
Value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ namespace Autofac.Features.AttributeFilters
/// <para>
/// Implementations of this attribute can be used to mark constructor parameters
/// so filtering can be done based on registered service data. For example, the
/// <see cref="WithMetadataAttribute"/> allows constructor
/// <see cref="MetadataFilterAttribute"/> allows constructor
/// parameters to be filtered by registered metadata criteria and the
/// <see cref="WithKeyAttribute"/> allows constructor
/// <see cref="KeyFilterAttribute"/> allows constructor
/// parameters to be filtered by a keyed service registration.
/// </para>
/// <para>
/// If a type uses these attributes, it should be registered with Autofac
/// using the
/// <see cref="RegistrationExtensions.WithAttributeFilter{TLimit, TReflectionActivatorData, TStyle}" />
/// <see cref="RegistrationExtensions.WithAttributeFiltering{TLimit, TReflectionActivatorData, TStyle}" />
/// extension to enable the behavior.
/// </para>
/// <para>
/// For specific attribute usage examples, see the attribute documentation.
/// </para>
/// </remarks>
/// <seealso cref="WithMetadataAttribute"/>
/// <seealso cref="WithKeyAttribute"/>
/// <seealso cref="MetadataFilterAttribute"/>
/// <seealso cref="KeyFilterAttribute"/>
[AttributeUsage(AttributeTargets.Parameter)]
public abstract class ParameterFilterAttribute : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public static class RegistrationExtensions
/// <para>
/// Apply this extension to component registrations that use attributes
/// that derive from the <see cref="ParameterFilterAttribute"/>
/// like the <see cref="WithMetadataAttribute"/>
/// like the <see cref="MetadataFilterAttribute"/>
/// in their constructors. Doing so will allow the attribute-based filtering to occur. See
/// <see cref="WithMetadataAttribute"/> for an
/// <see cref="MetadataFilterAttribute"/> for an
/// example on how to use the filter and attribute together.
/// </para>
/// </remarks>
/// <seealso cref="WithMetadataAttribute"/>
/// <seealso cref="MetadataFilterAttribute"/>
public static IRegistrationBuilder<TLimit, TReflectionActivatorData, TRegistrationStyle>
WithAttributeFilter<TLimit, TReflectionActivatorData, TRegistrationStyle>(
WithAttributeFiltering<TLimit, TReflectionActivatorData, TRegistrationStyle>(
this IRegistrationBuilder<TLimit, TReflectionActivatorData, TRegistrationStyle> builder)
where TReflectionActivatorData : ReflectionActivatorData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void MultipleFilterTypesCanBeUsedOnOneComponent()
.Keyed<ILogger>("Other");

builder.RegisterType<SolutionExplorerMixed>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand All @@ -58,7 +58,7 @@ public void KeyFilterIsAppliedOnConstructorDependencySingle()
.Keyed<ILogger>("Other");

builder.RegisterType<SolutionExplorerKeyed>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();
var explorer = container.Resolve<SolutionExplorerKeyed>();
Expand All @@ -81,7 +81,7 @@ public void KeyFilterIsAppliedOnConstructorDependencyMultiple()
.Keyed<IAdapter>("Other");

builder.RegisterType<SolutionExplorerKeyed>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand All @@ -105,7 +105,7 @@ public void KeyFilterIsAppliedOnConstructorDependencySingleWithLazy()
.Keyed<ILogger>("Other");

builder.RegisterType<ManagerWithLazySingle>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();
var resolved = container.Resolve<ManagerWithLazySingle>();
Expand All @@ -125,7 +125,7 @@ public void KeyFilterIsAppliedOnConstructorDependencySingleWithMeta()
.Keyed<ILogger>("Other");

builder.RegisterType<ManagerWithMetaSingle>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand All @@ -146,7 +146,7 @@ public void KeyFilterIsAppliedOnConstructorDependencySingleWithOwned()
.Keyed<ILogger>("Other");

builder.RegisterType<ManagerWithOwnedSingle>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand All @@ -170,7 +170,7 @@ public void KeyFilterIsAppliedOnConstructorDependencyManyWithLazy()
.Keyed<ILogger>("Other");

builder.RegisterType<ManagerWithLazyMany>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand All @@ -194,7 +194,7 @@ public void KeyFilterIsAppliedOnConstructorDependencyManyWithMeta()
.Keyed<ILogger>("Other");

builder.RegisterType<ManagerWithMetaMany>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand All @@ -217,7 +217,7 @@ public void KeyFilterIsAppliedOnConstructorDependencyManyWithOwned()
.Keyed<ILogger>("Other");

builder.RegisterType<ManagerWithOwnedMany>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand All @@ -240,7 +240,7 @@ public void MetadataFilterIsAppliedOnConstructorDependencySingle()
.As<ILogger>();

builder.RegisterType<SolutionExplorerMetadata>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand All @@ -266,7 +266,7 @@ public void MetadataFilterIsAppliedOnConstructorDependencyMultiple()
.WithMetadata<AdapterMetadata>(m => m.For(am => am.Target, "Other"))
.As<IAdapter>();

builder.RegisterType<SolutionExplorerMetadata>().WithAttributeFilter();
builder.RegisterType<SolutionExplorerMetadata>().WithAttributeFiltering();

var container = builder.Build();

Expand Down Expand Up @@ -300,7 +300,7 @@ public void ComponentsThatAreNotUsedDoNotGetActivated()
.OnActivating(h => adapterActivationCount++);

builder.RegisterType<SolutionExplorerMetadata>()
.WithAttributeFilter();
.WithAttributeFiltering();

var container = builder.Build();

Expand Down Expand Up @@ -343,7 +343,7 @@ public class ToolWindowAdapter : IAdapter

public class ManagerWithLazySingle
{
public ManagerWithLazySingle([WithKey("Manager")] Lazy<ILogger> logger)
public ManagerWithLazySingle([KeyFilter("Manager")] Lazy<ILogger> logger)
{
Logger = logger;
}
Expand All @@ -353,7 +353,7 @@ public ManagerWithLazySingle([WithKey("Manager")] Lazy<ILogger> logger)

public class ManagerWithMetaSingle
{
public ManagerWithMetaSingle([WithKey("Manager")] Meta<ILogger, EmptyMetadata> logger)
public ManagerWithMetaSingle([KeyFilter("Manager")] Meta<ILogger, EmptyMetadata> logger)
{
Logger = logger;
}
Expand All @@ -363,7 +363,7 @@ public ManagerWithMetaSingle([WithKey("Manager")] Meta<ILogger, EmptyMetadata> l

public class ManagerWithOwnedSingle
{
public ManagerWithOwnedSingle([WithKey("Manager")] Owned<ILogger> logger)
public ManagerWithOwnedSingle([KeyFilter("Manager")] Owned<ILogger> logger)
{
Logger = logger;
}
Expand All @@ -373,7 +373,7 @@ public ManagerWithOwnedSingle([WithKey("Manager")] Owned<ILogger> logger)

public class ManagerWithLazyMany
{
public ManagerWithLazyMany([WithKey("Manager")] IEnumerable<Lazy<ILogger>> loggers)
public ManagerWithLazyMany([KeyFilter("Manager")] IEnumerable<Lazy<ILogger>> loggers)
{
Loggers = loggers;
}
Expand All @@ -383,7 +383,7 @@ public ManagerWithLazyMany([WithKey("Manager")] IEnumerable<Lazy<ILogger>> logge

public class ManagerWithMetaMany
{
public ManagerWithMetaMany([WithKey("Manager")] IEnumerable<Meta<ILogger, EmptyMetadata>> loggers)
public ManagerWithMetaMany([KeyFilter("Manager")] IEnumerable<Meta<ILogger, EmptyMetadata>> loggers)
{
Loggers = loggers;
}
Expand All @@ -393,7 +393,7 @@ public ManagerWithMetaMany([WithKey("Manager")] IEnumerable<Meta<ILogger, EmptyM

public class ManagerWithOwnedMany
{
public ManagerWithOwnedMany([WithKey("Manager")] IEnumerable<Owned<ILogger>> loggers)
public ManagerWithOwnedMany([KeyFilter("Manager")] IEnumerable<Owned<ILogger>> loggers)
{
Loggers = loggers;
}
Expand All @@ -404,8 +404,8 @@ public ManagerWithOwnedMany([WithKey("Manager")] IEnumerable<Owned<ILogger>> log
public class SolutionExplorerKeyed
{
public SolutionExplorerKeyed(
[WithKey("Solution")] IEnumerable<IAdapter> adapters,
[WithKey("Solution")] ILogger logger)
[KeyFilter("Solution")] IEnumerable<IAdapter> adapters,
[KeyFilter("Solution")] ILogger logger)
{
Adapters = adapters.ToList();
Logger = logger;
Expand All @@ -419,8 +419,8 @@ public SolutionExplorerKeyed(
public class SolutionExplorerMetadata
{
public SolutionExplorerMetadata(
[WithMetadata("Target", "Solution")] IEnumerable<IAdapter> adapters,
[WithMetadata("LoggerName", "Solution")] ILogger logger)
[MetadataFilter("Target", "Solution")] IEnumerable<IAdapter> adapters,
[MetadataFilter("LoggerName", "Solution")] ILogger logger)
{
Adapters = adapters.ToList();
Logger = logger;
Expand All @@ -434,8 +434,8 @@ public SolutionExplorerMetadata(
public class SolutionExplorerMixed
{
public SolutionExplorerMixed(
[WithMetadata("Target", "Solution")] IEnumerable<IAdapter> adapters,
[WithKey("Solution")] ILogger logger)
[MetadataFilter("Target", "Solution")] IEnumerable<IAdapter> adapters,
[KeyFilter("Solution")] ILogger logger)
{
Adapters = adapters.ToList();
Logger = logger;
Expand Down

0 comments on commit 9753b92

Please sign in to comment.