2019-06-04 14:43:20 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-09-09 09:31:57 +00:00
|
|
|
|
using System.Configuration;
|
2019-06-04 14:43:20 +00:00
|
|
|
|
using System.Linq;
|
2020-02-17 08:58:14 +00:00
|
|
|
|
|
|
|
|
|
using ASC.Common;
|
2019-06-06 08:44:38 +00:00
|
|
|
|
using ASC.Common.Utils;
|
2020-02-17 08:58:14 +00:00
|
|
|
|
|
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-06-04 14:43:20 +00:00
|
|
|
|
|
|
|
|
|
namespace ASC.Data.Storage.Configuration
|
|
|
|
|
{
|
2019-11-11 09:03:49 +00:00
|
|
|
|
public static class StorageConfigExtension
|
2019-06-06 08:44:38 +00:00
|
|
|
|
{
|
2020-02-17 08:58:14 +00:00
|
|
|
|
public static DIHelper AddStorage(this DIHelper 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; }
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-09 09:31:57 +00:00
|
|
|
|
public class Module : ConfigurationElement
|
2019-06-04 14:43:20 +00:00
|
|
|
|
{
|
|
|
|
|
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 IEnumerable<Module> Domain { get; set; }
|
2020-09-09 09:31:57 +00:00
|
|
|
|
|
|
|
|
|
[ConfigurationProperty("visible", DefaultValue = true)]
|
|
|
|
|
public bool Visible
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)this["visible"]; }
|
|
|
|
|
set { this["visible"] = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ConfigurationProperty("appendTenantId", DefaultValue = true)]
|
|
|
|
|
public bool AppendTenantId
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)this["appendTenantId"]; }
|
|
|
|
|
set { this["appendTenantId"] = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ConfigurationProperty("public", DefaultValue = true)]
|
|
|
|
|
public bool Public
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)this["public"]; }
|
|
|
|
|
set { this["public"] = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ConfigurationProperty("disableMigrate", DefaultValue = true)]
|
|
|
|
|
public bool DisableMigrate
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)this["disableMigrate"]; }
|
|
|
|
|
set { this["disableMigrate"] = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ConfigurationProperty("count", DefaultValue = true)]
|
|
|
|
|
public bool Count
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)this["count"]; }
|
|
|
|
|
set { this["count"] = value; }
|
|
|
|
|
}
|
2019-06-04 14:43:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-06 08:44:38 +00:00
|
|
|
|
|