private void SaveLoadConfigurationData(Role role, SerializerType serializer)
        {
            FileInfo          _fileInfo      = GetFileName(role, serializer, @"ConfigurationData{0}.{1}");
            ConfigurationData _configuration = null;

            switch (role)
            {
            case Role.Producer:
                _configuration = ReferenceConfiguration.LoadProducer();
                break;

            case Role.Consumer:
                _configuration = ReferenceConfiguration.LoadConsumer();
                break;

            default:
                break;
            }
            ConfigurationDataFactoryIO.Save <ConfigurationData>(_configuration, serializer, _fileInfo, (x, y, z) => { Console.WriteLine(z); });
            _fileInfo.Refresh();
            Assert.IsTrue(_fileInfo.Exists);
            ConfigurationData _mirror = ConfigurationDataFactoryIO.Load <ConfigurationData>(serializer, _fileInfo, (x, y, z) => { Console.WriteLine(z); }, () => { });

            ReferenceConfiguration.Compare(_configuration, _mirror);
        }
Beispiel #2
0
        private ConfigurationExtension LoadConfig()
        {
            if (string.IsNullOrWhiteSpace(_configurationFileName))
            {
                ComponentNotInitialisedException exception = new ComponentNotInitialisedException($"{nameof(_configurationFileName)} was not initialised");
                _logger?.LogError(exception, exception.Message);
                throw exception;
            }

            FileInfo configurationFile = new FileInfo(_configurationFileName);

            if (configurationFile.Exists)
            {
                return(ConfigurationDataFactoryIO.Load <ConfigurationExtension>(
                           SerializerType.Xml,
                           configurationFile,
                           (x, y, z) => _logger?.LogInfo($"{x}-{y}: {z}"),
                           RaiseEvents
                           ));
            }
            else
            {
                ConfigurationFileNotFoundException exception = new ConfigurationFileNotFoundException($"{nameof(Configuration)} could not find the file {_configurationFileName}", _configurationFileName);
                _logger?.LogError(exception, exception.Message);
                throw exception;
            }
        }
        public void ConfigurationDataCreateTestMethod()
        {
            ConfigurationData _cnf = ConfigurationDataFactoryIO.Load <ConfigurationData>(Create, () => { });

            Assert.IsNotNull(_cnf);
            Assert.IsNotNull(_cnf.DataSets);
            TestAssociations(_cnf.DataSets);
        }
        public void LoadSaveTestMethod()
        {
            LocalConfigurationData _configuration = ConfigurationDataFactoryIO.Load <LocalConfigurationData>(LocalConfigurationData.Loader, () => { });

            Assert.IsNotNull(_configuration);
            Assert.AreEqual <int>(1, _configuration.OnLoadedCount);
            Assert.AreEqual <int>(0, _configuration.OnSavingCount);
            ConfigurationDataFactoryIO.Save <LocalConfigurationData>(_configuration, (x) => { Assert.AreEqual <int>(1, x.OnSavingCount); });
        }
        private void LoadUsingSerializer(Role role, SerializerType serializer)
        {
            FileInfo _fileInfo = GetFileName(role, serializer, @"TestData\ConfigurationData{0}.{1}");

            Assert.IsTrue(_fileInfo.Exists, _fileInfo.ToString());
            ConfigurationData _mirror = null;
            ConfigurationData _source = null;

            switch (role)
            {
            case Role.Producer:
                _source = ReferenceConfiguration.LoadProducer();
                break;

            case Role.Consumer:
                _source = ReferenceConfiguration.LoadConsumer();
                break;
            }
            string _message = null;

            switch (serializer)
            {
            case SerializerType.Json:
                _mirror = ConfigurationDataFactoryIO.Load <ConfigurationData>
                              (() => JSONDataContractSerializers.Load <ConfigurationData>(_fileInfo, (x, y, z) => { _message = z; Assert.AreEqual <TraceEventType>(TraceEventType.Verbose, x); }), () => { });
                break;

            case SerializerType.Xml:
                _mirror = ConfigurationDataFactoryIO.Load <ConfigurationData>
                              (() => XmlDataContractSerializers.Load <ConfigurationData>(_fileInfo, (x, y, z) => { _message = z; Assert.AreEqual <TraceEventType>(TraceEventType.Verbose, x); }), () => { });
                break;
            }
            Console.WriteLine(_message);
            Assert.IsNotNull(_mirror);
            Assert.IsFalse(String.IsNullOrEmpty(_message));
            Assert.IsTrue(_message.Contains(_fileInfo.FullName));
            ReferenceConfiguration.Compare(_source, _mirror);
        }
        private ConfigurationData LoadConfig()
        {
            FileInfo _configurationFile = new FileInfo(Properties.Settings.Default.ProducerConfigurationFileName);

            return(ConfigurationDataFactoryIO.Load <ConfigurationData>(() => XmlDataContractSerializers.Load <ConfigurationData>(_configurationFile, (x, y, z) => { }), () => RaiseEvents()));
        }
Beispiel #7
0
        private ConfigurationData LoadConfig()
        {
            FileInfo _configurationFile = new FileInfo(m_ConfigurationFileName);

            return(ConfigurationDataFactoryIO.Load <ConfigurationData>(() => XmlDataContractSerializers.Load <ConfigurationData>(_configurationFile, (x, y, z) => { }), () => RaiseEvents()));
        }
 private BoilersConfigurationData ConfigurationLoader()
 {
     _logger.LogDebug("Configuration data has been requested.");
     return(ConfigurationDataFactoryIO.Load(DataLoader, RaiseEvents));
 }
Beispiel #9
0
        private ConfigurationData LoadConfig()
        {
            FileInfo _configurationFile = new FileInfo(m_ProducerConfigurationFileName);

            return(ConfigurationDataFactoryIO.Load <ConfigurationData>(() => XmlDataContractSerializers.Load <ConfigurationData>(_configurationFile, m_TraceSource.TraceData), () => RaiseEvents()));
        }