ruder

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
        private static List<string> _needSaveAttributes = new List<string>(new string[]{"int","int16","int32","int64", "single", "double","datetime","bool","boolean","string" });

        private static List<PropertyInfo> _attributes;
        public static List<PropertyInfo> Attributes
        {
            
            get
            {                
                if (_attributes == null)
                {
                    _attributes = new List<PropertyInfo>();
                    foreach (PropertyInfo info in CurrentType.GetProperties())
                    {
                        if (_needSaveAttributes.Contains(info.PropertyType.Name.ToLower()))
                        {
                            _attributes.Add(info);
                        }
                    }
                }

                return _attributes;
            }
        }

        private static Type _type;
        private static Type CurrentType
        {
            get
            {
                if(_type==null)
                {
                    _type=typeof(T);
                }
                return _type;
            }
        }
posted on 2009-04-29 17:35  徐境  阅读(125)  评论(0)    收藏  举报