public virtual ObjectExtensionsDto Get() { if (CachedValue == null) { lock (SyncLock) { if (CachedValue == null) { CachedValue = GenerateCacheValue(); } } } return(CachedValue); }
protected virtual ObjectExtensionsDto GenerateCacheValue() { var objectExtensionsDto = new ObjectExtensionsDto { Modules = new Dictionary <string, ModuleExtensionDto>(), Enums = new Dictionary <string, ExtensionEnumDto>() }; foreach (var moduleConfig in ObjectExtensionManager.Instance.Modules()) { objectExtensionsDto.Modules[moduleConfig.Key] = CreateModuleExtensionDto(moduleConfig.Value); } FillEnums(objectExtensionsDto); return(objectExtensionsDto); }
protected virtual void FillEnums(ObjectExtensionsDto objectExtensionsDto) { var enumProperties = ObjectExtensionManager.Instance.Modules().Values .SelectMany( m => m.Entities.Values.SelectMany( e => e.GetProperties() ) ) .Where(p => p.Type.IsEnum) .ToList(); foreach (var enumProperty in enumProperties) { // ReSharper disable once AssignNullToNotNullAttribute (enumProperty.Type.FullName can not be null for this case) objectExtensionsDto.Enums[enumProperty.Type.FullName] = CreateExtensionEnumDto(enumProperty); } }