private T GetInstance <T>() { _deployer.Deploy(); var component = _manager.GetComponent(typeof(T)); return((T)_manager.GetReference(component, _manager.CreateCreationalContext(component))); }
public InterceptorMethodHandler(WeldComponentManager manager, MethodInfo method, Interceptor[] interceptors, ICreationalContext creationalContext) { _interceptorReferences = new LinkedList <IAroundInvokeInterceptor>( interceptors.Select(x => manager.GetReference(x, creationalContext)) .Cast <IAroundInvokeInterceptor>()); _bindingsLazy = new Lazy <IEnumerable <IInterceptorBinding> >(() => method.GetAnnotations().OfType <IInterceptorBinding>().ToArray()); var returnType = method.ReturnType; if (returnType == typeof(Task)) { _isAsync = true; _taskCaster = TaskCasters.ForVoid(); } else if (returnType.IsGenericType) { var genericType = returnType.GetGenericTypeDefinition(); if (genericType == typeof(Task <>)) { _isAsync = true; _taskCaster = TaskCasters.ForType(returnType.GetGenericArguments()[0]); } } }
public void FieldCircularDependencyShouldBeAllowed() { _deployer.AddTypes(typeof(One), typeof(Two)); _deployer.Deploy(); var component = _manager.GetComponent(typeof(One)); var instance = (One)_manager.GetReference(component, _manager.CreateCreationalContext(component)); Assert.AreEqual(instance, instance.two.one); }