Пример #1
0
 public Cryptor()
 {
     Manager         = new OptionsManager(true);
     Options         = Manager.GetOptions <CryptingOptions>(Options);
     IsEncryptEnable = Options.IsEncryptEnable;
     IsLoggerEnable  = Options.IsLoggerEnable;
     Key             = Options.Key;
 }
Пример #2
0
        public OptionsManager(bool isJson = true)
        {
            IsJson     = isJson;
            JsonReader = new JsonParser();
            JsonReader.Parse(JsonPath);
            ArchiveOptions ArchiveSet = new ArchiveOptions()
            {
                IsCompressEnable = string.Format(JsonReader.GetJsonElement("IsCompressEnable")).Contains("true"),
                CompressionLevel = (System.IO.Compression.CompressionLevel)Int32.Parse(JsonReader.GetJsonElement("CompressionLevel")),
                SourceDirectory  = JsonReader.GetJsonElement("SourceDirectory"),
                TargetDirectory  = JsonReader.GetJsonElement("TargetDirectory"),
                IsLoggerEnable   = bool.Parse(JsonReader.GetJsonElement("IsLoggerEnable"))
            };
            CryptingOptions CryptorSet = new CryptingOptions()
            {
                IsEncryptEnable = bool.Parse(JsonReader.GetJsonElement("IsEncryptEnable")),
                SourceDirectory = JsonReader.GetJsonElement("SourceDirectory"),
                TargetDirectory = JsonReader.GetJsonElement("TargetDirectory"),
                IsLoggerEnable  = bool.Parse(JsonReader.GetJsonElement("IsLoggerEnable"))
            };
            LoggerOptions LoggerSet = new LoggerOptions()
            {
                LogFile         = JsonReader.GetJsonElement("LogFile"),
                SourceDirectory = JsonReader.GetJsonElement("SourceDirectory"),
                TargetDirectory = JsonReader.GetJsonElement("TargetDirectory"),
                IsLoggerEnable  = bool.Parse(JsonReader.GetJsonElement("IsLoggerEnable"))
            };
            WatcherOptions WatcherSet = new WatcherOptions()
            {
                SourceDirectory = JsonReader.GetJsonElement("SourceDirectory"),
                TargetDirectory = JsonReader.GetJsonElement("TargetDirectory"),
                IsLoggerEnable  = bool.Parse(JsonReader.GetJsonElement("IsLoggerEnable"))
            };
            Options DefaultOptionsSet = new Options()
            {
                SourceDirectory = JsonReader.GetJsonElement("SourceDirectory"),
                TargetDirectory = JsonReader.GetJsonElement("TargetDirectory"),
                IsLoggerEnable  = bool.Parse(JsonReader.GetJsonElement("IsLoggerEnable"))
            };

            EtlJsonOptions = new EtlJsonOptions(ArchiveSet, CryptorSet, LoggerSet, WatcherSet, DefaultOptionsSet);

            XmlReader = new XmlParser();
            XmlReader.Parse(XmlPath);
            ArchiveOptions ArchiveSetXml = new ArchiveOptions()
            {
                IsCompressEnable = string.Format(XmlReader.GetXmlElement("IsCompressEnable")).Contains("true"),
                CompressionLevel = (System.IO.Compression.CompressionLevel)Int32.Parse(XmlReader.GetXmlElement("CompressionLevel")),
                SourceDirectory  = XmlReader.GetXmlElement("SourceDirectory"),
                TargetDirectory  = XmlReader.GetXmlElement("TargetDirectory"),
                IsLoggerEnable   = bool.Parse(XmlReader.GetXmlElement("IsLoggerEnable"))
            };
            CryptingOptions CryptorSetXml = new CryptingOptions()
            {
                IsEncryptEnable = bool.Parse(XmlReader.GetXmlElement("IsEncryptEnable")),
                SourceDirectory = XmlReader.GetXmlElement("SourceDirectory"),
                TargetDirectory = XmlReader.GetXmlElement("TargetDirectory"),
                IsLoggerEnable  = bool.Parse(XmlReader.GetXmlElement("IsLoggerEnable"))
            };
            LoggerOptions LoggerSetXml = new LoggerOptions()
            {
                LogFile         = JsonReader.GetJsonElement("LogFile"),
                SourceDirectory = XmlReader.GetXmlElement("SourceDirectory"),
                TargetDirectory = XmlReader.GetXmlElement("TargetDirectory"),
                IsLoggerEnable  = bool.Parse(XmlReader.GetXmlElement("IsLoggerEnable"))
            };
            WatcherOptions WatcherSetXml = new WatcherOptions()
            {
                SourceDirectory = XmlReader.GetXmlElement("SourceDirectory"),
                TargetDirectory = XmlReader.GetXmlElement("TargetDirectory"),
                IsLoggerEnable  = bool.Parse(XmlReader.GetXmlElement("IsLoggerEnable"))
            };
            Options DefaultOptionsSetXml = new Options()
            {
                SourceDirectory = XmlReader.GetXmlElement("SourceDirectory"),
                TargetDirectory = XmlReader.GetXmlElement("TargetDirectory"),
                IsLoggerEnable  = bool.Parse(XmlReader.GetXmlElement("IsLoggerEnable"))
            };

            EtlXmlOptions = new EtlXmlOptions(ArchiveSetXml, CryptorSetXml, LoggerSetXml, WatcherSetXml, DefaultOptionsSetXml);
        }
Пример #3
0
 public CryptingOptions GetOptions <Type>(CryptingOptions o)
 => IsJson ? EtlJsonOptions.CryptingOptions : EtlXmlOptions.CryptingOptions;