コード例 #1
0
        public GlobalAgentConfiguration GetConfiguration()
        {
            if (_cachedConfiguration == null)
                    _cachedConfiguration =
                        ReadFromDisk(ApplicationFilePath(_configurationDefaults.AgentConfigurationFile));

                return _cachedConfiguration;
        }
コード例 #2
0
        public void SaveToDisk_WithValidFileContents_SavesFileThatCanBeLoaded()
        {
            var testName = Guid.NewGuid().ToString();
            var testFileName = Guid.NewGuid().ToString();
            var configurationFile = new GlobalAgentConfiguration();
            configurationFile.Environments.Add(new DeploymentEnvironment());
            configurationFile.Environments[0].Name = testName;

            _mgr.SaveToDisk(configurationFile, testFileName);
            var loadedConfig = _mgr.ReadFromDisk(testFileName);

            Assert.That(loadedConfig.Environments[0].Name, Is.EqualTo(testName));
        }
コード例 #3
0
        public void SaveToDisk(GlobalAgentConfiguration configuration, string fileName = null)
        {
            var configurationPath = fileName ?? _configurationDefaults.AgentConfigurationFile;
            _logger.Debug(string.Format("saving configuration file to {0}", configurationPath));

            lock (_fileLock)
            {
                using (var memoryStream = new MemoryStream())
                using (var writer = new StreamWriter(memoryStream))
                {
                    new XmlSerializer(typeof (GlobalAgentConfiguration)).Serialize(writer, configuration);
                    SaveToDisk(memoryStream.ToArray(), ApplicationFilePath(configurationPath));
                }
            }
        }