當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。