Beispiel #1
0
        private static ConfigProperties GetProperties(object obj)
        {
            string           key = obj.GetType().FullName;
            ConfigProperties cahcheProperties = null;

            HttpContext context = HttpContext.Current;

            if (context != null)
            {
                cahcheProperties = context.Cache[key] as ConfigProperties;
            }


            if (cahcheProperties != null)
            {
                return(cahcheProperties);
            }
            else
            {
                PropertyInfo[] result = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                ConfigProperties list = new ConfigProperties();

                foreach (PropertyInfo propertyInfo in result)
                {
                    ConfigOptionAttribute attr = ClientConfig.GetClientConfigAttribute(propertyInfo);

                    if (attr != null)
                    {
                        list.Add(new ConfigObject(propertyInfo, attr, ReflectionUtils.GetDefaultValue(propertyInfo)));
                    }
                }

                list.Reverse();

                if (context != null)
                {
                    context.Cache.Insert(key, list);
                }

                return(list);
            }
        }