public Middleware(RequestDelegate next, AQL.IAQLEngine engine, IOptionsSnapshot <Config.Settings> settings, ILogger <Middleware> logger) { this.Next = next; this.Settings = settings.Value; this.Logger = logger; this.Engine = engine; }
/// <summary> /// Seleciona o objeto de conexão seguindo o provider do banco selecionado /// </summary> /// <param name="dataBaseName">Nome do banco de dados</param> /// <returns>Objeto de conexão com o banco de dados</returns> private static DatabaseConnection SelectDatabaseConnection(string dataBaseName) { //TODO: Tratar exceções ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings[dataBaseName]; Config.Settings essentialsSettings = (Config.Settings)ConfigurationManager.GetSection("essentialsSettings"); Config.DatabaseConnectionElement databaseConnectionElement = essentialsSettings.DatabaseConnectionClasses.GetDatabaseConnectionClass(connectionString.ProviderName); DatabaseConnection connection = (DatabaseConnection)Activator.CreateInstance(Type.GetType(databaseConnectionElement.Name), dataBaseName); return(connection); }
public SteamClientFixture() { var userSecretsFixture = new Fixtures.UserSecretsFixture(); var settings = new Config.Settings { Key = userSecretsFixture.SteamKey, }; var optionsSettings = Options.Create(settings); SteamClient = new Concrete.SteamClient(optionsSettings); }
/// <summary> /// Class constructor /// </summary> /// <param name="settings"></param> public Session(Config.Settings settings) { mSettings = settings; if (settings.CheckForUpdates && Update.IsUpdateAvailable()) { var diagResult = MessageBox.Show("There seems to be an update available.\nCheck it out?", "Update", MessageBoxButtons.YesNo); if (diagResult == DialogResult.Yes) Process.Start("https://github.com/Ezzpify/HourBoostr/releases/latest"); } mBwg.DoWork += MBwg_DoWork; mBwg.RunWorkerAsync(); }
public DWServiceInstaller() { InitializeComponent(); Config.Settings sett = new Config.Settings(); processInstaller = new ServiceProcessInstaller(); serviceInstaller = new ServiceInstaller(); // Service will run under system account //check the account in config processInstaller.Account = sett.ServiceAccount; if (processInstaller.Account == ServiceAccount.User) { processInstaller.Username = sett.ServiceAccountUserName; processInstaller.Password = sett.ServiceAccountPassword; } // Service will have Start Type of Manual serviceInstaller.StartType = ServiceStartMode.Manual; //string ServiceName = Settings.ServiceName; this.serviceInstaller.DisplayName = sett.ServiceName; this.serviceInstaller.ServiceName = sett.ServiceName; //serviceInstaller.ServiceName = "TayaIT.DirectoryWatcher.WindowsService"; // Create an instance of 'EventLogInstaller'. customEventLogInstaller = new EventLogInstaller(); // Set the 'Source' of the event log, to be created. customEventLogInstaller.Source = "customLog"; // Set the 'Event Log' that the source is created in. customEventLogInstaller.Log = "Application"; // Add myEventLogInstaller to 'InstallerCollection'. Installers.Add(customEventLogInstaller); Installers.Add(serviceInstaller); Installers.Add(processInstaller); }
private static ModelMap LoadModelXml(Type type) { try { Config.Settings essentialsSettings = (Config.Settings)ConfigurationManager.GetSection("essentialsSettings"); XmlDocument xml = new XmlDocument(); xml.Load(essentialsSettings.XmlModelsPath); XmlNode modelNode = xml.SelectSingleNode("/Models/Model[@type='" + type.FullName + "']"); modelNode = (modelNode == null) ? xml.SelectSingleNode("/Models/Model[@baseModelType='" + type.FullName + "']") : modelNode; if (modelNode != null) { ModelMap modelMap = new ModelMap(table: modelNode.Attributes["table"].Value); if (modelNode.Attributes["dataBaseName"] != null) { modelMap._databaseName = modelNode.Attributes["dataBaseName"].Value; } if (modelNode.Attributes["inheritanceMode"] != null && modelNode.Attributes["inheritanceMode"].Value == "JoinTables") { modelMap.InheritanceMode = DataAnnotations.ERBridge.InheritanceMode.JoinTables; modelMap.ParentTableReferenceColumn = modelNode.Attributes["parentTableReferenceColumn"].Value; } //Colunas foreach (XmlNode columnNode in modelNode.SelectNodes("ColumnMap")) { if (type.GetProperty(columnNode.Attributes["property"].Value) != null) { ColumnMap columnMap = new ColumnMap( property: columnNode.Attributes["property"].Value, column: columnNode.Attributes["column"].Value, dataType: (DataAnnotations.ERBridge.DataType)Enum.Parse(typeof(DataAnnotations.ERBridge.DataType), columnNode.Attributes["dbType"].Value), isAutoIncremented: (columnNode.Attributes["isAutoIncremented"] != null ? bool.Parse(columnNode.Attributes["isAutoIncremented"].Value) : false), sequenceName: (columnNode.Attributes["sequenceName"] != null ? columnNode.Attributes["sequenceName"].Value : null), isRequired: (columnNode.Attributes["isRequired"] != null ? bool.Parse(columnNode.Attributes["isRequired"].Value) : false), isKey: (columnNode.Attributes["isKey"] != null ? bool.Parse(columnNode.Attributes["isKey"].Value) : false), isReference: (columnNode.Attributes["isReference"] != null ? bool.Parse(columnNode.Attributes["isReference"].Value) : false)); modelMap.ColumnsMap.Add(columnMap.Property, columnMap); if (columnMap.IsKey) { modelMap.Keys.Add(columnMap.Property); } //Referências if (columnMap.IsReference) { XmlNode referenceNode = modelNode.SelectSingleNode("ReferenceMap[@property='" + columnMap.Property + "']"); ReferenceMapInfo referenceMap = new ReferenceMapInfo( property: referenceNode.Attributes["property"].Value, referenceKey: referenceNode.Attributes["referenceKey"].Value, fetchType: columnNode.Attributes["fetchType"] != null ? (DataAnnotations.ERBridge.Fetch)Enum.Parse(typeof(DataAnnotations.ERBridge.Fetch), columnNode.Attributes["fetchType"].Value) : DataAnnotations.ERBridge.Fetch.LAZY, referencedModelType: type.GetProperty(referenceNode.Attributes["property"].Value).PropertyType ); modelMap.ReferencesMap.Add(referenceMap.Property, referenceMap); modelMap.ColumnsMap.Add(columnMap.Property + "." + referenceMap.ReferenceKey, columnMap); modelMap.Columns.Add(columnMap.Column, columnMap.Property + "." + referenceMap.ReferenceKey); } else { modelMap.Columns.Add(columnMap.Column, columnMap.Property); } } } //Coleções foreach (XmlNode collectionNode in modelNode.SelectNodes("ColletionReferenceMap")) { if (type.GetProperty(collectionNode.Attributes["property"].Value) != null) { System.Reflection.PropertyInfo property = type.GetProperty(collectionNode.Attributes["property"].Value); Type itemType = (property.PropertyType.IsGenericType) ? property.PropertyType.GetGenericArguments()[0] : null; if (itemType != null) { CollectionReferenceMapInfo collectionMap = new CollectionReferenceMapInfo( property: property.Name, collectionItemType: itemType, itemReferenceKey: collectionNode.Attributes["itemReferenceKey"].Value, collectionFetchType: collectionNode.Attributes["fetchType"] != null ? (DataAnnotations.ERBridge.Fetch)Enum.Parse(typeof(DataAnnotations.ERBridge.Fetch), collectionNode.Attributes["fetchType"].Value) : DataAnnotations.ERBridge.Fetch.LAZY, associationTableName: (collectionNode.Attributes["associationTable"] != null ? collectionNode.Attributes["associationTable"].Value : null), mainColumnKey: (collectionNode.Attributes["mainColumnKey"] != null ? collectionNode.Attributes["mainColumnKey"].Value : null), secundaryColumnKey: (collectionNode.Attributes["secundaryColumnKey"] != null ? collectionNode.Attributes["secundaryColumnKey"].Value : null) ); modelMap.CollectionsReferencesMap.Add(property.Name, collectionMap); } } } //Procedures foreach (XmlNode procedureNode in modelNode.SelectNodes("ProcedureMap")) { ProcedureMapInfo procedureMap = new ProcedureMapInfo(procedureNode.Attributes["name"].Value); foreach (XmlNode parameterNode in procedureNode.SelectNodes("Parameter")) { ProcedureParameter parameter = new ProcedureParameter(); parameter.Name = parameterNode.Attributes["name"].Value; parameter.DataType = (DataAnnotations.ERBridge.DataType)Enum.Parse(typeof(DataAnnotations.ERBridge.DataType), parameterNode.Attributes["dbType"].Value); parameter.DefaultValue = parameterNode.Attributes["defaultValue"] != null ? parameterNode.Attributes["defaultValue"].Value : null; parameter.Direction = parameterNode.Attributes["direction"] != null ? (ParameterDirection)Enum.Parse(typeof(ParameterDirection), parameterNode.Attributes["direction"].Value): ParameterDirection.Input; parameter.Size = parameterNode.Attributes["size"] != null?int.Parse(parameterNode.Attributes["size"].Value) : 0; procedureMap.Parameters.Add(parameterNode.Attributes["field"].Value, parameter); } modelMap.ProceduresMap.Add(procedureNode.Attributes["procedureKey"].Value, procedureMap); } return(modelMap); } } catch (Exception ex) { Console.Write(ex); } return(null); }
public SocketAcceptor(Application app, Config.Settings settings) { app_ = app; settings_ = settings; shutdownRequested_ = false; }
/// <summary> /// Form load /// Finds Settings.json and loads it /// </summary> private void mainForm_Load(object sender, EventArgs e) { /*If HourBoostr is running, give warning about saving settings*/ var procs = Process.GetProcessesByName("hourboostr"); if (procs.Length > 0) { MessageBox.Show("Settings will be overwritten when you close HourBoostr.\n" + "I would not recommend making any changes here while HourBoostr is running.\n" + "If you need to make any changes, make a copy of Settings.json.", "Warning"); } /*Find the Settings.json file if it exists and load it up*/ string file = Path.Combine(Application.StartupPath, "Settings.json"); if (File.Exists(file)) { try { string fileContent = File.ReadAllText(file); if (!string.IsNullOrWhiteSpace(fileContent)) mSettings = JsonConvert.DeserializeObject<Config.Settings>(fileContent); } catch (Exception ex) { MessageBox.Show($"Could not read the Settings.json\n\n{ex.Message}", "Ruh roh!"); } } /*Refresh the account list*/ RefreshAccountList(); }
public AQLEngine(IOptionsSnapshot <Config.Settings> settings, ILogger <AQLEngine> logger) { this.Settings = settings.Value; this.Logger = logger; }
/// <summary> /// Main function /// Too many comments /// </summary> /// <param name="args">No args</param> static void Main(string[] args) { /*Create a folder for our account sentry files*/ Console.Title = EndPoint.CONSOLE_TITLE; Directory.CreateDirectory(EndPoint.SENTRY_FOLDER_PATH); Directory.CreateDirectory(EndPoint.LOG_FOLDER_PATH); /*Set exit events so we'll log out all accounts if application is exited*/ mEventHandler = new ConsoleEventDelegate(ConsoleEventCallback); SetConsoleCtrlHandler(mEventHandler, true); /*Start the trayicon thread*/ mThreadTray = new Thread(ToTray); mThreadTray.Start(); /*We'll read and store the settings twice since we'll compare the two objects later on to see if something has changed by the user during runtime*/ mSettings = Settings.GetSettings(); if (mSettings == null) return; /*Read the application settings and start our session*/ var settings = Settings.GetSettings(); if (settings != null) { if (settings.Accounts.Count > 0) { mSession = new Session(settings); while (mSession.mBwg.IsBusy) Thread.Sleep(250); if (settings.HideToTrayAutomatically) { mTrayIcon.ShowBalloonTip(1000, "HourBoostr", "I'm down here!", ToolTipIcon.Info); ShowConsole(false); } } else { Console.WriteLine("No accounts were loaded from settings."); } while (true) Thread.Sleep(250); } }