private void ApplyMethodInjectors(ExpressionBuildingEventArgs e, MethodInfo[] methods) { foreach (var method in methods) { this.ApplyMethodInjector(e, method); } }
void Intercept(object sender, ExpressionBuildingEventArgs e) { if (AspectUtility.IsDecorated(e.KnownImplementationType, Proxy.Configuration)) { e.Expression = Expression.Convert( Expression.Invoke(Expression.Constant(_createProxy), e.Expression), e.RegisteredServiceType); } }
private static void AddKnownRelationships(ExpressionBuildingEventArgs e, InstanceProducer[] dependencies) { var relationships = from dependency in dependencies select new KnownRelationship(e.KnownImplementationType, e.Lifestyle, dependency); foreach (KnownRelationship relationship in relationships) { e.KnownRelationships.Add(relationship); } }
public void ExpressionBuildingEventArgsExpressionProperty_SetWithNullReference_ThrowsArgumentNullException() { // Arrange var eventArgs = new ExpressionBuildingEventArgs( typeof(IPlugin), typeof(PluginImpl), Expression.Constant(new PluginImpl()), Lifestyle.Transient); // Act eventArgs.Expression = null; }
private static void ReplaceExpression(ExpressionBuildingEventArgs e, MethodInfo method, InstanceProducer[] dependencies) { Delegate injectorDelegate = BuildInjectorDelegate(e.KnownImplementationType, method); var dependencyExpressions = from dependency in dependencies select dependency.BuildExpression(); var parameters = (new Expression[] { e.Expression }).Concat(dependencyExpressions); e.Expression = Expression.Invoke(Expression.Constant(injectorDelegate), parameters); }
private void ApplyMethodInjector(ExpressionBuildingEventArgs e, MethodInfo method) { VerifyMethod(method); var dependencies = ( from parameter in method.GetParameters() select this.container.GetRegistration(parameter.ParameterType, throwOnFailure: true)) .ToArray(); ReplaceExpression(e, method, dependencies); AddKnownRelationships(e, dependencies); }
public void ExpressionBuildingEventArgsExpressionProperty_SetWithNullReference_ThrowsArgumentNullException() { // Arrange var eventArgs = new ExpressionBuildingEventArgs( typeof(PluginImpl), Expression.Constant(new PluginImpl()), Lifestyle.Transient, new Collection <KnownRelationship>()); // Act Action action = () => eventArgs.Expression = null; // Assert AssertThat.Throws <ArgumentNullException>(action); }
internal void ExpressionBuilding(object sender, ExpressionBuildingEventArgs e) { var methods = this.GetMethodsToInject(e.KnownImplementationType); this.ApplyMethodInjectors(e, methods); }
public ProfileData(ExpressionBuildingEventArgs info, TimeSpan elapsed) { this.Info = info; this.Elapsed = elapsed; }