using System;
using UnityEngine;
namespace Framework.Services {
/// Selects a default binding for a dependency-injected parameter
[
AttributeUsage(
AttributeTargets.Parameter | AttributeTargets.Interface,
Inherited = false,
AllowMultiple = false
)
]
public class DefaultBindingAttribute : Attribute {
/// Initializes a new default binding attribute
///
/// Type that provides the implementation for the service
///
public DefaultBindingAttribute(Type serviceImplementationType) {
this.serviceImplementationType = serviceImplementationType;
}
/// Initializes a new default binding attribute
///
/// Name of the type that provides the implementation for the service
///
public DefaultBindingAttribute(string serviceImplementationTypeName) {
this.serviceImplementationTypeName = serviceImplementationTypeName;
}
/// Type that is providing the implementation for the service parameter
public Type ServiceImplementationType {
get {
if(this.serviceImplementationType == null) {
this.serviceImplementationType = Type.GetType(this.serviceImplementationTypeName);
}
return this.serviceImplementationType;
}
}
/// Type that is providing the implementation for the service parameter
private Type serviceImplementationType;
/// Name of the type that is providing the service implementation
private string serviceImplementationTypeName;
}
} // namespace Framework.Services