예제 #1
0
        protected void EnsureInitialized()
        {
            _cacheKeyInforamtion.AddIfDoesntContainFunc(GetType(), () =>
            {
                List <CacheKeyPropertyInfo> info = new List <CacheKeyPropertyInfo>();

                PropertyInfo[] properties = GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);

                foreach (PropertyInfo pi in properties)
                {
                    if (!pi.IsDefined(_typeObsoleteAttr, true))
                    {
                        CacheKeyAttribute cka = GetFirstCacheKeyAttribute(pi);
                        if (pi.CanRead && !IsIgnored(cka, pi) && cka != null)
                        {
                            info.Add(new CacheKeyPropertyInfo()
                            {
                                CacheKeyAttribute = cka, PropertyInfo = pi, DefaultValue = cka.DefaultValue
                            });
                        }
                    }
                }

                FieldInfo[] fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);

                foreach (FieldInfo fi in fields)
                {
                    if (!fi.IsDefined(_typeObsoleteAttr, true))
                    {
                        CacheKeyAttribute cka = GetFirstCacheKeyAttribute(fi);
                        if (fi.IsPublic && !IsIgnored(cka, fi) && cka != null)
                        {
                            info.Add(new CacheKeyPropertyInfo()
                            {
                                CacheKeyAttribute = cka, FieldInfo = fi, DefaultValue = cka.DefaultValue
                            });
                        }
                    }
                }

                return(info);
            });
        }