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


C# Configuration.AppSettingsReader类代码示例

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


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

示例1: 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

示例2: btRestore_Click

        private void btRestore_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog d = new OpenFileDialog();
                d.Filter = "Backup Files|*.bak";
                d.ShowDialog();
                if (d.FileName != "")
                {
                    System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
                    string basedados = (string)settingsReader.GetValue("Base", typeof(String));

                    String nomeBanco = basedados;
                    String localBackup = d.FileName;

                    String conexao = DadosDaConexao.srtConnMaster;
                
                    this.Cursor = Cursors.WaitCursor;
                    SQLServerBackup.RestauraDatabase(conexao, nomeBanco, d.FileName);
                    Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                    MessageBox.Show("Backup restaurado com sucesso!!!!", "Aviso", MessageBoxButtons.OK,MessageBoxIcon.Information);
               
                    this.Cursor = Cursors.Default;

                }
            }
            catch (Exception erro)
            {
                this.Cursor = Cursors.Default;
                Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                MessageBox.Show(erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:mrsalustiano,项目名称:VS_C,代码行数:33,代码来源:frmBackupBancoDeDados.cs

示例3: OnStart

        /// <summary>
        /// When implemented in a derived class, executes when a Start command is sent to the service by the Service Control Manager (SCM) or when the operating system starts (for a service that starts automatically). Specifies actions to take when the service starts.
        /// </summary>
        /// <param name="args">Data passed by the start command.</param>
        protected override void OnStart(string[] args)
        {
            System.Configuration.AppSettingsReader appReader = new System.Configuration.AppSettingsReader();
            this.timer1 = new System.Timers.Timer(Convert.ToDouble(appReader.GetValue("Interval", typeof(string))));

            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = System.AppDomain.CurrentDomain.BaseDirectory;
            /* Watch for changes in LastAccess and LastWrite times, and
               the renaming of files or directories. */
            watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
               | NotifyFilters.FileName | NotifyFilters.DirectoryName;

            // Only watch text files.
            watcher.Filter = "*.config";

            // Add event handlers.
            watcher.Changed += new FileSystemEventHandler(OnChanged);

            // Begin watching.
            watcher.EnableRaisingEvents = true;
            this.mutex = new Mutex(false);
            this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.Timer1_Elapsed);
            this.timer1.Start();

            string ipToAdd = appReader.GetValue("Host", typeof(string)).ToString();
            EventLog.WriteEntry("Firewall Updater monitoring host '" + ipToAdd + "'");
        }
开发者ID:chrispont,项目名称:DynamicDNS-Firewall-Updater,代码行数:31,代码来源:Service1.cs

示例4: 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

示例5: DecryptString

        /// <summary>
        /// Decrypts a cipher sting
        /// </summary>
        /// <param name="cipherString">String to decrypt</param>
        /// <returns>Decrypted string</returns>
        public string DecryptString(string cipherString)
        {
            try
            {
                byte[] keyArray;
                byte[] toEncryptArray = Convert.FromBase64String(cipherString);

                System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
                string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));

                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateDecryptor();
                byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

                tdes.Clear();
                return UTF8Encoding.UTF8.GetString(resultArray);
            }
            catch (Exception e)
            {
                Console.WriteLine("DecryptString exception : " + e.ToString());
                return null;
            }
        }
开发者ID:Neeelsie,项目名称:REII422_Desktop,代码行数:36,代码来源:Cryptography.cs

示例6: Jqgrid2_DataRequesting

 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Jqgrid2_DataRequesting(object sender, Trirand.Web.UI.WebControls.JQGridDataRequestEventArgs e)
 {
     string ssd = (string)Session["sd_EnvExceptionDailyRpt "];
     string sed = (string)Session["ed_EnvExceptionDailyRpt "];
     if ((ssd == null) || (sed == null))
     {
         ssd = sd.Text;
         sed = ed.Text;
     }
     if ((ssd != null) && (sed != null)&&(ssd != "") && (sed != ""))
     {
         DataSet ds = new DataSet();
         try
         {
             AppSettingsReader asr = new AppSettingsReader();
             string dbconn = (string)asr.GetValue("dbconn", typeof(string));
             using (SqlConnection conn = new SqlConnection(dbconn))
             {
                 conn.Open();
                 SqlCommand sqlcomm = new SqlCommand("select * from V_EnvException_DayReport where timestamps<='" + sed + "' and timestamps>='" + ssd + "' order by timestamps desc", conn);
                 SqlDataAdapter sqladapter = new SqlDataAdapter(sqlcomm);
                 sqladapter.Fill(ds);
                 conn.Close();
             }
         }
         catch (Exception)
         {
         }
         Jqgrid2.DataSource = ds.Tables[0];
         Jqgrid2.DataBind();
     }
 }
开发者ID:zhiqi1001,项目名称:EPAReportingServices,代码行数:37,代码来源:EnvExceptionDailyRpt2.aspx.cs

示例7: WebSiteConfigInfo

        public WebSiteConfigInfo(AppSettingsReader myAppReader)
            : base(myAppReader)
        {
            BaseConnectionString = ConfigurationManager.ConnectionStrings["EzLookerDB"].ConnectionString;
            DryTestDB = ConfigurationManager.ConnectionStrings["DryTestDB"].ConnectionString;

            try { EmailYak_Domain = readAppSetting("EmailYak_Domain", myAppReader).Value.ToString(); }
            catch { EmailYak_Domain = @"ezlooker.skunkdemo.com"; }

            try { EmailYak_BaseURL = readAppSetting("EmailYak_BaseURL", myAppReader).Value.ToString(); }
            catch { EmailYak_BaseURL = @"https://api.emailyak.com/v1/yausmoq46fjhvga/json"; }

            try { EmailYak_CallBackURL = readAppSetting("EmailYak_CallBackURL", myAppReader).Value.ToString(); }
            catch { EmailYak_CallBackURL = @""; }

            try { EmailYak_IsPushEmail = bool.Parse(readAppSetting("EmailYak_IsPushEmail", myAppReader).Value.ToString().ToLower()); }
            catch { EmailYak_IsPushEmail = string.IsNullOrEmpty(EmailYak_CallBackURL) ? false : true; }

            //make sure IsPushMail is true, only when requested and the CallBackURL is also provided.
            EmailYak_IsPushEmail = EmailYak_IsPushEmail && !string.IsNullOrEmpty(EmailYak_CallBackURL);

            try { EmailYak_MessageFooter = readAppSetting("EmailYak_MessageFooter", myAppReader).Value.ToString(); }
            catch { EmailYak_MessageFooter = string.Empty; }

        }
开发者ID:eddiev,项目名称:eddiev.github.com,代码行数:25,代码来源:WebSiteConfigInfo.cs

示例8: 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

示例9: WorkTime_DoWork

 private void WorkTime_DoWork(object sender, DoWorkEventArgs e)
 {
     AppSettingsReader asr = new AppSettingsReader();
     int workTime = 60 * 1000 * (int)asr.GetValue("PomodoroPeriod", typeof(int));
     BackgroundWorker worker = (sender as BackgroundWorker);
     System.Threading.Thread.Sleep(workTime);
 }
开发者ID:Mellen,项目名称:Pomodoro,代码行数:7,代码来源:MainWindow.xaml.cs

示例10: JQGrid2_DataRequesting

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void JQGrid2_DataRequesting(object sender, JQGridDataRequestEventArgs e)
        {
            DataSet ds = new DataSet();
            try
            {
                AppSettingsReader asr = new AppSettingsReader();
                string dbconn = (string)asr.GetValue("dbconn", typeof(string));
                using (SqlConnection conn = new SqlConnection(dbconn))
                {
                    conn.Open();
                    SqlCommand sqlcomm = new SqlCommand("select * from v_abnormal_NOXSO2_Relevant2 where id2 = '" + e.ParentRowKey.ToString() + "'", conn);
                    SqlDataAdapter sqladapter = new SqlDataAdapter(sqlcomm);
                    sqladapter.Fill(ds);
                    conn.Close();
                }
            }
            catch (Exception)
            {

            }
            Jqgrid2.DataSource = ds.Tables[0];
            Jqgrid2.DataBind();

            //
        }
开发者ID:zhiqi1001,项目名称:EPAReportingServices,代码行数:30,代码来源:ExceptionDetails2.aspx.cs

示例11: EnsureSettingsLoaded

 private static void EnsureSettingsLoaded()
 {
     if (!settingsInitialized)
     {
         lock (appSettingsLock)
         {
             if (!settingsInitialized)
             {
                 try
                 {
                     AppSettingsReader reader = new AppSettingsReader();
                     object value = null;
                     if (TryGetValue(reader, AllowTransparentProxyMessageKeyName, typeof(bool), out value))
                     {
                         allowTransparentProxyMessageValue = (bool)value;
                     }
                     else
                     {
                         allowTransparentProxyMessageValue = AllowTransparentProxyMessageDefaultValue;
                     }
                 }
                 catch
                 {
                     // AppSettingsReader.ctor will throw if no appSettings section
                 }
                 finally
                 {
                     settingsInitialized = true;
                 }
             }
         }
     }
 }
开发者ID:salim18,项目名称:DemoProject2,代码行数:33,代码来源:AppSettings.cs

示例12: SampleContext

 public SampleContext(string databasePassword)
 {
     var connectionString = new AppSettingsReader().GetValue("sampleDb", typeof (string)).ToString();
     connectionString = connectionString.Replace("{{password}}", databasePassword);
     var client = new MongoClient(connectionString);
     _db = client.GetDatabase(connectionString.Split('/').Last());
 }
开发者ID:ewu-school-projects,项目名称:sample-mongodb-dotnet,代码行数:7,代码来源:SampleContext.cs

示例13: 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

示例14: PersistenceMgr

 public PersistenceMgr()
 {
     AppSettingsReader config = new AppSettingsReader();
     String connector = (String)config.GetValue("Connector", typeof(String));
     con = new OdbcConnection(connector);
     con.Open();
 }
开发者ID:philipp-spiess,项目名称:workflow-web,代码行数:7,代码来源:PersistenceMgr.cs

示例15: ReadConfigSettings

        private static ApplicationGridSettings ReadConfigSettings()
        {
            AppSettingsReader reader = new AppSettingsReader();

            ApplicationGridSettings settings = new ApplicationGridSettings();
            settings.MonoscapeAccessKey = (string)reader.GetValue("MonoscapeAccessKey", typeof(string));
            settings.MonoscapeSecretKey = (string)reader.GetValue("MonoscapeSecretKey", typeof(string));
            settings.DashboardServiceURL = (string)reader.GetValue("DashboardServiceURL", typeof(string));
            settings.NodeControllerServiceURL = (string)reader.GetValue("NodeControllerServiceURL", typeof(string));
            settings.FileServerServiceURL = (string)reader.GetValue("FileServerServiceURL", typeof(string));
            settings.FileServerServiceNetTcpURL = (string)reader.GetValue("FileServerServiceNetTcpURL", typeof(string));
            settings.FileServerServiceNetPipeURL = (string)reader.GetValue("FileServerServiceNetPipeURL", typeof(string));

            settings.ApplicationStoreFolder = (string)reader.GetValue("ApplicationStoreFolder", typeof(string));
            settings.ApplicationStorePath = Path.GetFullPath(settings.ApplicationStoreFolder);
            settings.SQLiteConnectionString = (string)reader.GetValue("SQLiteConnectionString", typeof(string));

            settings.LbApplicationGridEndPointUrl = (string)reader.GetValue("LbApplicationGridEndPointUrl", typeof(string));
            settings.NodeFileServerEndPointURL = (string)reader.GetValue("NodeFileServerEndPointURL", typeof(string));
            settings.NodeEndPointURL = (string)reader.GetValue("NodeEndPointURL", typeof(string));

            settings.ApFileReceiveSocketPort = (int)reader.GetValue("ApFileReceiveSocketPort", typeof(int));
            settings.NcFileTransferSocketPort = (int)reader.GetValue("NcFileTransferSocketPort", typeof(int));

            settings.IaasName = (string)reader.GetValue("IaasName", typeof(string));
            settings.IaasAccessKey = (string)reader.GetValue("IaasAccessKey", typeof(string));
            settings.IaasSecretKey = (string)reader.GetValue("IaasSecretKey", typeof(string));
            settings.IaasServiceURL = (string)reader.GetValue("IaasServiceURL", typeof(string));
            settings.IaasKeyName = (string)reader.GetValue("IaasKeyName", typeof(string));
            return settings;
        }
开发者ID:virajs,项目名称:monoscape,代码行数:31,代码来源:Initializer.cs


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