示例#1
0
        protected void given_operation(string name, params Type[] parameters)
        {
            var method = (from m in Handler.GetMethods()
                          where m.InputMembers.Count() == parameters.Length && m.Name.EqualsOrdinalIgnoreCase(name)
                          let matchingParams =
                              (from parameter in m.InputMembers
                               from typeParameter in parameters
                               where parameter.Type.CompareTo(parameter.TypeSystem.FromClr(typeParameter)) == 0
                               select parameter).Count()
                              where parameters.Length == 0 || matchingParams == parameters.Length
                              select m).First();

            if (method.Owner != Handler)
            {
                throw new InvalidOperationException();
            }
            Operation = MethodBasedOperationCreator.CreateOperationDescriptor(method).Create();
        }
示例#2
0
        protected void given_operation <T>(Expression <Func <T, object> > method,
                                           IDependencyResolver resolver = null) where T : new()
        {
            var mi       = HandlerMethodVisitor.FindMethodInfo(method);
            var provider = resolver == null
        ? null
        : new SystemAndAttributesOperationInterceptorProvider(resolver.Resolve <IEnumerable <IOperationInterceptor> >);
            Func <IOperation, IEnumerable <IOperationInterceptor> > syncInterceptorProvider = null;

            if (provider != null)
            {
                syncInterceptorProvider = provider.GetInterceptors;
            }
            var asyncInterceptors = resolver == null
        ? Enumerable.Empty <IOperationInterceptorAsync>()
        : resolver.Resolve <IEnumerable <IOperationInterceptorAsync> >();

            Operation = MethodBasedOperationCreator
                        .CreateOperationDescriptor(
                TypeSystems.Default.From(mi),
                () => asyncInterceptors,
                syncInterceptorProvider, binderLocator: null, resolver: resolver).Create();
        }