public void SaveSettings(ConfigContent content) { if (content == null) { return; } ConfigSection section = content.Find(EnvironmentVariable.ConfigSectionName); if (section == null) { section = content.Append(EnvironmentVariable.ConfigSectionName); } ConfigValue value = section.Find(this.Label); if (value == null) { value = new ConfigValue(this.Label); } value.Value = this.FromArray(this.shift); section[this.Label] = value; }
private void OpenNewContent(ConfigFile file) { if (m_configContentDic.ContainsKey(file)) { m_curConfigContent = m_configContentDic[file]; } else { ConfigContent content = null; if (file.fileType == FileType.Csv) { content = new CsvContent(file); } else if (file.fileType == FileType.Json) { content = new JsonContent(file); } else if (file.fileType == FileType.Xml) { content = new XmlContent(file); } else { return; } m_configContentDic.Add(file, content); m_curConfigContent = content; } }
// Use this for initialization private void Start() { string config = LoadFile(); ConfigContent configuration = JsonUtility.FromJson <ConfigContent>(config); ConfigSingleton configInstance = ConfigSingleton.GetInstance(); configInstance.SetMyNetworkConfig(new MyNetworkConfig(configuration.ServerIp, configuration.ServerPort)); transform.GetComponent <NetworkConnectionConfigurator>().SetupConnection(); }
// Use this for initialization private void Start() { string config = LoadFile(); ConfigContent configuration = JsonUtility.FromJson <ConfigContent>(config); ConfigSingleton configInstance = ConfigSingleton.GetInstance(); configInstance.SetMyNetworkConfig(new MyNetworkConfig("0.0.0.0", configuration.ServerPort)); configInstance.DBDomain = configuration.DBDomain; configInstance.TestGroup = configuration.TestGroup; NetworkManagerEvents.singleton.networkPort = int.Parse(configuration.ServerPort); NetworkManagerEvents.singleton.StartServer(); }
public async void CanAddItem() { var author = new User { Email = ".com", FirstName = "Tal", LastName = "Almog", Username = "******" }; var content = new ConfigContent { Content = JsonSerializer.Serialize(new { Port = 2000 }) }; var system = new Microservice { Name = "SystemName" }; var config = new Config { ConfigContent = content, Author = author, Microservice = system }; await using (var context = new ConfigurationContext(ContextOptions)) { author = new UserService(context).Register(author, "pass"); var controller = new ConfigsController(context); await controller.PostConfig(config); } await using (var context = new ConfigurationContext(ContextOptions)) { var controller = new ConfigsController(context); var item = (await controller.GetConfigs()).Value.ToList()[1]; Assert.Equal("Tal", item.Author.FirstName); Assert.Equal("SystemName", item.Microservice.Name); Assert.Equal(2000, JObject.Parse(item.ConfigContent.Content).GetValue("Port")); } }
public void LoadConfig() { if (File.Exists(_configFilePath)) { using (StreamReader sr = new StreamReader(_configFilePath)) { using (var input = new StringReader(sr.ReadToEnd())) { this.Content = JSON.Deserialize <ConfigContent>(input); } } } else { this.Content = new ConfigContent(); } }
public void FreeSettings(ConfigContent content) { if (content == null) { return; } ConfigSection section = content.Find(EnvironmentVariable.ConfigSectionName); if (section == null) { return; } if (!String.IsNullOrWhiteSpace(this.Start)) { section.Remove(this.Start); } section.Remove(this.Label); }
private void Seed() { using (var context = new ConfigurationContext(ContextOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var author = new User { FirstName = "Tal", LastName = "Almog", Email = "abc", Username = "******" }; author = new UserService(context).Register(author, "test-password"); var content = new ConfigContent { Content = JsonSerializer.Serialize(new { Port = 200 }) }; var system = new Microservice { Name = "ConfigurationHub" }; var config = new Config { ConfigContent = content, Author = author, Microservice = system }; context.Add(config); context.SaveChanges(); } }
public void LoadSettings(ConfigContent content) { if (content == null) { return; } ConfigSection section = content.Find(EnvironmentVariable.ConfigSectionName); if (section == null) { return; } ConfigValue value = section.Find(this.Label); if (value == null) { return; } this.shift = this.IntoArray(value.Value); }