Exemplo n.º 1
0
        public T GetConfigurations <T>() where T : class
        {
            managerOfLogging = new ManagerOfLogging();
            if (path is null)
            {
                if (managerOfLogging.setuped == true)
                {
                    managerOfLogging.LoggerMessage("File of configurations not found.");
                }

                return(null);
            }

            IConfigurationParser <T> configurationParser = null;

            switch (Path.GetExtension(path))
            {
            case ".xml":
                Help.flg = true;
                break;

            case ".json":
                break;
            }
            configurationParser = new Parser <T>(path);
            return(configurationParser.Parse());
        }
Exemplo n.º 2
0
        public void EncryptFile(string inputFile, string outputFile, string Key)
        {
            var encod = new UnicodeEncoding();
            var key   = encod.GetBytes(Key);
            var File  = System.IO.File.ReadAllBytes(inputFile);

            try
            {
                using (var fileStream = new FileStream(outputFile, FileMode.Create))
                {
                    var rijndaelManaged = new RijndaelManaged();

                    using (var cryptoStream = new CryptoStream(fileStream,
                                                               rijndaelManaged.CreateEncryptor(key, key), CryptoStreamMode.Write))
                    {
                        foreach (var symbol in File)
                        {
                            cryptoStream.WriteByte(symbol);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (logger.setuped == true)
                {
                    logger.LoggerMessage("Encryption error: ");
                    logger.LoggerDatabaseMessage("Encryption error: ");
                }
            }
        }
        private bool Validation(string xmlPath, string xsdPath)
        {
            try
            {
                var setting = new XmlReaderSettings();
                setting.ValidationType = ValidationType.Schema;
                setting.Schemas.Add(null, XmlReader.Create(xsdPath));

                var xmlReader   = XmlReader.Create(xmlPath, setting);
                var xmlDocument = new XmlDocument();
                xmlDocument.Load(xmlReader);
                return(true);
            }

            catch (Exception ex)
            {
                if (managerOfLogging.setuped == true)
                {
                    managerOfLogging.LoggerMessage("Error in XMLvalidation: ");
                }
                return(false);
            }
        }