Exemplo n.º 1
0
 private void IsolateParameters(MethodInfo methodInfo)
 {
     Parameters = methodInfo.GetParameters()
                  .Select(p => {
         var proceedFunctionType = StaticAnalysis.ExtractProceedFunctionType(p.ParameterType);
         if (proceedFunctionType != null)
         {
             TransformsScopeTo = proceedFunctionType;
             return(new ProceedParameter()
             {
                 Name = p.Name,
                 Type = p.ParameterType,
                 TransformsTo = proceedFunctionType
             });
         }
         else
         {
             return(new StatementParameter()
             {
                 Name = p.Name, Type = p.ParameterType
             });
         }
     })
                  .ToList();
 }
Exemplo n.º 2
0
 public StatementSet FromAssembly(Assembly assembly)
 {
     foreach (var t in assembly.GetTypes()
              .Where(x => !x.IsAbstract &&
                     StaticAnalysis.IsStatementController(x)))
     {
         FromController(t);
     }
     return(this);
 }
Exemplo n.º 3
0
            private void PrecacheReflections(Type controllerType)
            {
                var defaultConstructor = controllerType.GetConstructors().FirstOrDefault(x => x.GetParameters().Length == 0);

                if (defaultConstructor == null)
                {
                    throw new ArgumentException("StatementHandler " + controllerType.Name + " does not have a default constructor");
                }
                activator = FastFlect.GetActivator(defaultConstructor);
                delegateForScopeSetter       = controllerType.DelegateForSetPropertyValue("Scope");
                delegateForContextSetter     = controllerType.DelegateForSetPropertyValue("Context");
                delegateForAttachmentsSetter = controllerType.DelegateForSetPropertyValue("Attachments");
                delegateForTracerSetter      = controllerType.DelegateForSetPropertyValue("Tracer");
                delegateForInvokation        = definition.MethodInfo.DelegateForCallMethod();
                if (definition.TransformsScopeTo != null)
                {
                    scopeConverter        = StaticAnalysis.CreateConverter(definition.TransformsScopeTo);
                    transformsToValueType = definition.TransformsScopeTo.IsValueType;
                }
            }