PropertyKey
Represents a property key.
using Castle.Core;
using System;
namespace Castle.MicroKernel.Registration
{
public class PropertyKey
{
private readonly object key;
public object Key => key;
internal PropertyKey(object key)
{
this.key = key;
}
public Property Eq(object value)
{
return new Property(key, value);
}
public ServiceOverride Is(string componentName)
{
return GetServiceOverrideKey().Eq(componentName);
}
public ServiceOverride Is(Type componentImplementation)
{
if (componentImplementation == (Type)null)
throw new ArgumentNullException("componentImplementation");
return GetServiceOverrideKey().Eq(ComponentName.DefaultNameFor(componentImplementation));
}
public ServiceOverride Is<TComponentImplementation>()
{
return Is(typeof(TComponentImplementation));
}
private ServiceOverrideKey GetServiceOverrideKey()
{
if (key is Type)
return ServiceOverride.ForKey((Type)key);
return ServiceOverride.ForKey((string)key);
}
}
}