Beispiel #1
0
        private void LoadParameter()
        {
            DescriptionAttribute da = mMethod.GetCustomAttribute <DescriptionAttribute>(false);

            if (da != null)
            {
                this.Remark = da.Description;
            }
            foreach (System.Reflection.ParameterInfo pi in mMethod.GetParameters())
            {
                ParameterBinder   pb       = new DefaultParameter();
                ParameterBinder[] customPB = (ParameterBinder[])pi.GetCustomAttributes(typeof(ParameterBinder), false);
                if (customPB != null && customPB.Length > 0)
                {
                    pb = customPB[0];
                }
                else if (pi.ParameterType == typeof(Boolean))
                {
                    pb = new BooleanParameter();
                }
                else if (pi.ParameterType == typeof(string))
                {
                    pb = new StringParameter();
                }
                else if (pi.ParameterType == typeof(DateTime))
                {
                    pb = new DateTimeParameter();
                }

                else if (pi.ParameterType == typeof(Decimal))
                {
                    pb = new DecimalParameter();
                }
                else if (pi.ParameterType == typeof(float))
                {
                    pb = new FloatParameter();
                }
                else if (pi.ParameterType == typeof(double))
                {
                    pb = new DoubleParameter();
                }
                else if (pi.ParameterType == typeof(short))
                {
                    pb = new ShortParameter();
                }
                else if (pi.ParameterType == typeof(int))
                {
                    pb = new IntParameter();
                }
                else if (pi.ParameterType == typeof(long))
                {
                    pb = new LongParameter();
                }
                else if (pi.ParameterType == typeof(ushort))
                {
                    pb = new UShortParameter();
                }
                else if (pi.ParameterType == typeof(uint))
                {
                    pb = new UIntParameter();
                }
                else if (pi.ParameterType == typeof(ulong))
                {
                    pb = new ULongParameter();
                }
                else if (pi.ParameterType == typeof(HttpRequest))
                {
                    pb = new RequestParameter();
                }
                else if (pi.ParameterType == typeof(IHttpContext))
                {
                    pb = new HttpContextParameter();
                }
                else if (pi.ParameterType == typeof(IDataContext))
                {
                    pb = new DataContextParameter();
                }
                else if (pi.ParameterType == typeof(HttpApiServer))
                {
                    pb = new HttpApiServerParameter();
                }
                else if (pi.ParameterType == typeof(HttpResponse))
                {
                    pb = new ResponseParameter();
                }
                else
                {
                    pb = new DefaultParameter();
                }
                pb.Name = pi.Name;
                pb.Type = pi.ParameterType;
                Parameters.Add(pb);
            }
        }
Beispiel #2
0
        private void LoadParameter()
        {
            DescriptionAttribute da = mMethod.GetCustomAttribute <DescriptionAttribute>(false);

            if (da != null)
            {
                this.Remark = da.Description;
            }
            foreach (System.Reflection.ParameterInfo pi in mMethod.GetParameters())
            {
                ParameterBinder   pb       = new DefaultParameter();
                ParameterBinder[] customPB = (ParameterBinder[])pi.GetCustomAttributes(typeof(ParameterBinder), false);
                if (customPB != null && customPB.Length > 0)
                {
                    pb = customPB[0];
                }
                else if (pi.ParameterType == typeof(Boolean))
                {
                    pb = new BooleanParameter();
                }
                else if (pi.ParameterType == typeof(string))
                {
                    pb = new StringParameter();
                }
                else if (pi.ParameterType == typeof(DateTime))
                {
                    pb = new DateTimeParameter();
                }

                else if (pi.ParameterType == typeof(Decimal))
                {
                    pb = new DecimalParameter();
                }
                else if (pi.ParameterType == typeof(float))
                {
                    pb = new FloatParameter();
                }
                else if (pi.ParameterType == typeof(double))
                {
                    pb = new DoubleParameter();
                }
                else if (pi.ParameterType == typeof(short))
                {
                    pb = new ShortParameter();
                }
                else if (pi.ParameterType == typeof(int))
                {
                    pb = new IntParameter();
                }
                else if (pi.ParameterType == typeof(long))
                {
                    pb = new LongParameter();
                }
                else if (pi.ParameterType == typeof(ushort))
                {
                    pb = new UShortParameter();
                }
                else if (pi.ParameterType == typeof(uint))
                {
                    pb = new UIntParameter();
                }
                else if (pi.ParameterType == typeof(ulong))
                {
                    pb = new ULongParameter();
                }
                else if (pi.ParameterType == typeof(HttpRequest))
                {
                    pb = new RequestParameter();
                }
                else if (pi.ParameterType == typeof(IHttpContext))
                {
                    pb = new HttpContextParameter();
                }
                else if (pi.ParameterType == typeof(IDataContext))
                {
                    pb = new DataContextParameter();
                }
                else if (pi.ParameterType == typeof(HttpApiServer))
                {
                    pb = new HttpApiServerParameter();
                }
                else if (pi.ParameterType == typeof(HttpResponse))
                {
                    pb = new ResponseParameter();
                }
                else if (pi.ParameterType == typeof(PostFile))
                {
                    pb = new PostFileParameter();
                }
                else
                {
                    pb = HttpApiServer.ActionFactory.GetParameterBinder(pi.ParameterType);
                    if (pb == null)
                    {
                        if (HttpApiServer.ActionFactory.HasParameterBindEvent)
                        {
                            pb = new ParamterEventBinder(HttpApiServer.ActionFactory);
                        }
                        else
                        {
                            pb = new DefaultParameter();
                        }
                    }
                }
                pb.ActionHandler = this;
                pb.ParameterInfo = pi;
                pb.Name          = pi.Name;
                pb.Type          = pi.ParameterType;
                pb.Validations   = pi.GetCustomAttributes <Validations.ValidationBase>(false).ToArray();
                if (!HasValidation)
                {
                    HasValidation = pb.Validations != null && pb.Validations.Length > 0;
                }
                pb.CacheKey = pi.GetCustomAttribute <CacheKeyParameter>(false);
                Parameters.Add(pb);
            }
        }
Beispiel #3
0
        private void LoadParameter()
        {
            foreach (System.Reflection.ParameterInfo pi in mMethod.GetParameters())
            {
                ParameterBinder   pb       = new DefaultParameter();
                ParameterBinder[] customPB = (ParameterBinder[])pi.GetCustomAttributes(typeof(ParameterBinder), false);
                if (customPB != null && customPB.Length > 0)
                {
                    pb = customPB[0];
                }
                else if (pi.ParameterType == typeof(string))
                {
                    pb = new StringParameter();
                }
                else if (pi.ParameterType == typeof(DateTime))
                {
                    pb = new DateTimeParameter();
                }

                else if (pi.ParameterType == typeof(Decimal))
                {
                    pb = new DecimalParameter();
                }
                else if (pi.ParameterType == typeof(float))
                {
                    pb = new FloatParameter();
                }
                else if (pi.ParameterType == typeof(double))
                {
                    pb = new DoubleParameter();
                }
                else if (pi.ParameterType == typeof(short))
                {
                    pb = new ShortParameter();
                }
                else if (pi.ParameterType == typeof(int))
                {
                    pb = new IntParameter();
                }
                else if (pi.ParameterType == typeof(long))
                {
                    pb = new LongParameter();
                }
                else if (pi.ParameterType == typeof(ushort))
                {
                    pb = new UShortParameter();
                }
                else if (pi.ParameterType == typeof(uint))
                {
                    pb = new UIntParameter();
                }
                else if (pi.ParameterType == typeof(ulong))
                {
                    pb = new ULongParameter();
                }
                else if (pi.ParameterType == typeof(HttpRequest))
                {
                    pb = new RequestParameter();
                }
                else if (pi.ParameterType == typeof(IHttpContext))
                {
                    pb = new HttpContextParameter();
                }
                else if (pi.ParameterType == typeof(IDataContext))
                {
                    pb = new DataContextParameter();
                }
                else if (pi.ParameterType == typeof(HttpApiServer))
                {
                    pb = new HttpApiServerParameter();
                }
                else if (pi.ParameterType == typeof(HttpResponse))
                {
                    pb = new ResponseParameter();
                }
                else
                {
                    if (pi.ParameterType.GetInterface("BeetleX.HttpExtend.IBodyFlag") != null)
                    {
                        pb = new BodyParameter();
                    }
                    else
                    {
                        pb = new DefaultParameter();
                    }
                }
                pb.Name = pi.Name;
                pb.Type = pi.ParameterType;
                Parameters.Add(pb);
            }
        }