本文整理汇总了C#中Registry.RegisterInterceptor方法的典型用法代码示例。如果您正苦于以下问题:C# Registry.RegisterInterceptor方法的具体用法?C# Registry.RegisterInterceptor怎么用?C# Registry.RegisterInterceptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry.RegisterInterceptor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
/// <summary>
/// Processes types from an assembly for controllers and implements controller overriding behavior
/// </summary>
/// <param name="type">Type to process</param>
/// <param name="registry">Registry on which to register controllers</param>
public void Process(Type type, Registry registry)
{
// ensure the type is not null, registry isn't null and the type is a valid controller
if (registry == null || !IsValidController(type))
return;
var baseClass = type.BaseType;
// type must inherit from controller with same type name to be overriden.
// The type should be added as normal
// NOTE: this can be extended to be resolved by attribute or something of the sort
if (!IsValidController(baseClass) || !baseClass.Name.Equals(type.Name))
registry.AddType(typeof(IController), type);
else
{
registry.AddType(typeof(IController), baseClass);
registry.RegisterInterceptor(new TypeReplacementInterceptor(baseClass, type));
}
}
示例2: Process
public void Process(Type type, Registry registry)
{
if (type.IsConcreteAndAssignableTo(typeof(TypeInterceptor)))
registry.RegisterInterceptor((TypeInterceptor)Activator.CreateInstance(type));
}