public void InterceptionIsInherited() { PolicyList policies = new PolicyList(); MethodBase method = typeof(DerivedOneMethod).GetMethod("InterceptedMethod"); InterceptionReflector.Reflect <DerivedOneMethod>(policies, new StubObjectFactory()); IRemotingInterceptionPolicy policy = policies.Get <IRemotingInterceptionPolicy>(typeof(DerivedOneMethod)); Assert.Equal(1, policy.Count); Assert.Equal(1, policy[method].Count); Assert.IsType <RecordingHandler>(policy[method][0]); }
public void TwoAttributesOnOneMethod() { PolicyList policies = new PolicyList(); MethodBase method = typeof(OneMethodTwoAttributes).GetMethod("InterceptedMethod"); InterceptionReflector.Reflect <OneMethodTwoAttributes>(policies, new StubObjectFactory()); IRemotingInterceptionPolicy policy = policies.Get <IRemotingInterceptionPolicy>(typeof(OneMethodTwoAttributes)); Assert.Equal(1, policy.Count); Assert.Equal(2, policy[method].Count); Assert.IsType <RecordingHandler>(policy[method][0]); Assert.IsType <RecordingHandler>(policy[method][1]); }
public void CanAddHandlersInInheritedClass() { PolicyList policies = new PolicyList(); MethodBase method = typeof(DerivedWithAddedIntercepts).GetMethod("InterceptedMethod"); InterceptionReflector.Reflect <DerivedWithAddedIntercepts>(policies, new StubObjectFactory()); IRemotingInterceptionPolicy policy = policies.Get <IRemotingInterceptionPolicy>(typeof(DerivedWithAddedIntercepts)); Assert.Equal(1, policy.Count); Assert.Equal(2, policy[method].Count); Assert.IsType <RecordingHandler>(policy[method][0]); Assert.IsType <RecordingHandler>(policy[method][1]); }
public void TwoInterceptedMethods() { PolicyList policies = new PolicyList(); MethodBase method1 = typeof(TwoMethods).GetMethod("InterceptedMethod1"); MethodBase method2 = typeof(TwoMethods).GetMethod("InterceptedMethod2"); InterceptionReflector.Reflect <TwoMethods>(policies, new StubObjectFactory()); IRemotingInterceptionPolicy policy = policies.Get <IRemotingInterceptionPolicy>(typeof(TwoMethods)); Assert.Equal(2, policy.Count); Assert.Equal(1, policy[method1].Count); Assert.IsType <RecordingHandler>(policy[method1][0]); Assert.Equal(1, policy[method2].Count); Assert.IsType <RecordingHandler>(policy[method2][0]); }
public override object BuildUp(IBuilderContext context, object buildKey, object existing) { Type typeToBuild; if (TryGetTypeFromBuildKey(buildKey, out typeToBuild)) { Type originalType; if (!TryGetTypeFromBuildKey(context.OriginalBuildKey, out originalType)) { originalType = typeToBuild; } IRemotingInterceptionPolicy policy = context.Policies.Get <IRemotingInterceptionPolicy>(buildKey); if (existing != null && policy != null) { existing = RemotingInterceptor.Wrap(existing, originalType, policy); } } return(base.BuildUp(context, buildKey, existing)); }