public void StrartLoadBallancerTestNoConf() { var moq = new MockRepository(MockBehavior.Default); var config = new SimpleConfig(@"nonfile.xml"); config.StrartLoadBallancer(moq.OneOf<IBallancerTask<int>>()); }
public Form1() { string config_file = Application.StartupPath + @"\watch.ini"; try { config = new SimpleConfig(config_file); config.fileChanged += new EventHandler(config_fileChanged); config.Sync(this); } catch (Exception e) { MessageBox.Show("Error initializing: " + config_file + "\n" + e.Message); this.Close(); } InitializeComponent(); runner = new AppRunner(); pm = new ProcessManager(); pm.registerApp(new Apache("", "")); pm.registerApp(new Nginx("", "")); pm.registerApp(new PHP("", "")); pm.registerApp(new MySQL("", "")); pm.onProcessUpdated += new ProcessManager.ProcessUpdateEventHandler(pm_onProcessUpdated); pm.start(); growlBootUp(); autoStartFileWatcher(); updateProcessInfo(); }
/********* ** Public methods *********/ /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { this.Config = helper.ReadConfig <SimpleConfig>(); this.GridHelper = new GridHelper(this.Config); helper.Events.Player.Warped += OnWarped; }
/********* ** Public methods *********/ /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { this.Config = helper.ReadConfig <SimpleConfig>(); this.GridHelper = new GridHelper(this.Config); LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; }
/// <summary> /// Add a feed url to the system. /// </summary> /// <exception cref="UserMessageException">If the feed name already exists or the feed is invalid.</exception> /// <param name="name">Feed name</param> /// <param name="feed">Feed url</param> public void AddFeed(string name, string feed) { try { Log.InfoFormat("Validating feed for {0} {1}", name, feed); if (!SingletonContext.ValidateFeedUrl(feed)) { Log.InfoFormat("Feed not valid for {0} {1}", name, feed); throw new UserMessageException("{0} is not a valid feed.", feed); } Log.InfoFormat("Checking if feed name already exists for {0} {1}", name, feed); if (SimpleConfig.Get().GetFeeds().Any(x => x.Name.ToLower() == name.ToLower())) { Log.InfoFormat("Feed name already exists for {0} {1}", name, feed); throw new UserMessageException("Feed name {0} already exists.", name); } Log.InfoFormat("Adding feed {0} {1}", name, feed); SimpleConfig.Get().AddFeed(new NamedUrl(name, feed)); Log.InfoFormat("Firing update feed list {0} {1}", name, feed); this.FireOnUpdateFeedList(); Log.InfoFormat("Feed {0} {1} added.", name, feed); } finally { Log.InfoFormat("Finished {0} {1}", name, feed); } }
public void StrartLoadBallancerTest() { var config = new SimpleConfig(@"C:\Users\Wojciech.Krol\Documents\Affrodite\Affrodite\Affrodite.Tests\affrodite.xml"); int ijk = 0; var recived = new List<int>(); config.StrartLoadBallancer(i => { if (ijk != 5) return new int?[] {ijk++}; return Enumerable.Empty<int?>(); }, i => { if (i != null) recived.Add(i.Value); else { lock (recived) { Monitor.PulseAll(recived); return true; } } return true; }, 1); lock (recived) { Monitor.Wait(recived); Assert.AreEqual(recived.Count, ijk); } }
public void StrartLoadBallancerTestNoConf() { var moq = new MockRepository(MockBehavior.Default); var config = new SimpleConfig(@"nonfile.xml"); config.StrartLoadBallancer(moq.OneOf <IBallancerTask <int> >()); }
/// <summary> /// Remove a feed url from the system. /// </summary> /// <param name="name">Feed name</param> public void RemoveFeed(string name) { Log.InfoFormat("Removing feed {0}", name); SimpleConfig.Get().RemoveFeed(new NamedUrl(name, "")); Log.InfoFormat("Firing update feed list {0}", name); this.FireOnUpdateFeedList(); Log.InfoFormat("Removed feed {0}", name); }
public void CanSerializeSimpleConfig() { var exampleConfig = new SimpleConfig().CreateExample(); var mapper = new DefaultJobConfigurationMapper(new IJobConfiguration[] { new SimpleConfig(), new SimpleListConfig() }); var serialized = mapper.Serialize(exampleConfig); var deserialized = mapper.Deserialize(serialized); exampleConfig.Should().Be(deserialized); }
public static bool getFilterGame(string name) { bool ret = true; if (!Boolean.TryParse(SimpleConfig.ReadValue("FilterGames_" + name, "true"), out ret)) { ret = true; SimpleConfig.WriteValue("FilterGames_" + name, true.ToString(CultureInfo.InvariantCulture)); } return(ret); }
public void DataReader_LocalDataFile_ValidResult() { // Arrange const string ConfigFilePath = @"~\TestData\TestData.xml"; // Act SimpleConfig config = DataReader.LoadConfigByXPath <SimpleConfig>("/SimpleConfig", ConfigFilePath); // Assert Assert.NotNull(config); Assert.Equal(config.Name, "Onno"); }
public void Load(string path) { _config = File.Exists(path) ? new SimpleConfig(path) : new SimpleConfig(); // reset sections _flashPlayer = null; _compiler = null; _runtime = null; _swf = null; _flex = null; _html = null; }
public async Task BuildConfigAsync_T_BuildsConfigFromResult() { var config = new SimpleConfig { IntProperty = 23 }; clientWrapper.Setup(r => r.GetAsync(It.IsAny <Uri>())) .Returns(() => Task.FromResult(BuildResponse(config))); var result = await target.GetConfigAsync <SimpleConfig>(); Assert.Equal(config.IntProperty, result.IntProperty); }
private static void CreateEntry(ConfigFile file, string prefabName) { var config = new SimpleConfig(); config.PrefabName.DefaultValue = prefabName; var entryType = typeof(IConfigurationEntry); foreach (var field in typeof(SimpleConfig).GetFields().Where(x => entryType.IsAssignableFrom(x.FieldType))) { var entry = field.GetValue(config) as IConfigurationEntry; entry.Bind(file, prefabName, field.Name); } }
public async Task BuildConfigAsync_BuildsConfigFromResult() { var config = new SimpleConfig { IntProperty = 23 }; clientWrapper.Setup(r => r.GetAsync(It.IsAny <Uri>())) .Returns(() => Task.FromResult(BuildResponse(config))); var result = await target.BuildConfigAsync(typeof(SimpleConfig)); var castResult = result as SimpleConfig; Assert.NotNull(castResult); Assert.Equal(config.IntProperty, castResult.IntProperty); }
public static T GetGameSetting <T>(Octgn.DataNew.Entities.Game game, string propName, T def) { var defSettings = new Hashtable(); defSettings["name"] = game.Name; var settings = SimpleConfig.Get().ReadValue("GameSettings_" + game.Id.ToString(), defSettings); if (settings.ContainsKey(propName)) { if (settings[propName] is T) { return((T)settings[propName]); } } SetGameSetting(game, propName, def); return(def); }
public static void SetGameSetting <T>(DataNew.Entities.Game game, string propName, T val) { var defSettings = new Hashtable(); defSettings["name"] = game.Name; var settings = SimpleConfig.Get().ReadValue("GameSettings_" + game.Id.ToString(), defSettings); if (!settings.ContainsKey(propName)) { settings.Add(propName, val); } else { settings[propName] = val; } SimpleConfig.Get().WriteValue("GameSettings_" + game.Id.ToString(), settings); }
DataControlConfig configLoader(String configName) { SimpleConfig config = new SimpleConfig(); String erreur = config.loadFile("./job.config"); if (erreur != String.Empty) // on tient compte du fait qu'en environnement de développement, l'exe est dans bin/Release { erreur = config.loadFile("../../job.config"); } if (erreur != String.Empty) { System.Console.WriteLine(erreur); Assert.Fail(erreur); } return(config.getDatacontrolConfig(configName)); }
public void AddFeed_ThrowsIfGameAlreadyExists() { bool pass = false; var curSimpleConfig = SimpleConfig.Get(); var curGameFeedManager = GameFeedManager.Get(); var gameListWithFeed = new List <NamedUrl>(); gameListWithFeed.Add(new NamedUrl("asdf", "asdf")); try { // Fake out the simple config so it returns what we want. // This also sets the singleton context to this fake object. var fakeSimpleConfig = A.Fake <ISimpleConfig>(); A.CallTo(fakeSimpleConfig).DoesNothing(); A.CallTo(() => fakeSimpleConfig.GetFeeds()).Returns(gameListWithFeed); SimpleConfig.SingletonContext = fakeSimpleConfig; // Fake out the GameFeedManager so that we can make sure ValidateFeed does what we want. var fakeGf = A.Fake <IGameFeedManager>(x => x.Wrapping(curGameFeedManager)); GameFeedManager.SingletonContext = fakeGf; A.CallTo(() => fakeGf.ValidateFeedUrl(A <string> ._)).Returns(true); // Now we pass in a game feed by the name asdf, and it should throw an error since it // already exists in the list above. try { fakeGf.AddFeed("asdf", "asdf"); } catch (TargetInvocationException e) { if (e.InnerException is UserMessageException) { pass = true; } } } finally { SimpleConfig.SingletonContext = curSimpleConfig; GameFeedManager.SingletonContext = curGameFeedManager; } Assert.True(pass); }
public void GetFeeds_JustCallsSimpleConfigGetFeeds() { var curSimple = SimpleConfig.Get(); try { var fake = A.Fake <ISimpleConfig>(); A.CallTo(fake).DoesNothing(); SimpleConfig.SingletonContext = fake; var res = GameFeedManager.Get().GetFeeds(); Assert.IsNull(res); A.CallTo(() => fake.GetFeeds()).MustHaveHappened(Repeated.Exactly.Once); } finally { SimpleConfig.SingletonContext = curSimple; } }
public void RemoveFeed_JustCallsSimpleConfigRemoveFeed() { var curSimple = SimpleConfig.Get(); try { var fake = A.Fake <ISimpleConfig>(); A.CallTo(fake).DoesNothing(); SimpleConfig.SingletonContext = fake; GameFeedManager.Get().RemoveFeed("asdf"); A.CallTo(() => fake.RemoveFeed(A <NamedUrl> ._)).MustHaveHappened(Repeated.Exactly.Once); } finally { SimpleConfig.SingletonContext = curSimple; } }
static void Main(string[] args) { var config = new SimpleConfig { BaseAddress = "http://api.openweathermap.org/data/2.5/weather", ApiKey = "62ffa8c4c1dfbc438b162198e174c4cb", State = "wa", IsoCountryCode = "au" }; var cacheOptions = new MemoryCacheOptions(); if (args.Length > 0) { config.State = args[0]; } if (args.Length > 1) { config.IsoCountryCode = args[1]; } var builder = new ContainerBuilder(); builder.RegisterType <WeatherServiceApplication>().AsImplementedInterfaces(); builder.RegisterInstance(config).AsImplementedInterfaces(); builder.RegisterModule <OpenWeatherModule>(); builder.RegisterType <OpenWeatherForecastProvider>().AsImplementedInterfaces(); builder.RegisterType <ConsoleInputHandler>().AsImplementedInterfaces(); builder.RegisterType <ConsoleOutputHandler>().AsImplementedInterfaces(); builder.RegisterInstance(cacheOptions).AsImplementedInterfaces(); builder.RegisterType <MemoryCache>().AsImplementedInterfaces(); builder.AddAutoMapper(typeof(OpenWeatherMappingProfile).Assembly); var container = builder.Build(); using (var scope = container.BeginLifetimeScope()) { var applicaiton = scope.Resolve <IWeatherServiceApplication>(); applicaiton.Run(); } }
public void AddFeed_CallsValidate() { var fakeSimpleConfig = A.Fake <ISimpleConfig>(); A.CallTo(fakeSimpleConfig).DoesNothing(); A.CallTo(() => fakeSimpleConfig.GetFeeds()).Returns(new List <NamedUrl>()); var curSimpleConfig = SimpleConfig.Get(); SimpleConfig.SingletonContext = fakeSimpleConfig; var cur = GameFeedManager.Get(); GameFeedManager.SingletonContext = A.Fake <IGameFeedManager>(x => x.Wrapping(cur)); A.CallTo(() => GameFeedManager.SingletonContext.ValidateFeedUrl(A <string> ._)).Returns(true); GameFeedManager.Get().AddFeed("asdfASDFasdfASDF", "asdf"); A.CallTo(() => GameFeedManager.SingletonContext.ValidateFeedUrl(A <string> ._)).MustHaveHappened(Repeated.Exactly.Once); GameFeedManager.SingletonContext = cur; SimpleConfig.SingletonContext = curSimpleConfig; }
private void Save_Click(object sender, RoutedEventArgs e) { if (_path != null) { try { SimpleConfig res = new SimpleConfig(); foreach (ConfigElement configElement in _path) { res.ConfigElements.Add(configElement); } SimpleConfig.SaveConfig(res, "ERZDCom.config"); MessageBox.Show("Конфигурация сохранена!"); //Application.Current.Shutdown(); } catch (Exception ex) { MessageBox.Show("Ошибка при сохранении в файл конфигурации: " + ex); } } }
public void DataReader_ExternalDataFile_ValidResult() { // Arrange string configFileContent = @" <?xml version='1.0' ?> <TestData> <SimpleConfig> <Name>Onno</Name> </SimpleConfig> </TestData> ".Trim(); string configFilePath = Path.GetTempFileName(); File.WriteAllText(configFilePath, configFileContent); // Act SimpleConfig config = DataReader.LoadConfigByXPath <SimpleConfig>("/SimpleConfig", configFilePath); // Assert Assert.NotNull(config); Assert.Equal(config.Name, "Onno"); }
private void LoadConfig() { if (File.Exists("ERZDCom.config")) { try { var loadConfig = SimpleConfig.LoadConfig("ERZDCom.config"); if (loadConfig == null) { return; } foreach (ConfigElement config in loadConfig.ConfigElements) { _path.Find(p => p.Key.Equals(config.Key)).Value = config.Value; } } catch (Exception ex) { MessageBox.Show("Ошибка при откритии файла конфигурации: " + ex); } } }
private static void Main(string[] args) { // var random = new Random(); // Configurator<int>.SetMaxPriotity(1); // Configurator<int>.SetConfigPath("affrodite.xml"); // Configurator<int>.RegisterMasterAction(i => random.Next()); // Configurator<int>.RegisterSlaveAction(i => // { // Console.WriteLine(i); // return true; // }); // Configurator<int>.Start(); // Thread.Sleep(100000); int ijk = 0; SimpleConfig conf = new SimpleConfig("affrodite.xml"); var task = conf.StrartLoadBallancer((int i) => new[] {ijk++}, i => { Console.WriteLine(i); return true; }, new []{new Tuple<int,Tuple<int,int>>(1,new Tuple<int,int> (0,100))}); task.Wait(); }
public void StrartLoadBallancerTest() { var config = new SimpleConfig(@"C:\Users\Wojciech.Krol\Documents\Affrodite\Affrodite\Affrodite.Tests\affrodite.xml"); int ijk = 0; var recived = new List <int>(); config.StrartLoadBallancer(i => { if (ijk != 5) { return new int?[] { ijk++ } } ; return(Enumerable.Empty <int?>()); }, i => { if (i != null) { recived.Add(i.Value); } else { lock (recived) { Monitor.PulseAll(recived); return(true); } } return(true); }, 1); lock (recived) { Monitor.Wait(recived); Assert.AreEqual(recived.Count, ijk); } }
public void AddFeed_CallsSimpleConfigAddFeedIfItPasses() { bool pass = false; var curSimpleConfig = SimpleConfig.Get(); var curGameFeedManager = GameFeedManager.Get(); var gameListWithFeed = new List <NamedUrl>(); try { // Fake out the simple config so it returns what we want. // This also sets the singleton context to this fake object. var fakeSimpleConfig = A.Fake <ISimpleConfig>(); A.CallTo(fakeSimpleConfig).DoesNothing(); A.CallTo(() => fakeSimpleConfig.GetFeeds()).Returns(gameListWithFeed); SimpleConfig.SingletonContext = fakeSimpleConfig; // Fake out the GameFeedManager so that we can make sure ValidateFeed does what we want. var fakeGf = A.Fake <IGameFeedManager>(x => x.Wrapping(curGameFeedManager)); GameFeedManager.SingletonContext = fakeGf; A.CallTo(() => fakeGf.ValidateFeedUrl(A <string> ._)).Returns(true); // Now we pass in a game feed by the name asdf, and it should throw an error since it // already exists in the list above. fakeGf.AddFeed("asdf", "asdf"); // Make sure that SimpleConfig.AddFeed was called once A.CallTo(() => fakeSimpleConfig.AddFeed(A <NamedUrl> ._)).MustHaveHappened(Repeated.Exactly.Once); Assert.Pass(); } finally { SimpleConfig.SingletonContext = curSimpleConfig; GameFeedManager.SingletonContext = curGameFeedManager; } Assert.Fail(); }
private static void Main(string[] args) { // var random = new Random(); // Configurator<int>.SetMaxPriotity(1); // Configurator<int>.SetConfigPath("affrodite.xml"); // Configurator<int>.RegisterMasterAction(i => random.Next()); // Configurator<int>.RegisterSlaveAction(i => // { // Console.WriteLine(i); // return true; // }); // Configurator<int>.Start(); // Thread.Sleep(100000); int ijk = 0; SimpleConfig conf = new SimpleConfig("affrodite.xml"); var task = conf.StrartLoadBallancer((int i) => new[] { ijk++ }, i => { Console.WriteLine(i); return(true); }, new [] { new Tuple <int, Tuple <int, int> >(1, new Tuple <int, int> (0, 100)) }); task.Wait(); }
public void SimpleConfigConstructorTest() { SimpleConfig target = new SimpleConfig(null); Assert.IsNull(target); }
/// <summary> /// Gets all saved game feeds /// </summary> /// <returns>Saved game feeds</returns> public IEnumerable <NamedUrl> GetFeeds() { Log.Info("Getting Feeds"); return(SimpleConfig.Get().GetFeeds()); }
public HtmlSection(SimpleConfig config) { _section = new Section(config, "html"); }
public Section(SimpleConfig config, string key) { _config = config; _key = key; }