Exemplo n.º 1
0
        private bool PresumeQueryStringBind()
        {
            QueryStringBind     queryStringBind;
            List <FieldInfo>    fieldInfos = new List <FieldInfo>(this.Parameter.ParameterType.GetFields());
            List <PropertyInfo> properties = new List <PropertyInfo>(this.Parameter.ParameterType.GetProperties());

            if (this.MethodWrap.IsGet())
            {
                if (TypeReflector.IsPrivateValue(this.Parameter.ParameterType))
                {
                    queryStringBind = new QueryStringBind(this.Parameter.Name);
                    this.QueryStringBindes.Add(queryStringBind);
                    return(true);
                }
                else
                {
                    fieldInfos.ForEach(f =>
                    {
                        queryStringBind = new QueryStringBind(f.Name, f);
                        this.QueryStringBindes.Add(queryStringBind);
                    });
                    properties.ForEach(p =>
                    {
                        queryStringBind = new QueryStringBind(p.Name, p);
                        this.QueryStringBindes.Add(queryStringBind);
                    });
                    return(true);
                }
            }
            if (this.MethodWrap.IsPOST())
            {
                return(false);
            }
            return(false);
        }
Exemplo n.º 2
0
        private void BindAttribute()
        {
            PathParaBind        paraBind;
            ParameterHeaderBind headerBind;
            QueryStringBind     queryStringBind;
            string              headername;
            List <FieldInfo>    fieldInfos = new List <FieldInfo>(this.Parameter.ParameterType.GetFields());
            List <PropertyInfo> properties = new List <PropertyInfo>(this.Parameter.ParameterType.GetProperties());

            if (this.pathParaAttribute != null)
            {
                paraBind = new PathParaBind(string.IsNullOrEmpty(pathParaAttribute.Name) ? this.Parameter.Name : pathParaAttribute.Name);
                paraBind.Prompt();
                this.PathParaBindes.Add(paraBind);
                AttributeBinded = true;
            }
            if (this.HeaderAttributes.Count > 0)
            {
                this.HeaderAttributes.ForEach(x =>
                {
                    if (TypeReflector.IsPrivateValue(this.Parameter.ParameterType))
                    {
                        headername = string.IsNullOrEmpty(x.Name) ? this.Parameter.Name : x.Name;
                        headerBind = new ParameterHeaderBind(this, headername, x.Unique);
                        headerBind.Prompt();
                        this.HeaderBindes.Add(headerBind);
                    }
                    else
                    {
                        fieldInfos.ForEach(f =>
                        {
                            headerBind = new ParameterHeaderBind(this, f.Name, f, x.Unique);
                            headerBind.Prompt();
                            this.HeaderBindes.Add(headerBind);
                        });
                        properties.ForEach(p =>
                        {
                            headerBind = new ParameterHeaderBind(this, p.Name, p, x.Unique);
                            headerBind.Prompt();
                            this.HeaderBindes.Add(headerBind);
                        });
                    }
                });
                AttributeBinded = true;
            }
            if (this.QueryStringAttribute != null)
            {
                string queryname;
                if (TypeReflector.IsPrivateValue(this.Parameter.ParameterType))
                {
                    queryname       = string.IsNullOrEmpty(this.QueryStringAttribute.Name) ? this.Parameter.Name : this.QueryStringAttribute.Name;
                    queryStringBind = new QueryStringBind(queryname);
                    queryStringBind.Prompt();
                    this.QueryStringBindes.Add(queryStringBind);
                }
                else
                {
                    if (false == string.IsNullOrEmpty(this.QueryStringAttribute.Name))
                    {
                        queryStringBind = new QueryStringBind(this.QueryStringAttribute.Name);
                        queryStringBind.Prompt();
                        this.QueryStringBindes.Add(queryStringBind);
                    }
                    else
                    {
                        fieldInfos.ForEach(f =>
                        {
                            queryStringBind = new QueryStringBind(f.Name, f);
                            queryStringBind.Prompt();
                            this.QueryStringBindes.Add(queryStringBind);
                        });
                        properties.ForEach(p =>
                        {
                            queryStringBind = new QueryStringBind(p.Name, p);
                            queryStringBind.Prompt();
                            this.QueryStringBindes.Add(queryStringBind);
                        });
                    }
                }
                AttributeBinded = true;
            }
        }