示例#1
0
    public virtual ObjectExtensionsDto Get()
    {
        if (CachedValue == null)
        {
            lock (SyncLock)
            {
                if (CachedValue == null)
                {
                    CachedValue = GenerateCacheValue();
                }
            }
        }

        return(CachedValue);
    }
示例#2
0
    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);
    }
示例#3
0
    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);
        }
    }