using System; using System.Collections.Generic; using System.Linq; using ASC.Common; using ASC.Common.Utils; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace ASC.Data.Storage.Configuration { public static class StorageConfigExtension { public static DIHelper AddStorage(this DIHelper services) { services.TryAddSingleton(r => r.GetService().GetSetting("Storage")); return services; } } public class Storage { public IEnumerable Appender { get; set; } public IEnumerable Handler { get; set; } public IEnumerable Module { get; set; } public Module GetModuleElement(string name) { return Module?.FirstOrDefault(r => r.Name == name); } public Handler GetHandler(string name) { return Handler?.FirstOrDefault(r => r.Name == name); } } public class Appender { public string Name { get; set; } public string Append { get; set; } public string AppendSecure { get; set; } public string Extensions { get; set; } } public class Handler { public string Name { get; set; } public string Type { get; set; } public IEnumerable Property { get; set; } public IDictionary GetProperties() { if (Property == null || !Property.Any()) return new Dictionary(); return Property.ToDictionary(r => r.Name, r => r.Value); } } public class Properties { public string Name { get; set; } public string Value { get; set; } } public class Module { public string Name { get; set; } public string Data { get; set; } public string Type { get; set; } public string Path { get; set; } public ACL Acl { get; set; } = ACL.Read; public string VirtualPath { get; set; } public TimeSpan Expires { get; set; } public bool Visible { get; set; } = true; public bool AppendTenantId { get; set; } = true; public bool Public { get; set; } public bool DisableMigrate { get; set; } public bool Count { get; set; } = true; public IEnumerable Domain { get; set; } } }