public void GetConfig_LoadConfigForCustomAssemblyDoesNotExist_ThrowsConfigurationException() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws<ConfigurationException>(() => configRepository.GetConfig(assembly)); Assert.AreEqual(assembly.GetName().Name, configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_CanLoadConfigsFromMultipleThreads() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(false, true); var configRepository = new ConfigRepository(configLoader); const int maxThreads = 10; Exception ex = null; IConfig config = null; var getConfigCompletedEvent = new ManualResetEvent(false); for(int i = 0; i < maxThreads; i++) { int remainingThreads = i; ThreadPool.QueueUserWorkItem(s => { try { config = configRepository.GetConfig(configKey, false); if(Interlocked.Decrement(ref remainingThreads) == 0) { getConfigCompletedEvent.Set(); } } catch(Exception innerEx) { getConfigCompletedEvent.Set(); ex = innerEx; throw; } }); } getConfigCompletedEvent.WaitOne(); getConfigCompletedEvent.Close(); Assert.IsNotNull(config); Assert.IsNull(ex); }
public void GetConfig_LoadCurrentConfigThatDoesNotExistAndSupressExceptions_ReturnsNull() { var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(true); Assert.IsNull(config); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadConfigForCustomAssembly_ReturnsConfigWithCorrectSystemConfigKey() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(assembly); Assert.AreEqual(assembly.GetName().Name, config.ConfigKey); }
public void TestAdd() { var dbConnection = AppConfigConnectionFactory.CreateSicConnection(); //using (dbConnection.BeginTransaction()) { var sut = new ConfigRepository(dbConnection); var expected = new LomoConfig { Name = "MyConfig", Description = "Description", Customer = new Customer("John", 0), Fields = new Collection<Field> { new Field {Name = "Test1", Description = "Description1"}, new Field {Name = "Test2", Description = "Description2"}, } }; var id = sut.Create(expected); expected.Id = id; var actual = sut.Get(id); Assert.Equal(expected, actual); } }
public void GetConfig_LoadConfigForCustomAssemblyDoesNotExistAndSupressExceptions_ReturnsNull() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(assembly, true); Assert.IsNull(config); Assert.AreEqual(assembly.GetName().Name, configLoader.ConfigKeysLoaded[0]); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // StructureMap Dependencies configuration StructureMapBootStrapper.ConfigureDependencies(StructureMapBootStrapper.DependencyType.LIVE); //set to either "test" or "live" var db = ObjectFactory.GetInstance<DbContext>(); db.Database.Initialize(true); Utilities.Server.ServerPhysicalPath = Server.MapPath("~"); //AutoMapper create map configuration AutoMapperBootStrapper.ConfigureAutoMapper(); Logger.GetLogger().Info("Kwasant web starting..."); Utilities.Server.IsProduction = ObjectFactory.GetInstance<IConfigRepository>().Get<bool>("IsProduction"); Utilities.Server.IsDevMode = ObjectFactory.GetInstance<IConfigRepository>().Get<bool>("IsDev", true); // CommunicationManager curCommManager = ObjectFactory.GetInstance<CommunicationManager>(); // curCommManager.SubscribeToAlerts(); var segmentWriteKey = new ConfigRepository().Get("SegmentWriteKey"); Analytics.Initialize(segmentWriteKey); AlertReporter curReporter = new AlertReporter(); curReporter.SubscribeToAlerts(); IncidentReporter incidentReporter = new IncidentReporter(); incidentReporter.SubscribeToAlerts(); ModelBinders.Binders.Add(typeof (DateTimeOffset), new KwasantDateBinder()); SharedNotificationQueues.Begin(); var configRepository = ObjectFactory.GetInstance<IConfigRepository>(); using (var uow = ObjectFactory.GetInstance<IUnitOfWork>()) { uow.RemoteCalendarProviderRepository.CreateRemoteCalendarProviders(configRepository); uow.SaveChanges(); } SetServerUrl(); Logger.GetLogger().Warn("Docutrack starting..."); var docusign = new DocusignPackager(); string baseURL = docusign.Login(); }
public static Config GetConfig() { Config result = null; try { ConfigRepository configRepository = new ConfigRepository(); result = configRepository.FindOne(c => c.Id == 1); } catch (Exception e) { LogService.Log("查询配置信息失败", e.ToString()); } return result; }
private void btnRs2014Path_Click(object sender, EventArgs e) { using (var fbd = new VistaFolderBrowserDialog()) { fbd.SelectedPath = general_rs2014path.Text; fbd.Description = "Select Rocksmith 2014 executable root installation folder."; if (fbd.ShowDialog() != DialogResult.OK) { return; } var rs2014Path = fbd.SelectedPath; general_rs2014path.Text = rs2014Path; ConfigRepository.Instance()["general_rs2014path"] = rs2014Path; } }
public static bool EditConfig(Config config) { bool result = false; try { if (config != null) { ConfigRepository configRepository = new ConfigRepository(); result = configRepository.UpdateEntitySave(config); } } catch (Exception e) { LogService.Log("编辑配置信息失败", e.ToString()); } return result; }
// only gets called one time public GeneralConfig() { InitializeComponent(); // fix readonly textbox/cuebox background colors general_rs1path.BackColor = SystemColors.Window; general_rs2014path.BackColor = SystemColors.Window; general_wwisepath.BackColor = SystemColors.Window; creator_defaulttone.BackColor = SystemColors.Window; creator_defaultproject.BackColor = SystemColors.Window; general_defaultauthor.Validating += ValidateSortName; loading = true; try { PopulateAppIdCombo(general_defaultappid_RS2012, GameVersion.RS2012); PopulateAppIdCombo(general_defaultappid_RS2014, GameVersion.RS2014); PopulateEnumCombo(general_defaultgameversion, typeof(GameVersion)); PopulateEnumCombo(general_defaultplatform, typeof(GamePlatform)); PopulateEnumCombo(converter_source, typeof(GamePlatform)); PopulateEnumCombo(converter_target, typeof(GamePlatform)); PopulateRampUp(); PopulateConfigDDC(); // CRITICAL - force static Wwise path and settings for Mac Mono/Wine packages on first run if ((Environment.OSVersion.Platform == PlatformID.MacOSX || GeneralExtension.IsWine()) && ConfigRepository.Instance().GetBoolean("general_firstrun")) { ConfigRepository.Instance()["general_autoupdate"] = "false"; ConfigRepository.Instance()["general_replacerepo"] = "true"; ConfigRepository.Instance()["general_defaultauthor"] = "CST_Mac"; ConfigRepository.Instance()["general_wwisepath"] = "C:\\Program Files (x86)\\Audiokinetic\\Wwise\\Authoring"; // interestingly the full path is not needed here ConfigRepository.Instance()["general_replacerepo"] = "false"; ConfigRepository.Instance()["general_defaultplatform"] = "Mac"; // TODO: identify these Mac paths if static (they are not static) ConfigRepository.Instance()["general_rs2014path"] = ""; ConfigRepository.Instance()["general_rs1path"] = ""; } LoadAndSetupConfiguration(this.Controls); } catch { /*For mono compatibility*/ } loading = false; }
public void ConfigureUsers() { // Create a superuser //_db.Users.Add(new User //{ // Token = superToken, // IsSuperUser=true //}); //_db.SaveChanges(); Mock <ILogger <BaseDataRepository> > mockLogger = new Mock <ILogger <BaseDataRepository> >(); //mockLogger.Setup(m => m.LogInformation() ); var repo = new ConfigRepository(_db, null, mockLogger.Object); new ConfigController(repo).Seed(Guid.NewGuid().ToString("N") + "@gmail.com"); }
public void GetAllUIConfigsForSPO() { GeneralSettings genS = new GeneralSettings(); genS.CloudStorageConnectionString = _fixture.Configuratuion.GetSection("General").GetSection("CloudStorageConnectionString").Value.ToString(); //Need to Mock the injected services and setup any properties on these that the test requires var errorSettingsMoq = new Moq.Mock <IOptions <ErrorSettings> >(); var generalSettingsMoq = new Moq.Mock <IOptions <GeneralSettings> >(); generalSettingsMoq.SetupGet(p => p.Value.CloudStorageConnectionString).Returns(genS.CloudStorageConnectionString); generalSettingsMoq.SetupGet(p => p.Value.AdminUserName).Returns(_fixture.Configuratuion.GetSection("General").GetSection("AdminUserName").Value.ToString()); generalSettingsMoq.SetupGet(p => p.Value.AdminPassword).Returns(_fixture.Configuratuion.GetSection("General").GetSection("AdminPassword").Value.ToString()); generalSettingsMoq.SetupGet(p => p.Value.CentralRepositoryUrl).Returns("https://msmatter.sharepoint.com/sites/catalog"); var environmentMoq = new Moq.Mock <IHostingEnvironment>(); environmentMoq.SetupGet(p => p.WebRootPath).Returns(@"C:\projects\mc2\tree\master\cloud\src\solution\Microsoft.Legal.MatterCenter.Web\wwwroot"); var matterCenterServiceFunctionsMoq = new Moq.Mock <IMatterCenterServiceFunctions>(); var uiConfigsMoq = new Moq.Mock <IOptions <UIConfigSettings> >(); uiConfigsMoq.SetupGet(t => t.Value.MatterCenterConfiguration).Returns("MatterCenterConfiguration"); uiConfigsMoq.SetupGet(p => p.Value.Partitionkey).Returns("MatterCenterConfig"); uiConfigsMoq.SetupGet(c => c.Value.ConfigGroup).Returns("ConfigGroup"); uiConfigsMoq.SetupGet(k => k.Value.Key).Returns("Key"); uiConfigsMoq.SetupGet(v => v.Value.Value).Returns("Value"); var logTableMoq = new Moq.Mock <IOptions <LogTables> >(); ConfigRepository configRepository = new ConfigRepository(null, generalSettingsMoq.Object, uiConfigsMoq.Object); generalSettingsMoq.SetupGet(g => g.Value).Returns(genS); errorSettingsMoq.SetupAllProperties(); ConfigController controller = new ConfigController(errorSettingsMoq.Object, generalSettingsMoq.Object, uiConfigsMoq.Object, logTableMoq.Object, matterCenterServiceFunctionsMoq.Object, configRepository, environmentMoq.Object); var result = controller.GetConfigsForSPO(""); Assert.True(result.Status > 0); }
private void PopulateConfigDDC() { if (Directory.Exists(@".\ddc\")) { ddc_config.Items.Clear(); foreach (var xml in Directory.EnumerateFiles(@".\ddc\", "*.cfg", SearchOption.AllDirectories)) { var name = Path.GetFileNameWithoutExtension(xml); if (name.StartsWith("user_")) { name = name.Remove(0, 5); } ddc_config.Items.Add(name); ddc_config.SelectedItem = ConfigRepository.Instance()[ddc_config.Name]; } } }
public JsonResult GetAll() { ConfigRepository SucRep = new ConfigRepository(); try { return(Json(SucRep.GetConfig(), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { List <Config> list = new List <Config>(); Config obj = new Config(); obj.Accion = 0; obj.Mensaje = ex.Message.ToString(); list.Add(obj); return(Json(list, JsonRequestBehavior.AllowGet)); } }
private void btnTonePath_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialog()) { ofd.InitialDirectory = creator_defaulttone.Text; ofd.Title = "Select Default Tone for the CDLC Creator"; ofd.Filter = CurrentOFDFilter; if (ofd.ShowDialog() != DialogResult.OK) { return; } var tonePath = ofd.FileName; creator_defaulttone.Text = tonePath; ConfigRepository.Instance()["creator_defaulttone"] = tonePath; } }
public void LoadConfigXml() { var configFile = ConfigRepository.Instance()["ddc_config"] + ".cfg"; var rampupFile = ConfigRepository.Instance()["ddc_rampup"] + ".xml"; PhraseLen = (int)ConfigRepository.Instance().GetDecimal("ddc_phraselength"); RemoveSus = ConfigRepository.Instance().GetBoolean("ddc_removesustain"); RampPath = Path.Combine(ExternalApps.TOOLKIT_ROOT, ExternalApps.DDC_DIR, rampupFile); CfgPath = Path.Combine(ExternalApps.TOOLKIT_ROOT, ExternalApps.DDC_DIR, configFile); if (!File.Exists(RampPath) || !File.Exists(CfgPath)) { throw new FileNotFoundException("DDC support files are missing"); } // // -m "D:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\rocksmith-custom-song-toolkit\RocksmithTookitGUI\bin\Debug\ddc\ddc_default.xml" // // -c "D:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\rocksmith-custom-song-toolkit\RocksmithTookitGUI\bin\Debug\ddc\ddc_default.cfg" }
public void LoadIntroScreens() { txtAuthor.DoubleClick += txtAuthor_DoubleClick; txtSeqName.DoubleClick += txtSeqName_DoubleClick; txtSeqName.Leave += txtSeqName_Leave; if (Directory.Exists(ConfigRepository.Instance()["general_rs2014path"])) { rsDir = ConfigRepository.Instance()["general_rs2014path"]; } else { rsDir = Path.Combine(workDir, "cgm"); } txtAuthor.Text = ConfigRepository.Instance()["general_defaultauthor"]; LoadImages(Path.Combine(workDir, "cgm", "current.cis")); }
public string GetRandomFile(SocketGuild guild, string category) { var config = ConfigRepository.FindConfig(guild.Id, "", category); var configData = config.GetData <MemeImagesConfig>(); var files = Directory.GetFiles(configData.Path) .Where(file => configData.AllowedImageTypes.Any(type => type == Path.GetExtension(file))) .ToList(); if (files.Count == 0) { return(null); } var randomValue = Random.Next(files.Count); return(files[randomValue]); }
private ActionResult GetPost(string url) { var config = ConfigRepository.Read(ConfigPath); var configViewModel = new ConfigurationViewModel(config); var postSearchCriteria = new FrontMatterSearchCriteria(1, 0, Order.Descending, PostPath, FrontMatterSearchCriteria.DefaultFrom, FrontMatterSearchCriteria.DefaultTo, url, true); var pageOfPost = FrontMatterRepository.Get(postSearchCriteria); var post = pageOfPost.Entities.First(); var postViewModel = new PostViewModel(post, MarkupProcessorFactory); var layoutPath = GetLayoutPath(post.Layout); var layout = LayoutParser.Parse(layoutPath); var layoutViewModel = new LayoutViewModel(layout); var pageOfPostViewModel = new PageOfPostViewModel(configViewModel, layoutViewModel, postViewModel); return(View("Post", pageOfPostViewModel)); }
private ActionResult GetPage(string url) { var config = ConfigRepository.Read(ConfigPath); var configViewModel = new ConfigurationViewModel(config); var searchCriteria = new FrontMatterSearchCriteria(1, 0, Order.Ascending, SitePath, null, null, url, true); var pageOfPages = FrontMatterRepository.Get(searchCriteria); var frontMatter = pageOfPages.Entities.First(); var frontMatterContentViewModel = new ContentViewModel(frontMatter, MarkupProcessorFactory); var layoutPath = GetLayoutPath(frontMatter.Layout); var layout = LayoutParser.Parse(layoutPath); var layoutViewModel = new LayoutViewModel(layout); var pageOfFrontMatterContentViewModel = new PageOfContentViewModel(configViewModel, layoutViewModel, frontMatterContentViewModel); return(View("Default", pageOfFrontMatterContentViewModel)); }
public JsonResult getParametosByIdEncabezado(string id) { ConfigRepository SucRep = new ConfigRepository(); try { return(Json(SucRep.GetConfigItem(id, null), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { List <ConfigItem> list = new List <ConfigItem>(); ConfigItem obj = new ConfigItem(); obj.Accion = 0; obj.Mensaje = ex.Message.ToString(); list.Add(obj); return(Json(list, JsonRequestBehavior.AllowGet)); } }
private void LoadAndSetupConfiguration(ControlCollection controls) { foreach (var control in controls) { if (control is TextBox || control is CueTextBox) { var tb = (TextBox)control; tb.Text = (string)ConfigRepository.Instance()[tb.Name]; } else if (control is ComboBox) { var cb = (ComboBox)control; var value = ConfigRepository.Instance()[cb.Name]; if (!String.IsNullOrEmpty(cb.ValueMember)) { cb.SelectedValue = value; } else { cb.SelectedItem = value; } } else if (control is CheckBox) { var ch = (CheckBox)control; ch.Checked = ConfigRepository.Instance().GetBoolean(ch.Name); } else if (control is NumericUpDown) { var nud = (NumericUpDown)control; nud.Value = ConfigRepository.Instance().GetDecimal(nud.Name); } else if (control is GroupBox) { LoadAndSetupConfiguration(((GroupBox)control).Controls); } } // hide First Run if (ConfigRepository.Instance()["general_firstrun"] == "false") { lblFirstRun.Visible = false; } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { // autosave the dlc.xml template on closing if (dlcPackageCreator1.IsDirty && ConfigRepository.Instance().GetBoolean("creator_autosavetemplate")) { dlcPackageCreator1.SaveTemplateFile(dlcPackageCreator1.UnpackedDir, false); } // leave temp folder contents for developer debugging if (GeneralExtension.IsInDesignMode) { return; } // cleanup temp folder garbage carefully // confirm this is the 'Local Settings\Temp' directory var di = new DirectoryInfo(Path.GetTempPath()); if (di.Parent != null) { return; } if (di.Parent.Name == "Local Settings" && di.Name == "Temp") { foreach (FileInfo file in di.GetFiles()) { try { file.Delete(); } catch { /*Don't worry just skip locked file*/ } } foreach (DirectoryInfo dir in di.GetDirectories()) { try { dir.Delete(true); } catch { /*Don't worry just skip locked directory*/ } } } }
public override int Update(MaterialCategoryBO vo) { var category = Repository.SingleOrDefault(x => x.Code == vo.Code); if (category != null && category.Id != vo.Id) { throw new BusinessException(ResponseCode.CodeAlreadyExists.Format(vo.Code)); } if (vo.Configs != null && vo.Configs.Count > 0) { var cnt = vo.Configs.Count; var groupCount = vo.Configs.GroupBy(x => x.ConfigKey.ToLower()).Count(); if (cnt != groupCount) { throw new BusinessException(ResponseCode.DuplicateKeyFoundInConfigs); } //判断是否可以修改需要容器 和自定义PN 该类别下已有物料的 不允许修改 var materialCategory = Repository.SingleOrDefault(x => x.Id == vo.Id); if (materialCategory == null) { throw new BusinessException(ResponseCode.MaterialCategoryNotExist.Format(vo.Id)); } if ((materialCategory.RequireContainer != vo.RequireContainer || materialCategory.ManualPartNumber != vo.ManualPartNumber || materialCategory.RequireRack != vo.RequireRack) && MaterialRepository.Count(x => x.CategoryId == vo.Id) > 0) { throw new BusinessException(ResponseCode.CannotModifyRequireContainerOrManualPn); } ConfigRepository.Delete(x => x.MaterialCategoryId == vo.Id); int sort = 10; foreach (var config in vo.Configs) { config.MaterialCategoryId = vo.Id; config.Id = null; config.Sort = sort; sort += 10; //步长设置为10 方便后期在中间插入 } ConfigRepository.BulkInsert(Mapper.Map <List <MaterialCategoryConfig> >(vo.Configs)); } return(base.Update(vo)); }
/// <summary> /// Crea, se non esiste, l'istanza della classe e inizializza gli attributi /// </summary> /// <returns></returns> public static ConfigRepository getInstance(string idAmm) { if (_instances == null) { _instances = Hashtable.Synchronized(new Hashtable()); } lock (_instances) { if (!_instances.ContainsKey(idAmm)) { ConfigRepository instance = new ConfigRepository(); ArrayList ListaChiaviConfig = ChiaviConfigManager.GetChiaviConfig(idAmm); instance.ListaChiavi = ListaChiaviConfig; _instances.Add(idAmm, instance); } } return((ConfigRepository)_instances[idAmm]); }
public PageResult <IDictionary <string, object> > SearchDic(SearchArgs <Material> searchArgs) { var result = Search(searchArgs); var list = new List <IDictionary <string, object> >(); foreach (var item in result.Items) { var brand = BrandRepository.FindById(item.BrandId); var typeDTO = MaterialTypeService.GetById(item.TypeId); var materialConfigs = ConfigRepository.Find(x => x.MaterialId == item.Id).ToDictionary(x => x.ConfigKey); var configs = typeDTO.Configs.Select(x => new MaterialConfigDTO() { ConfigKey = x.ConfigKey, ConfigKeyDesc = x.ConfigKeyDesc, ConfigValueType = x.ConfigValueType, ConfigValue = materialConfigs.ContainsKey(x.ConfigKey) ? materialConfigs[x.ConfigKey].ConfigValue : x.ConfigDefaultValue, MaterialId = item.Id, Remark = x.Remark, Sort = x.Sort }).ToList(); item.Configs = configs; item.BrandName = brand.Name; item.CategoryId = typeDTO.CategoryId; item.CategoryName = typeDTO.CategoryName; item.TypeName = typeDTO.Name; var dic = item.ToDictionary(); foreach (var c in item.Configs) { dic.Add(c.ConfigKey, c.ConfigValue); } list.Add(dic); } var p = new PageResult <IDictionary <string, object> >() { Items = list, PageCount = result.PageCount, PageIndex = result.PageIndex, PageSize = result.PageSize, TotalRows = result.TotalRows }; return(p); }
private void MainForm_Shown(object sender, EventArgs e) { // don't bug the Developers when in design mode ;) if (GeneralExtensions.IsInDesignMode) { return; } bool showRevNote = ConfigRepository.Instance().GetBoolean("general_showrevnote"); if (showRevNote) { if (this.Text.ToUpper().Contains("BETA")) { ShowHelpForm(); } ConfigRepository.Instance()["general_showrevnote"] = "false"; } this.Refresh(); // check for first run //Check if author set at least, then it's not a first run tho, but let it show msg anyways... bool firstRun = ConfigRepository.Instance().GetBoolean("general_firstrun"); if (!firstRun) { return; } MessageBox.Show(new Form { TopMost = true }, " Welcome to the Song Creator Toolkit for Rocksmith." + Environment.NewLine + " Commonly known as, 'the toolkit'." + Environment.NewLine + Environment.NewLine + "It looks like this may be your first time running the toolkit. " + Environment.NewLine + "Please fill in the Configuration menu with your selections.", "Song Creator Toolkit for Rocksmith - FIRST RUN", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowConfigScreen(); BringToFront(); }
private void btnWwisePath_Click(object sender, EventArgs e) { using (var fbd = new VistaFolderBrowserDialog()) { fbd.SelectedPath = general_wwisepath.Text; fbd.Description = "Select the 'WwiseCLI.exe' installation folder," + Environment.NewLine + "or press 'X' to close and clear the Wwise Path."; if (fbd.ShowDialog() != DialogResult.OK) { fbd.SelectedPath = ""; // allow user to clear the path // return; // leaves the path as-is } var wwisePath = fbd.SelectedPath; general_wwisepath.Text = wwisePath; ConfigRepository.Instance()["general_wwisepath"] = wwisePath; } }
private void PopulateRampUp() { if (Directory.Exists(@".\ddc\")) { ddc_rampup.Items.Clear(); foreach (var xml in Directory.EnumerateFiles(@".\ddc\", "*.xml", SearchOption.AllDirectories)) { var name = Path.GetFileNameWithoutExtension(xml); if (name.StartsWith("user_")) { name = name.Substring(5, name.Length - 5); } ddc_rampup.Items.Add(name); var storedRampup = ConfigRepository.Instance()[ddc_rampup.Name]; ddc_rampup.SelectedItem = storedRampup; } } }
private void PopulateConfigDDC() { var ddcpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "ddc"); if (Directory.Exists(ddcpath)) { ddc_config.Items.Clear(); foreach (var xml in Directory.EnumerateFiles(ddcpath, "*.cfg", SearchOption.AllDirectories)) { var name = Path.GetFileNameWithoutExtension(xml); if (name.StartsWith("user_", StringComparison.Ordinal)) { name = name.Remove(0, 5); } ddc_config.Items.Add(name); ddc_config.SelectedItem = ConfigRepository.Instance()[ddc_config.Name]; } } }
public void Init(ToolkitVersionOnline onlineVersion) { if (onlineVersion.UpdateAvailable) { this.Text = "Toolkit update is available ..."; } else { this.Text = "Toolkit is already up to date ..."; } // delete old updater application var updatingAppPath = Path.Combine(LocalToolkitDir, APP_UPDATING); if (File.Exists(updatingAppPath)) { File.Delete(updatingAppPath); } var updatingConfigPath = Path.Combine(LocalToolkitDir, APP_UPDATING + APP_CONFIG_EXT); if (File.Exists(updatingConfigPath)) { File.Delete(updatingConfigPath); } var useBeta = ConfigRepository.Instance().GetBoolean("general_usebeta"); lblCurrentVersion.Text = ToolkitVersion.RSTKGuiVersion; lblNewVersion.Text = String.Format("{0}-{1} {2}", onlineVersion.OnlineVersion, onlineVersion.Revision, useBeta ? "" : "DISABLED"); lblNewVersionDate.Text = onlineVersion.Date.ToShortDateString(); if (onlineVersion.CommitMessages != null) { dgvCommitMessage.Visible = true; dgvCommitMessage.Rows.Clear(); for (var i = 0; i < onlineVersion.CommitMessages.Length; i++) { dgvCommitMessage.Rows.Add(); dgvCommitMessage.Rows[i].Cells["Message"].Value = onlineVersion.CommitMessages[i]; } } }
public static string GetWwisePath() { // Audiokinect Wwise might not be installed in the default location ;< // so added Wwise location to toolkit configuration menu if (!String.IsNullOrEmpty(ConfigRepository.Instance()["general_wwisepath"])) { return(ConfigRepository.Instance()["general_wwisepath"]); } try { var programsDir = String.Empty; if (Environment.OSVersion.Version.Major >= 6) { programsDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Audiokinetic"); } else { programsDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Audiokinetic"); } var pathWwiseCli = Directory.EnumerateFiles(programsDir, "WwiseCLI.exe", SearchOption.AllDirectories).FirstOrDefault(); if (String.IsNullOrEmpty(Path.GetFileName(pathWwiseCli))) { throw new FileNotFoundException("Could not find WwiseCLI.exe in " + programsDir + Environment.NewLine + "Please confirm that Build 4828 is installed."); } return(pathWwiseCli); } catch (Exception ex) { MessageBox.Show(new Form { TopMost = true }, @"Could not find WwiseCLI.exe or Audiokinetic directory. " + Environment.NewLine + @"Please confirm that it is installed and selected in the CST configuration menu.", @"Exception: " + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); Environment.Exit(-1); return(null); } }
public ConfigurationModule(ConfigRepository repository) { var system = repository.GetOrCreate("system", new SystemConfiguration()); Get["/application/{application}"] = parameters => { var application = parameters.application; return repository.Get(application); //return new //{ // Application = application, // Setting1 = 1, // Persistence = new // { // Mongo = new // { // Url = "mongo" // }, // Sql = new // { // Url = "sql" // } // }, // Timeout = 3 //}; }; Post["/register"] = ctx => { var clientAddress = Request.UserHostAddress; var clients = system.Clients; if (!clients.Contains(clientAddress)) { clients.Add(clientAddress); } return HttpStatusCode.OK; }; }
public void GetConfig() { SQLiteRepository con = new SQLiteRepository(); con.CreateDatabase(); ConfigRepository configRepository = new ConfigRepository(con); Config c = new Config() { Phone = "34676681420", Voz = false, Velocidad = (float)0.5 }; using (var connection = con.GetConnection()) { configRepository.InsertConfig(c); var result = configRepository.GetConfig(); Assert.AreEqual(false, result.Voz); } }
public override MaterialDTO GetById(int?id) { var materialDto = base.GetById(id); var typeDTO = MaterialTypeService.GetById(materialDto.TypeId); var materialConfigs = ConfigRepository.Find(x => x.MaterialId == materialDto.Id).OrderBy(x => x.Sort).ToList(); var configs = typeDTO.Configs.Select(x => new MaterialConfigDTO() { ConfigKey = x.ConfigKey, ConfigKeyDesc = x.ConfigKeyDesc, ConfigValueType = x.ConfigValueType, ConfigValue = materialConfigs.FirstOrDefault(y => y.ConfigKey == x.ConfigKey) == null ? x.ConfigDefaultValue : materialConfigs.FirstOrDefault(y => y.ConfigKey == x.ConfigKey).ConfigValue, MaterialId = materialDto.Id, Remark = x.Remark, Sort = x.Sort }).OrderBy(x => x.Sort).ToList(); materialDto.Configs = configs; return(materialDto); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn); database = new SQLiteRepository(); configRepo = new ConfigRepository(database); loginService = new LoginService(); errorText = new ErrorText(); FakeSessionDelete = new FakeSessionDelete(); configuracion = configRepo.GetConfig(); b = FindViewById <ImageButton>(Resource.Id.Enviar); b2 = FindViewById <ImageButton>(Resource.Id.Leer); b3 = FindViewById <ImageButton>(Resource.Id.Contactos); b4 = FindViewById <ImageButton>(Resource.Id.Configuracion); logout = FindViewById <Button>(Resource.Id.logout); try { client = loginService.Connect(); } catch (Exception ex) { this.FinishAffinity(); } if (client.IsUserAuthorized()) { usuario = client.Session.TLUser; } service = new Intent(this, typeof(ReceiveService)); if (!IsMyServiceRunning(service)) { StartService(service); } SetVisible(true); }
public DLCPackerUnpacker() { InitializeComponent(); try { var gameVersionList = Enum.GetNames(typeof(GameVersion)).ToList <string>(); gameVersionList.Remove("None"); cmbGameVersion.DataSource = gameVersionList; cmbGameVersion.SelectedItem = ConfigRepository.Instance()["general_defaultgameversion"]; gameVersion = (GameVersion)Enum.Parse(typeof(GameVersion), cmbGameVersion.SelectedItem.ToString()); PopulateAppIdCombo(gameVersion); } catch { /*For mono compatibility*/ } // AppID updater worker bwRepack.DoWork += new DoWorkEventHandler(UpdateAppId); bwRepack.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged); bwRepack.RunWorkerCompleted += new RunWorkerCompletedEventHandler(ProcessCompleted); bwRepack.WorkerReportsProgress = true; }
public IActionResult CallStats() { var configs = ConfigRepository.GetAllConfigurations(); var commands = new List <CommandStatSummaryItem>(); foreach (var config in configs) { var guild = DiscordClient.GetGuild(config.GuildIDSnowflake); commands.Add(new CommandStatSummaryItem() { CallsCount = config.UsedCount, Command = config.Command, Group = config.Group, Guild = guild == null ? $"UnknownGuild ({config.GuildIDSnowflake})" : $"{guild.Name}", PermissionsCount = config.Permissions.Count }); } return(View(new CallStatsViewModel(commands))); }
public JsonResult SaveData(Config Config) { try { ConfigRepository SucRep = new ConfigRepository(); if (ModelState.IsValid) { SucRep.Save(Config); } else { Config.Accion = 0; Config.Mensaje = "Los datos enviados no son correctos, intente de nuevo!"; } return(Json(Config, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(Config, JsonRequestBehavior.AllowGet)); } }
protected void Application_Start() { Database.SetInitializer<GolfDbContext>(new GolfLeagueInitializer()); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var dbContext = new GolfDbContext(); var configSettings = new ConfigRepository(dbContext).Get(); Application.Add("HandicapWeeks", configSettings.HandicapWeekCount); Application.Add("HandicapRoundAdj", configSettings.RoundAdjustment); Application.Add("RoundParFront", configSettings.RoundParFront); Application.Add("RoundParBack", configSettings.RoundParBack); var courseSettings = new CourseRepository(dbContext).Get(); var parRepo = new ParRespository(dbContext); var frontPars = parRepo.GetFrontPars(courseSettings.CourseId); var backPars = parRepo.GetBackPars(courseSettings.CourseId); Application.Add("FrontPars", frontPars); Application.Add("BackPars", backPars); }
public void GetSystemConfig_CreateConfigRepositoryWithDefaultValuesAndLoadSystemConfig_ReturnsConfigWithCorrectSystemConfigKey() { var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetSystemConfig(); Assert.AreEqual("System", config.ConfigKey); }
public void GetConfig_LoadConfigForCustomConfigDoesNotExist_ThrowsConfigurationException() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws<ConfigurationException>(() => configRepository.GetConfig(configKey)); Assert.AreEqual(configKey, configLoader.ConfigKeysLoaded[0]); }
public void TestGetAll() { var sut = new ConfigRepository(AppConfigConnectionFactory.CreateSicConnection()); var allFields = sut.GetAll(); Assert.NotEmpty(allFields); }
public void GetConfig_LoadConfigForCustomConfigDoesNotExistAndSupressExceptions_ReturnsNull() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(configKey, true); Assert.IsNull(config); Assert.AreEqual(configKey, configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_GetSameConfigTwice_ReturnsSameConfig() { var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config1 = configRepository.GetConfig("myConfig"); Assert.IsTrue(configRepository.Configurations.Contains("myConfig")); IConfig config2 = configRepository.GetConfig("myConfig"); Assert.AreEqual(config1, config2); }
public void GetConfig_LoadCurrentConfig_ReturnsConfigWithCorrectSystemConfigKey() { var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", config.ConfigKey); }
public void GetConfig_LoadCurrentConfigThatDoesNotExist_ThrowsConfigurationException() { var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws<ConfigurationException>(() => configRepository.GetConfig()); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadConfigForCustomConfig_ReturnsConfigWithCorrectSystemConfigKey() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(configKey); Assert.AreEqual(configKey, config.ConfigKey); }
public void GetSystemConfig_CreateConfigRepositoryWithCustomValuesAndLoadSystemConfig_ReturnsConfigWithCorrectSystemConfigKey() { var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader, "CustomSystemKey", "CustomAppKey"); IConfig config = configRepository.GetSystemConfig(); Assert.AreEqual("CustomSystemKey", config.ConfigKey); }
public void GetAppConfig_CreateConfigRepositoryWithDefaultValuesAndLoadAppConfig_ReturnsConfigWithCorrectAppConfigKey() { var configLoader = new FakeLoader(false); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetAppConfig(); Assert.AreEqual("nJupiter.Configuration.Tests.Integration.dll", config.ConfigKey); }