本文整理汇总了C#中IInterceptor类的典型用法代码示例。如果您正苦于以下问题:C# IInterceptor类的具体用法?C# IInterceptor怎么用?C# IInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IInterceptor类属于命名空间,在下文中一共展示了IInterceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectMethodInterceptors
private IInterceptor[] SelectMethodInterceptors(IInterceptorSelector selector,
IInterceptor[] methodInterceptors,
Type targetType)
{
return methodInterceptors ??
selector.SelectInterceptors(targetType, Method, interceptors) ??
new IInterceptor[0];
}
示例2: SelectInterceptors
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
if (method.IsAddMethod()) return interceptors.Where(x => x is ListAddInterceptor).ToArray();
if (method.IsSetMethod()) return interceptors.Where(x => x is ListSetInterceptor).ToArray();
if (method.IsRemoveMethod()) return interceptors.Where(x => x is ListRemoveInterceptor).ToArray();
return new IInterceptor[0];
}
示例3: SelectInterceptors
/// <summary>Select interceptors which must be applied to the method.</summary>
/// <param name="type">The type.</param>
/// <param name="method">The method.</param>
/// <param name="interceptors">The interceptors.</param>
/// <returns>The interceptors after filtering.</returns>
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
if (method.IsGetter())
{
var propertyInfo = type.GetProperty(method);
if (propertyInfo.IsPropertyWithSelectorAttribute())
{
return typeof(BaseHtmlElement).IsAssignableFrom(method.ReturnType)
? interceptors.Where(x => x is PropertyInterceptor).ToArray()
: interceptors.Where(x => x is CollectionPropertyInterceptor).ToArray();
}
}
if (method.IsSetter())
{
var propertyInfo = type.GetProperty(method);
if (propertyInfo.IsPropertyWithSelectorAttribute())
{
return interceptors.Where(x => x is InvalidWriteOperationInterceptor).ToArray();
}
}
return interceptors.Where(x => !(x is PropertyInterceptor)
&& !(x is CollectionPropertyInterceptor)
&& !(x is InvalidWriteOperationInterceptor)).ToArray();
}
示例4: Invocation
protected Invocation(object proxy, MethodInfo proxiedMethod, object[] arguments, IInterceptor[] interceptors)
{
_proxy = proxy;
_proxiedMethod = proxiedMethod;
_arguments = arguments;
_interceptors = interceptors ?? new IInterceptor[0];
}
示例5: InterceptionContext
public InterceptionContext(IInterceptor[] interceptors)
{
//if (interceptors != null)
{
_interceptors = new List<IInterceptor>(interceptors);
}
}
示例6: SelectInterceptors
/// <summary>
/// The select interceptors.
/// </summary>
/// <param name="type">
/// The type.
/// </param>
/// <param name="method">
/// The method.
/// </param>
/// <param name="interceptors">
/// The interceptors.
/// </param>
/// <returns>
/// The <see cref="IInterceptor[]" />.
/// </returns>
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
string name = method.Name;
if (method.IsSpecialName)
{
if (name.StartsWith(AopConstants.PropertyGetter, StringComparison.Ordinal)) name = name.Remove(0, AopConstants.PropertyGetter.Length);
if (name.StartsWith(AopConstants.PropertySetter, StringComparison.Ordinal)) name = name.Remove(0, AopConstants.PropertySetter.Length);
if (name.StartsWith(AopConstants.EventAdder, StringComparison.Ordinal)) name = name.Remove(0, AopConstants.EventAdder.Length);
if (name.StartsWith(AopConstants.EventRemover, StringComparison.Ordinal)) name = name.Remove(0, AopConstants.EventRemover.Length);
}
return interceptors.Where(
inter =>
{
var sinter = inter as ISpecificInterceptor;
if (sinter != null)
{
return sinter.Name == name ||
sinter.Name == AopConstants.InternalUniversalInterceptorName;
}
return true;
}).OrderBy(
inter =>
{
var sinter = inter as ISpecificInterceptor;
return sinter == null ? 0 : sinter.Order;
}).ToArray();
}
示例7: MockingProxy
public MockingProxy(MarshalByRefObject wrappedInstance, IInterceptor interceptor, IMockMixin mockMixin)
: base(wrappedInstance.GetType())
{
this.WrappedInstance = wrappedInstance;
this.interceptor = interceptor;
this.mockMixin = mockMixin;
}
示例8:
IInterceptor[] IInterceptorSelector.SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
if (interceptors.Length == 0)
return interceptors;
var markers = new List<MarkerBaseAttribute>();
if (type != null)
markers.AddRange(type.GetCustomAttributes(typeof(MarkerBaseAttribute), true).Cast<MarkerBaseAttribute>());
if (method != null)
markers.AddRange(method.GetCustomAttributes(typeof(MarkerBaseAttribute), true).Cast<MarkerBaseAttribute>());
if (markers.Count == 0) // no marker attributes found, no ordering required
return interceptors;
markers.Sort((a, b) => a.Order.CompareTo(b.Order));
var sorted = new List<IInterceptor>();
for (int i = 0; i < markers.Count; ++i)
{
var providers = interceptors.OfType<IInterceptorMarkerProvider>();
var markerType = markers[i].GetType();
var matchingInterceptor = providers.FirstOrDefault(x => x.MarkerType == markerType) as IInterceptor;
if (matchingInterceptor != null)
sorted.Add(matchingInterceptor);
}
return sorted.ToArray();
}
示例9: SessionProvider
public SessionProvider(IConfigurationBuilder builder, IInterceptor interceptor, IWebContext webContext)
{
nhSessionFactory = builder.BuildSessionFactory();
Debug.WriteLine("Built Session Factory " + DateTime.Now);
this.webContext = webContext;
this.interceptor = interceptor;
}
示例10: RegistrationActivating
/// <summary>
/// Registrations the activating.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="Autofac.Core.ActivatingEventArgs<System.Object>"/> instance containing the event data.</param>
private static void RegistrationActivating(object sender, ActivatingEventArgs<object> e)
{
// Ignore AspectConfiguration and IInterceptor types since they're being referenced via the Autofac
// registration context. Otherwise calling e.Context.Resolve<IInterceptor> will fail when
// the code below executes.
if (e.Instance.GetType() == typeof (MasterProxy) || e.Instance is IInterceptor)
{
return;
}
var proxy = (MasterProxy)e.Context.Resolve(typeof(MasterProxy));
if (!e.Instance.IsDecorated(proxy.Configuration))
{
return;
}
var pseudoList = new IInterceptor[proxy.Configuration.Interceptors.Count];
pseudoList[0] = proxy;
for (var i = 1; i < pseudoList.Length; i++)
{
pseudoList[i] = new PseudoInterceptor();
}
var interfaceTypes = e.Instance.GetType().GetInterfaces();
var targetInterface =
interfaceTypes.FirstMatch(proxy.Configuration.Namespaces);
e.Instance = new ProxyGenerator().CreateInterfaceProxyWithTargetInterface(targetInterface, e.Instance, pseudoList);
}
示例11: PostProcess
public void PostProcess(IServiceRequestResult result)
{
var instance = result.ActualResult;
var instanceTypeName = instance.GetType().FullName;
// Ignore any LinFu factories or Snap-specific instances.
if (instanceTypeName.Contains("LinFu.") || instanceTypeName == "Snap.AspectConfiguration"
|| instanceTypeName == "Snap.IMasterProxy" || instanceTypeName == "Snap.MasterProxy")
{
return;
}
var proxy = result.Container.GetService<IMasterProxy>();
if (!instance.IsDecorated(proxy.Configuration))
{
return;
}
var pseudoList = new IInterceptor[proxy.Configuration.Interceptors.Count];
pseudoList[0] = proxy;
for (var i = 1; i < pseudoList.Length; i++)
{
pseudoList[i] = new PseudoInterceptor();
}
var interfaceTypes = instance.GetType().GetInterfaces();
var targetInterface =
interfaceTypes.FirstMatch(proxy.Configuration.Namespaces);
result.ActualResult = new ProxyGenerator().CreateInterfaceProxyWithTargetInterface(targetInterface, instance, pseudoList);
}
示例12: Add
/// <summary>
/// Add the interceptor in the argument as the first interceptor
/// and set its next to the interceptor that we have. In the first
/// execution it will be the TailInterceptor.
/// </summary>
/// <param name="interceptor"></param>
public virtual void Add(IInterceptor interceptor)
{
AssertUtil.ArgumentNotNull(interceptor, "interceptor");
interceptor.Next = m_interceptor;
m_interceptor = interceptor;
}
示例13: SelectInterceptors
public IInterceptor[] SelectInterceptors(Type type, System.Reflection.MethodInfo method, IInterceptor[] interceptors)
{
if (method.Name == "FunA")
return interceptors;
return new IInterceptor[0];
// ...
}
示例14: GetProxy
public virtual object GetProxy(Type type, IInterceptor interceptor)
{
if (cache.ContainsKey(type))
return cache[type];
cache[type] = CreateProxy(interceptor, type);
return cache[type];
}
示例15: SelectInterceptors
public IInterceptor[] SelectInterceptors( Type type, MethodInfo method, IInterceptor[] interceptors )
{
if( method.Name.StartsWith( "set_" ) )
return interceptors;
return null;
}