/src/LinFu.IoC.Common/FactoryAttribute.cs
C# | 39 lines | 15 code | 4 blank | 20 comment | 0 complexity | cc197604954bd4b1543d5818364c6143 MD5 | raw file
- using System;
- namespace LinFu.IoC.Configuration
- {
- /// <summary>
- /// An attribute that marks a type as a custom factory.
- /// </summary>
- [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
- public class FactoryAttribute : Attribute
- {
- /// <summary>
- /// The additional parameters supported by the custom factory.
- /// </summary>
- public Type[] ArgumentTypes;
- /// <summary>
- /// The service name that will be associated
- /// with the service type.
- /// </summary>
- public string ServiceName;
- /// <summary>
- /// Marks a target type as a custom factory
- /// that can create object instances that
- /// can implement the <paramref name="serviceType" />.
- /// </summary>
- /// <param name="serviceType">The service type to create.</param>
- public FactoryAttribute(Type serviceType)
- {
- ServiceType = serviceType;
- }
- /// <summary>
- /// Gets the service type that can be created
- /// using the factory instance.
- /// </summary>
- public Type ServiceType { get; }
- }
- }