当前位置: 首页>>代码示例>>C#>>正文


C# AppSettingsReader.GetValue方法代码示例

本文整理汇总了C#中System.Configuration.AppSettingsReader.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# AppSettingsReader.GetValue方法的具体用法?C# AppSettingsReader.GetValue怎么用?C# AppSettingsReader.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Configuration.AppSettingsReader的用法示例。


在下文中一共展示了AppSettingsReader.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configuration

        static Configuration()
        {
            AppSettingsReader reader = new AppSettingsReader();
            try
            {
                ApplicationName = (string)reader.GetValue("ApplicationName", typeof(string));
            }
            catch (Exception)
            {
                ApplicationName = Assembly.GetExecutingAssembly().FullName;
            }

            try
            {
                EAEPMonitorURI = (string)reader.GetValue("EAEPMonitorURI", typeof(string));
            }
            catch (Exception)
            {
                EAEPMonitorURI = null;
            }

            try
            {
                EAEPHttpClientTimeout = (int)reader.GetValue("EAEPHttpClientTimeout", typeof(int));
            }
            catch (Exception)
            {
                EAEPHttpClientTimeout = 100;
            }
        }
开发者ID:adambird,项目名称:eaep,代码行数:30,代码来源:Configuration.cs

示例2: Configuration

        static Configuration()
        {
            AppSettingsReader reader = new AppSettingsReader();

            try
            {
                MonitorURI = (string)reader.GetValue("EAEPMonitorURI", typeof(string));
            }
            catch
            {
                MonitorURI = null;
            }

            try
            {
                DefaultPollInterval = (int)reader.GetValue("DefaultPollInterval", typeof(int));
            }
            catch
            {
                DefaultPollInterval = 30;
            }

            try
            {
                DefaultEAEPClientTimeout = (int)reader.GetValue("DefaultEAEPClientTimeout", typeof(int)) * 1000;
            }
            catch
            {
                DefaultEAEPClientTimeout = 30000;
            }
        }
开发者ID:adambird,项目名称:eaep,代码行数:31,代码来源:Configuration.cs

示例3: ManagmentService

        static ManagmentService()
        {
            ClientList = new List<IncomingClient>();

            AppSettingsReader _settingsReader = new AppSettingsReader();

            string value = _settingsReader.GetValue("ServerRunAtIP", type: typeof(string)) as string;

            if (!IPAddress.TryParse(value, out ServerIP))
                throw new Exception(message: "Appseting ServerRunAtIP Error");

            value = _settingsReader.GetValue("ServerRunAtPort", type: typeof(string)) as string;

            if (!int.TryParse(value, out ServerPort))
                throw new Exception(message: "Appseting ServerRunAtPort Error");

            value = _settingsReader.GetValue("MaxPoolClient", type: typeof(string)) as string;

            if (!int.TryParse(value, out MaxClient))
                throw new Exception(message: "Appseting MaxPoolClient Error");

            ServerEndPoint = new IPEndPoint(ServerIP, ServerPort);

            ServerLisenerSocket = new Socket(addressFamily: AddressFamily.InterNetwork, socketType: SocketType.Stream, protocolType: ProtocolType.Tcp);

            ServerLisenerSocket.Bind(ServerEndPoint);
        }
开发者ID:amoein,项目名称:AsyncClient,代码行数:27,代码来源:ManagmentService.cs

示例4: LoginPage

 public LoginPage(IWebDriver driver)
 {
     this.driver = driver;
     AppSettingsReader appSettingsReader = new AppSettingsReader();
     loginCred = (string)appSettingsReader.GetValue("login", typeof(string));
     passwordCred = (string)appSettingsReader.GetValue("password", typeof(string));
 }
开发者ID:AndriiChorniak,项目名称:Task-C-,代码行数:7,代码来源:LoginPage.cs

示例5: sendAlert

        public static Boolean sendAlert()
        {
            System.Configuration.AppSettingsReader reader = new AppSettingsReader();
            string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string postData = File.ReadAllText(Path.Combine(path,reader.GetValue("alertfile", typeof(string)).ToString()));

            var uri = reader.GetValue("url", typeof(string)).ToString();

            var request = (HttpWebRequest)WebRequest.Create(uri);
            request.Credentials = new NetworkCredential(reader.GetValue("user", typeof(string)).ToString(), reader.GetValue("password", typeof(string)).ToString());

            request.Method = WebRequestMethods.Http.Post;
            request.ContentType = "application/xml";

            request.ContentLength = postData.Length;
            try
            {

                StreamWriter postStream = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
                postStream.Write(postData);
                postStream.Close();

                var response = (HttpWebResponse)request.GetResponse();

            }
            catch (Exception ex)
            {
                //use some logger to log this
                return false;
            }
            return true;
        }
开发者ID:ReachPlus,项目名称:ReachPlusHotKey,代码行数:32,代码来源:SDKHelper.cs

示例6: Initialize

 public static void Initialize()
 {
     AppSettingsReader reader = new AppSettingsReader();
     Settings.MonoscapeAccessKey = (string)reader.GetValue("MonoscapeAccessKey", typeof(string));
     Settings.MonoscapeSecretKey = (string)reader.GetValue("MonoscapeSecretKey", typeof(string));
     Settings.LoadBalancerEndPointURL = (string)reader.GetValue("LoadBalancerEndPointURL", typeof(string));
 }
开发者ID:virajs,项目名称:monoscape,代码行数:7,代码来源:Initializer.cs

示例7: ValidateWithBriteVerify

        private void ValidateWithBriteVerify()
        {
            try
            {
                AppSettingsReader appsreader = new AppSettingsReader();
                string url = (string)appsreader.GetValue("briteverify_url", typeof(string)) + (string)appsreader.GetValue("briteverify_parameters", typeof(string));
                string apiKey = (string)appsreader.GetValue("briteverify_apikey", typeof(string));
                url = String.Format(url, eStatus.Email, apiKey);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";

                request.Timeout = 10000;
                string output = string.Empty;
                using (var response = request.GetResponse())
                {
                    using (var stream = new StreamReader(response.GetResponseStream()))
                    {
                        string emailResponse = stream.ReadToEnd();
                        briteVerifyResult = JsonConvert.DeserializeObject<BriteVerifyResult>(emailResponse);
                        if (briteVerifyResult.status.Equals("valid"))
                        {
                            eStatus.Status = "Valid";
                        }
                    }
                }
            }
            catch(Exception e)
            {
                throw e;
            }
        }
开发者ID:pherrera91,项目名称:email_permutations,代码行数:31,代码来源:Email.cs

示例8: Form1

        public Form1()
        {
            InitializeComponent();

            AppSettingsReader appReader = new AppSettingsReader();
            _url = appReader.GetValue("URL", typeof(string)).ToString();
            _savePath = appReader.GetValue("SavePath", typeof(string)).ToString();
        }
开发者ID:CharlesGeng,项目名称:study-c,代码行数:8,代码来源:Form1.cs

示例9: getActivator

        private LogActivator getActivator(String assembly, String classname)
        {
            LogActivator activator = new LogActivator ();
            AppSettingsReader reader = new AppSettingsReader ();

            activator.Assembly = (String)reader.GetValue (assembly, typeof(String));
            activator.Classname = (String)reader.GetValue (classname, typeof(String));

            return activator;
        }
开发者ID:Thomasch,项目名称:husacct_temp,代码行数:10,代码来源:LoggerProperties.cs

示例10: Index

        public ActionResult Index(string login, string senha)
        {
            try
            {
                string AD = "";
                AppSettingsReader reader = new AppSettingsReader();
                AD = (string)reader.GetValue("ACTIVE_DIRECTORY", typeof(string));
                var isValido = autenticacao.ValidarLogin(login, senha, AD);

                if (isValido)
                {
                    FormsAuthentication.SetAuthCookie(login, false);
                    Session["Usuario"] = login;
                    string dominio = (string)reader.GetValue("DOMINIO_ALIAS", typeof(string));
                    string bancoFrequencia = (string)reader.GetValue("BANCO_FREQUENCIA", typeof(string));

                    var pesquisa = autenticacao.isPesquisaValida(login, bancoFrequencia);

                    if (pesquisa)
                    {
                        ViewBag.Mensagem = "Usuário já preencheu o questionário";
                    }

                    var funcionarioDado = autenticacao.ObterDadosFuncionario(login, dominio, AD);//tipo funcionario qd dá ponto pega qq coisa dele

                    //Funcionario func = new Funcionario();
                    //var f = funcionario.ObterPesquisa(func);//qd é do tipo pega qq coisa dele

                    //foreach (var item in f)
                    //{
                    //    if (item.Funcao)
                    //    {

                    //    }

                    //}

                    if (funcionarioDado != null && funcionarioDado.Funcao.ToUpper().Contains("OPERADOR"))
                    {
                        return RedirectToAction("Cadastrar","Operador");
                    }
                    else
                    {
                        return RedirectToAction("Cadastrar","Supervisor");
                    }
                }
            }
            catch (Exception ex)
            {

                ViewBag.Mensagem = ex.Message;//pode ser uma msg no viewbag
            }
            return View();
        }
开发者ID:jeanmota15,项目名称:ProjetoMVC_Questionario,代码行数:54,代码来源:InicioController.cs

示例11: GetCoreAPI

        public static CoreAPI GetCoreAPI()
        {
            CoreAPI core;

                AppSettingsReader reader = new AppSettingsReader();

                core = new CoreAPI(reader.GetValue("AccessToken", typeof(string)).ToString(),
                    reader.GetValue("CoreID", typeof(string)).ToString());

                return core;
        }
开发者ID:yonglehou,项目名称:SparkIODotNet,代码行数:11,代码来源:Helper.cs

示例12: Main

 static void Main(string[] args)
 {
     Console.WriteLine("***** Reading <appSettings> Data *****\n");
     AppSettingsReader ar = new AppSettingsReader();
     int numbOfTimes = (int) ar.GetValue("RepeatCount", typeof (int));
     string textColor = (string) ar.GetValue("TextColor", typeof (string));
     Console.ForegroundColor = (ConsoleColor) Enum.Parse(typeof (ConsoleColor), textColor);
     for (int i = 0; i < numbOfTimes; i++)
     {
         Console.WriteLine("Howdy!");
     }
     Console.ReadLine();
 }
开发者ID:volkoff-pro,项目名称:Troelsen.CSharp,代码行数:13,代码来源:Program.cs

示例13: AdAuthenticator

 public AdAuthenticator()
 {
     var appSettings = new AppSettingsReader();
     try
     {
         LdapPath = appSettings.GetValue("LdapPath", typeof(string)).ToString();
     }
     catch { }
     try
     {
         LdapDomain = appSettings.GetValue("LdapDomain", typeof(string)).ToString();
     }
     catch { }
 }
开发者ID:RenanMOliveira1,项目名称:AdAuthenticator,代码行数:14,代码来源:AdAuthenticator.cs

示例14: frmConfiguracaoBancoDeDados_Load

        private void frmConfiguracaoBancoDeDados_Load(object sender, EventArgs e)
        {
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            string server = (string)settingsReader.GetValue("Servidor", typeof(String));
            string basedados = (string)settingsReader.GetValue("Base", typeof(String));
            string users = (string)settingsReader.GetValue("User", typeof(String));
            string passwd = Ferramentas.CryptoEngine.Decrypt((string)settingsReader.GetValue("Password", typeof(String)), true);
            txtServidor.Text = server;
            txtBancoDados.Text = basedados;
            txtUsuario.Text = users;
            txtSenha.Text = passwd;


        }
开发者ID:mrsalustiano,项目名称:VS_C,代码行数:14,代码来源:frmConfiguracaoBancoDeDados.cs

示例15: btnAccept_Click

 private void btnAccept_Click(object sender, EventArgs e)
 {
     if (dataBaseList.Where(v => v.Name == txtDataBaseName.Text).Count() == 0)
     {
         AppSettingsReader _appReader = new AppSettingsReader();
         String dbPath = _appReader.GetValue("DataBasePath", typeof(System.String)).ToString();
         String cfgPath = _appReader.GetValue("ConfigPath", typeof(System.String)).ToString();
         DataBase.CreateDataBase(txtDataBaseName.Text, dbPath, cfgPath);
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
         this.Close();
     }
     else
         MessageBox.Show((String.Format("La base {0} existe déjà.", txtDataBaseName.Text)), "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
 }
开发者ID:TMA-AQ,项目名称:AlgoQuest,代码行数:14,代码来源:FrmCreateDataBase.cs


注:本文中的System.Configuration.AppSettingsReader.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。