DocSpace-buildtools/common/ASC.Data.Storage/Configuration/Appender.cs

82 lines
2.5 KiB
C#
Raw Normal View History

2019-06-04 14:43:20 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
2019-06-06 08:44:38 +00:00
using ASC.Common.Utils;
2019-10-09 16:08:37 +00:00
using Microsoft.Extensions.Configuration;
2019-06-10 12:54:10 +00:00
using Microsoft.Extensions.DependencyInjection;
2019-10-31 11:28:30 +00:00
using Microsoft.Extensions.DependencyInjection.Extensions;
2019-06-04 14:43:20 +00:00
namespace ASC.Data.Storage.Configuration
{
2019-06-06 08:44:38 +00:00
public static class StorageConfigFactory
{
2019-10-31 11:28:30 +00:00
public static IServiceCollection AddStorage(this IServiceCollection services)
2019-06-06 08:44:38 +00:00
{
2019-10-31 11:28:30 +00:00
services.TryAddSingleton(r => r.GetService<IConfiguration>().GetSetting<Storage>("Storage"));
return services;
2019-06-06 08:44:38 +00:00
}
}
2019-06-04 14:43:20 +00:00
public class Storage
{
public IEnumerable<Appender> Appender { get; set; }
public IEnumerable<Handler> Handler { get; set; }
public IEnumerable<Module> 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<Properties> Property { get; set; }
public IDictionary<string, string> GetProperties()
{
if (Property == null || !Property.Any()) return new Dictionary<string, string>();
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; }
public string VirtualPath { get; set; }
public TimeSpan Expires { get; set; }
public bool Visible { get; set; }
public bool AppendTenantId { get; set; }
public bool Public { get; set; }
public bool DisableMigrate { get; set; }
public bool Count { get; set; }
public IEnumerable<Module> Domain { get; set; }
}
}
2019-06-06 08:44:38 +00:00