public static bool InitParams(Type targetType, bool isStatic, MemberInfo[] infos, out ParametresDef parametres)
 {
     parametres = default(ParametresDef);
     if (targetType == null)
     {
         return(false);
     }
     parametres = new ParametresDef {
         paramDefinitions = new List <ParamDef>()
     };
     if (!isStatic)
     {
         parametres.resultDef = new ParamDef {
             paramMode = ParamMode.Undefined
         };
         parametres.instanceDef = new ParamDef
         {
             paramType = targetType,
             portName  = targetType.FriendlyName(),
             portId    = "Instance",
             paramMode = ParamMode.Instance
         };
     }
     for (var i = 0; i <= infos.Length - 1; i++)
     {
         var def = GetGetterDefFromInfo(infos[i]);
         if (def.paramMode != ParamMode.Undefined)
         {
             parametres.paramDefinitions.Add(def);
         }
     }
     return(true);
 }
        public static bool InitParams(MethodInfo method, out ParametresDef parametres)
        {
            parametres = new ParametresDef
            {
                paramDefinitions = new List <ParamDef>(),
                instanceDef      = new ParamDef {
                    paramMode = ParamMode.Undefined
                },
                resultDef = new ParamDef {
                    paramMode = ParamMode.Undefined
                }
            };
            if (method == null || method.ContainsGenericParameters || method.IsGenericMethodDefinition)
            {
                return(false);
            }
            var prms       = method.GetParameters();
            var returnType = method.ReturnType;

            if (!method.IsStatic)
            {
                parametres.instanceDef.paramType = method.DeclaringType;
                parametres.instanceDef.portName  = method.DeclaringType.FriendlyName();
                parametres.instanceDef.paramMode = ParamMode.Instance;
            }
            return(InitParams(prms, returnType, ref parametres));
        }
 public static bool InitParams(FieldInfo field, out ParametresDef parametres)
 {
     parametres = new ParametresDef
     {
         paramDefinitions = null,
         instanceDef      = new ParamDef {
             paramMode = ParamMode.Undefined
         },
         resultDef = new ParamDef {
             paramMode = ParamMode.Undefined
         },
     };
     if (field == null || field.FieldType.ContainsGenericParameters || field.FieldType.IsGenericTypeDefinition)
     {
         return(false);
     }
     if (!field.IsStatic)
     {
         parametres.instanceDef.paramMode = ParamMode.Instance;
         parametres.instanceDef.paramType = field.DeclaringType;
         parametres.instanceDef.portName  = field.DeclaringType.FriendlyName();
     }
     parametres.resultDef.paramMode = ParamMode.Result;
     parametres.resultDef.paramType = field.FieldType;
     parametres.resultDef.portName  = RETURN_VALUE_NAME;
     return(true);
 }
        private static bool InitParams(ParameterInfo[] prms, Type returnType, ref ParametresDef parametres)
        {
            bool valueNameIsUsed = false;

            for (int i = 0; i <= prms.Length - 1; i++)
            {
                var def = GetDefFromInfo(prms[i], i == prms.Length - 1);
                if (def.portName == RETURN_VALUE_NAME && !valueNameIsUsed)
                {
                    valueNameIsUsed = true;
                }
                if (parametres.instanceDef.paramMode != ParamMode.Undefined && def.portName == parametres.instanceDef.portName &&
                    (def.paramMode == ParamMode.In || def.paramMode == ParamMode.Ref || def.paramMode == ParamMode.Out))
                {
                    def.portId = def.portName + " ";
                }
                parametres.paramDefinitions.Add(def);
            }
            if (returnType != typeof(void))
            {
                parametres.resultDef.paramType = returnType;
                parametres.resultDef.portName  = RETURN_VALUE_NAME;
                parametres.resultDef.portId    = valueNameIsUsed? "*Value" : null;
                parametres.resultDef.paramMode = ParamMode.Result;
            }
            return(true);
        }
 protected bool Init(FieldInfo field, ParametresDef parametres)
 {
     if (field == null || field.FieldType.ContainsGenericParameters || field.FieldType.IsGenericTypeDefinition)
     {
         return(false);
     }
     instanceDef = parametres.instanceDef;
     resultDef   = parametres.resultDef;
     fieldInfo   = field;
     return(InitInternal(fieldInfo));
 }
 protected bool Init(MethodInfo method, ParametresDef parametres)
 {
     if (method == null || method.ContainsGenericParameters || method.IsGenericMethodDefinition)
     {
         return(false);
     }
     paramDefinitions = parametres.paramDefinitions == null ? new List <ParamDef>() : parametres.paramDefinitions;
     instanceDef      = parametres.instanceDef;
     resultDef        = parametres.resultDef;
     methodInfo       = method;
     return(InitInternal(method));
 }
 protected bool Init(ConstructorInfo constructor, ParametresDef parametres)
 {
     if (constructor == null || constructor.ContainsGenericParameters || constructor.IsGenericMethodDefinition)
     {
         return(false);
     }
     paramDefinitions = parametres.paramDefinitions == null ? new List <ParamDef>() : parametres.paramDefinitions;
     instanceDef      = parametres.instanceDef;
     resultDef        = parametres.resultDef;
     constructorInfo  = constructor;
     return(InitInternal(constructor));
 }
        public static bool InitParams(ConstructorInfo constructor, out ParametresDef parametres)
        {
            parametres = new ParametresDef
            {
                paramDefinitions = new List <ParamDef>(),
                instanceDef      = new ParamDef {
                    paramMode = ParamMode.Undefined
                },
                resultDef = new ParamDef {
                    paramMode = ParamMode.Undefined
                }
            };
            if (constructor == null || constructor.ContainsGenericParameters || constructor.IsGenericMethodDefinition)
            {
                return(false);
            }
            var prms       = constructor.GetParameters();
            var returnType = constructor.RTReflectedType();

            return(InitParams(prms, returnType, ref parametres));
        }
 protected bool Init(ParametresDef paramsDef, Type targetType)
 {
     Params     = paramsDef;
     TargetType = targetType;
     return(InitInternal());
 }