private RealTimeCacheHelper ParseCacheTimelinessHelper(System.Type t) { RealTimeCacheHelper realTimeCacheHelper = null; object[] customAttributes = t.GetCustomAttributes(typeof(CacheSettingAttribute), true); if (customAttributes.Length > 0) { CacheSettingAttribute cacheSettingAttribute = customAttributes[0] as CacheSettingAttribute; if (cacheSettingAttribute != null) { realTimeCacheHelper = new RealTimeCacheHelper(cacheSettingAttribute.EnableCache, this.TypeHashID); if (cacheSettingAttribute.EnableCache) { switch (cacheSettingAttribute.ExpirationPolicy) { case EntityCacheExpirationPolicies.Stable: realTimeCacheHelper.CachingExpirationType = CachingExpirationType.Stable; goto IL_89; case EntityCacheExpirationPolicies.Usual: realTimeCacheHelper.CachingExpirationType = CachingExpirationType.UsualSingleObject; goto IL_89; } realTimeCacheHelper.CachingExpirationType = CachingExpirationType.SingleObject; IL_89: System.Collections.Generic.List <System.Reflection.PropertyInfo> list = new System.Collections.Generic.List <System.Reflection.PropertyInfo>(); if (!string.IsNullOrEmpty(cacheSettingAttribute.PropertyNamesOfArea)) { string[] array = cacheSettingAttribute.PropertyNamesOfArea.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string name = array2[i]; System.Reflection.PropertyInfo property = t.GetProperty(name); if (property != null) { list.Add(property); } } } realTimeCacheHelper.PropertiesOfArea = list; if (!string.IsNullOrEmpty(cacheSettingAttribute.PropertyNameOfBody)) { System.Reflection.PropertyInfo property2 = t.GetProperty(cacheSettingAttribute.PropertyNameOfBody); realTimeCacheHelper.PropertyNameOfBody = property2; } } } } if (realTimeCacheHelper == null) { realTimeCacheHelper = new RealTimeCacheHelper(true, this.TypeHashID); } return(realTimeCacheHelper); }
/// <summary> /// 解析Type的CacheTimelinessHelper /// </summary> /// <param name="t"></param> /// <returns></returns> private RealTimeCacheHelper ParseCacheTimelinessHelper(Type t) { RealTimeCacheHelper helper = null; object[] customAttributes = t.GetCustomAttributes(typeof(CacheSettingAttribute), true); if (customAttributes.Length > 0) { CacheSettingAttribute attribute = customAttributes[0] as CacheSettingAttribute; if (attribute != null) { helper = new RealTimeCacheHelper(attribute.EnableCache, this.TypeHashID); if (attribute.EnableCache) { switch (attribute.ExpirationPolicy) { case EntityCacheExpirationPolicies.Stable: helper.CachingExpirationType = CachingExpirationType.Stable; break; case EntityCacheExpirationPolicies.Usual: helper.CachingExpirationType = CachingExpirationType.UsualSingleObject; break; default: helper.CachingExpirationType = CachingExpirationType.SingleObject; break; } BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance; List <EntityPropertyInfo> list = new List <EntityPropertyInfo>(); if (!string.IsNullOrEmpty(attribute.PropertyNamesOfArea)) { foreach (string str in attribute.PropertyNamesOfArea.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { PropertyInfo property = t.GetProperty(str, bindingFlags); if (property != null) { list.Add(property.AsEntityPropertyInfo()); } } } helper.PropertiesOfArea = list; if (!string.IsNullOrEmpty(attribute.PropertyNameOfBody)) { PropertyInfo propertyInfo = t.GetProperty(attribute.PropertyNameOfBody, bindingFlags); helper.PropertyNameOfBody = propertyInfo.AsEntityPropertyInfo(); } } } } if (helper == null) { helper = new RealTimeCacheHelper(true, this.TypeHashID); } return(helper); }
/// <summary> /// 解析Type的CacheTimelinessHelper /// </summary> /// <param name="t">实体类型</param> /// <returns>实体缓存设置</returns> private RealTimeCacheHelper ParseCacheTimelinessHelper(Type t) { RealTimeCacheHelper rch = null; // Get CacheTimelinessHelper var a = t.GetCustomAttributes(typeof(CacheSettingAttribute), true); if (a.Length > 0) { CacheSettingAttribute csa = a[0] as CacheSettingAttribute; if (csa != null) { rch = new RealTimeCacheHelper(csa.EnableCache, TypeHashID); if (csa.EnableCache) { switch (csa.ExpirationPolicy) { case EntityCacheExpirationPolicies.Stable: rch.CachingExpirationType = CachingExpirationType.Stable; break; case EntityCacheExpirationPolicies.Usual: rch.CachingExpirationType = CachingExpirationType.UsualSingleObject; break; case EntityCacheExpirationPolicies.Normal: default: rch.CachingExpirationType = CachingExpirationType.SingleObject; break; } List <PropertyInfo> propertyInfoOfArea = new List <PropertyInfo>(); if (!string.IsNullOrEmpty(csa.PropertyNamesOfArea)) { string[] propertyNamesOfAreaArray = csa.PropertyNamesOfArea.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var pn in propertyNamesOfAreaArray) { var pi = t.GetProperty(pn); if (pi != null) { propertyInfoOfArea.Add(pi); } } } rch.PropertiesOfArea = propertyInfoOfArea; if (!string.IsNullOrEmpty(csa.PropertyNameOfBody)) { var pi = t.GetProperty(csa.PropertyNameOfBody); rch.PropertyNameOfBody = pi; } } } } if (rch == null) { rch = new RealTimeCacheHelper(true, TypeHashID); } return(rch); }