Пример #1
0
        // Token: 0x060000A2 RID: 162 RVA: 0x0000913C File Offset: 0x0000733C
        public static T GetModel <T>(string prefix) where T : new()
        {
            T    t = (default(T) == null) ? Activator.CreateInstance <T>() : default(T);
            Type typeFromHandle = typeof(T);

            foreach (PropertyInfo propertyInfo in typeFromHandle.GetProperties())
            {
                if (propertyInfo != null && propertyInfo.CanWrite)
                {
                    string text = prefix + propertyInfo.Name;
                    if (text.ToLower() == prefix + "pageurl")
                    {
                        propertyInfo.SetValue(t, FPRequest.GetRawUrl(), null);
                    }
                    else if (HttpContext.Current.Request.QueryString[text] != null || HttpContext.Current.Request.Form[text] != null)
                    {
                        if (propertyInfo.PropertyType == typeof(string))
                        {
                            propertyInfo.SetValue(t, FPRequest.GetString(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(int))
                        {
                            propertyInfo.SetValue(t, FPRequest.GetInt(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(short))
                        {
                            propertyInfo.SetValue(t, short.Parse(FPRequest.GetInt(text).ToString()), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(DateTime))
                        {
                            propertyInfo.SetValue(t, FPRequest.GetDateTime(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(decimal))
                        {
                            propertyInfo.SetValue(t, FPRequest.GetDecimal(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(float))
                        {
                            propertyInfo.SetValue(t, FPRequest.GetFloat(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(double))
                        {
                            propertyInfo.SetValue(t, FPRequest.GetDouble(text), null);
                        }
                    }
                }
            }
            return(t);
        }
Пример #2
0
        // Token: 0x060000A3 RID: 163 RVA: 0x000093EC File Offset: 0x000075EC
        public static T GetModel <T>(T model, string prefix)
        {
            Type type = model.GetType();

            foreach (PropertyInfo propertyInfo in type.GetProperties())
            {
                if (propertyInfo != null && propertyInfo.CanWrite)
                {
                    string text = prefix + propertyInfo.Name;
                    if (text.ToLower() == prefix + "pageurl")
                    {
                        propertyInfo.SetValue(model, FPRequest.GetRawUrl(), null);
                    }
                    else if (HttpContext.Current.Request.QueryString[text] != null || HttpContext.Current.Request.Form[text] != null)
                    {
                        if (propertyInfo.PropertyType == typeof(string))
                        {
                            propertyInfo.SetValue(model, FPRequest.GetString(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(int))
                        {
                            propertyInfo.SetValue(model, FPRequest.GetInt(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(DateTime))
                        {
                            propertyInfo.SetValue(model, FPRequest.GetDateTime(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(decimal))
                        {
                            propertyInfo.SetValue(model, FPRequest.GetDecimal(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(float))
                        {
                            propertyInfo.SetValue(model, FPRequest.GetFloat(text), null);
                        }
                        else if (propertyInfo.PropertyType == typeof(double))
                        {
                            propertyInfo.SetValue(model, FPRequest.GetDouble(text), null);
                        }
                    }
                }
            }
            return(model);
        }