• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Configuration.AppSettingsReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: EncryptText

        public string EncryptText(string toEncrypt, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);

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

            if (useHashing)
            {
                MD5CryptoServiceProvider hashMd5 = new MD5CryptoServiceProvider();
                keyArray = hashMd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashMd5.Clear();
            }
            else keyArray = UTF8Encoding.UTF8.GetBytes(key);

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

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

            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
        }
开发者ID:wojsza,项目名称:sandbox,代码行数:27,代码来源:Encrypt.cs


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


示例18: LogToFile

        public LogToFile(LoggerMode mode)
        {
            modOfException = mode;
            readAppConfig = new AppSettingsReader ();

            path = (string)readAppConfig.GetValue ("Path", typeof (string));
        }
开发者ID:kartoshka7777,项目名称:BFU,代码行数:7,代码来源:LogToFile.cs


示例19: Service1

 /// <summary>
 /// Devuelve una instancia del servicio web.
 /// Inicializa la conexión SQL con la cadena de conexión guardada en el fichero Web.config
 /// </summary>
 public Service1()
 {
     this.Log = LogManager.GetLogger("SOREWebServiceLog");
     AppSettingsReader appSettingsReader = new AppSettingsReader();
     this.connection = new SqlConnection();
     this.connection.ConnectionString = (string)appSettingsReader.GetValue("SqlConnection.ConnectionString", typeof(string));
 }
开发者ID:moisvv,项目名称:SOREWebService,代码行数:11,代码来源:Service1.asmx.cs


示例20: Encrypt

        /// <summary>
        /// Encrypt a string using dual encryption method. Return a encrypted cipher Text
        /// </summary>
        /// <param name="toEncrypt">string to be encrypted</param>
        /// <param name="useHashing">use hashing? send to for extra secirity</param>
        /// <returns></returns>
        public static string Encrypt(string toEncrypt, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);

            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            // Get the key from config file
            string key = SecurityKey;
            //System.Windows.Forms.MessageBox.Show(key);
            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                keyArray = UTF8Encoding.UTF8.GetBytes(key);

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

            ICryptoTransform cTransform = tdes.CreateEncryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
            tdes.Clear();
            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
        }
开发者ID:nhannhan159,项目名称:room-management4,代码行数:34,代码来源:CryptorEngine.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Configuration.Configuration类代码示例发布时间:2022-05-26
下一篇:
C# Serialization.DesignerSerializationManager类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap