コード例 #1
0
        public WhisperApplication()
        {
            if (!Directory.Exists(LoggingDirectory))
            {
                Directory.CreateDirectory(LoggingDirectory);
            }

            if (!Directory.Exists(ConfigDirectory))
            {
                Directory.CreateDirectory(ConfigDirectory);
            }

            _loggingService   = new LoggingServiceProvider(LoggingDirectory);
            _appInfoService   = new ApplicationInfoServiceProvider();
            _clipboardService = new ClipboardServiceProvider();
            _configService    = new ConfigurationServiceProvider(_loggingService);
            _generatorService = new GeneratorServiceProvider();

            _services = new List <IApplicationService>
            {
                _appInfoService,
                _clipboardService,
                _configService,
                _generatorService
            };

            _logger = _loggingService.GetContextualLogger("Initialisation");
        }
コード例 #2
0
        public int AddRecord(string descricao)
        {
            using (MySqlConnection conn = new MySqlConnection(ConfigurationServiceProvider.GetConnectionString("GTI.MySQL")))
            {
                conn.Open();

                StringBuilder stbComando = new StringBuilder();
                stbComando.Append("Insert into TipoEndereco (descricao) ");
                stbComando.Append($" values ('{descricao}')");

                using (MySqlCommand command = new MySqlCommand(stbComando.ToString(), conn))
                {
                    return(command.ExecuteNonQuery());
                }
            }
        }
コード例 #3
0
        public List <TipoEnderecoModel> GetRecord(int?id = null)
        {
            List <TipoEnderecoModel> objRetorno = new List <TipoEnderecoModel>();

            using (MySqlConnection conn = new MySqlConnection(ConfigurationServiceProvider.GetConnectionString("GTI.MySQL")))
            {
                conn.Open();

                // EXEMPLO DO QUE "NÃO SE DEVE FAZER".... CONCATENAÇÃO "DESENFREADA" DE STRINGS....
                //string strComando = "";
                //strComando += "Select ID";             ''  / 'Select ID'
                //strComando += " , descricao";           ''  / 'Select ID' / 'Select ID , descricao'
                //strComando += "From TipoEndereco ";

                StringBuilder stbComando = new StringBuilder();
                stbComando.Append("Select ID");
                stbComando.Append(" , descricao ");
                stbComando.Append("From TipoEndereco ");
                if (id != null)
                {
                    stbComando.Append(" Where ID = " + id.ToString());
                }

                using (MySqlCommand command = new MySqlCommand(stbComando.ToString(), conn))
                {
                    using (MySqlDataReader mySqlData = command.ExecuteReader())
                    {
                        while (mySqlData.Read())
                        {
                            objRetorno.Add(new TipoEnderecoModel()
                            {
                                ID        = (int)mySqlData["ID"],
                                Descricao = (string)mySqlData["descricao"]
                            });
                        }
                    }
                }

                return(objRetorno);
            }
        }
コード例 #4
0
 private void WhenIGetTheService()
 {
     _serviceProvider = new ConfigurationServiceProvider(_expected);
     _result          = _serviceProvider.Get().Result;
 }
コード例 #5
0
ファイル: Startup.cs プロジェクト: sircavalier/GTI_API
 public Startup(IConfiguration configuration)
 {
     Configuration = configuration;
     ConfigurationServiceProvider.SetConfigurationService(configuration);
 }