本文整理汇总了C#中System.Configuration.AppSettingsReader类的典型用法代码示例。如果您正苦于以下问题:C# System.Configuration.AppSettingsReader类的具体用法?C# System.Configuration.AppSettingsReader怎么用?C# System.Configuration.AppSettingsReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Configuration.AppSettingsReader类属于命名空间,在下文中一共展示了System.Configuration.AppSettingsReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadByKey
public static string ReadByKey(string key)
{
var reader = new System.Configuration.AppSettingsReader();
var resultObject = reader.GetValue(key, typeof(string));
if (resultObject == null)
{
throw new System.Exception("Không có key này trong DataConfig");
}
return resultObject.ToString();
}
示例2: Encrypt
public static string Encrypt(string text, bool useHash)
{
byte[] keyArray;
byte[] toEcryptArray = UTF8Encoding.UTF8.GetBytes(text);
System.Configuration.AppSettingsReader setingReader = new System.Configuration.AppSettingsReader();
string key = (string)setingReader.GetValue("SecurityKey", typeof(string));
if (useHash)
{
MD5CryptoServiceProvider hashMd5 = new MD5CryptoServiceProvider();
keyArray = hashMd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashMd5.Clear();
}
else
{
keyArray = UTF8Encoding.UTF8.GetBytes(key);
}
TripleDESCryptoServiceProvider crypto = new TripleDESCryptoServiceProvider();
crypto.Key = keyArray;
crypto.Mode = CipherMode.ECB;
crypto.Padding = PaddingMode.PKCS7;
ICryptoTransform transforme = crypto.CreateEncryptor();
byte[] result = transforme.TransformFinalBlock(toEcryptArray, 0, toEcryptArray.Length);
crypto.Clear();
return Convert.ToBase64String(result, 0, result.Length);
}
示例3: InitializeComponent
/// <summary>
/// M�todo necesario para admitir el Dise�ador, no se puede modificar
/// el contenido del m�todo con el editor de c�digo.
/// </summary>
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.datosInforme1 = new informe_1.datosInforme();
((System.ComponentModel.ISupportInitialize)(this.datosInforme1)).BeginInit();
//
// oleDbDataAdapter1
//
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Table", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("NOMBRE", "NOMBRE")})});
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = "SELECT \'\' AS NOMBRE FROM DUAL";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = ((string)(configurationAppSettings.GetValue("cadenaConexion", typeof(string))));
//
// datosInforme1
//
this.datosInforme1.DataSetName = "datosInforme";
this.datosInforme1.Locale = new System.Globalization.CultureInfo("es-ES");
this.datosInforme1.Namespace = "http://www.tempuri.org/datosInforme.xsd";
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.datosInforme1)).EndInit();
}
示例4: MaildirMessageRetrievalInterface
public MaildirMessageRetrievalInterface()
{
string maildirPath;
try
{
System.Configuration.AppSettingsReader settings = new System.Configuration.AppSettingsReader();
maildirPath = (string)settings.GetValue("MaildirPath", typeof(string));
}
catch (InvalidOperationException)
{
throw new ApplicationException(
"Could not read MaildirPath from the configuration."
);
}
if (!Directory.Exists(maildirPath))
{
throw new ApplicationException(
"MaildirPath does not exist."
);
}
if (!Directory.Exists(Path.Combine(maildirPath, "new"))
|| !Directory.Exists(Path.Combine(maildirPath, "cur"))
)
{
throw new ApplicationException(
"MaildirPath does not refer to a valid Maildir."
);
}
newDir = new DirectoryInfo(Path.Combine(maildirPath, "new"));
curDir = new DirectoryInfo(Path.Combine(maildirPath, "cur"));
}
示例5: RentalService
public RentalService()
{
System.Configuration.AppSettingsReader r = new System.Configuration.AppSettingsReader();
string path = (string)r.GetValue("DataFaceSimulationsettings", typeof(String));
//class name to load
string line;
// Read the file and display it line by line.
using (System.IO.StreamReader file = new System.IO.StreamReader(path))
{
line = file.ReadToEnd();
file.Close();
}
SimulationManager.Simulator s = new SimulationManager.Simulator();
//s.Check("DataFaceSimulationsettings: " + line);
if (line=="DataFacade1")
{
df = new DataFacade1();
//s.Check("DataFaceSimulationsettings: instantiated " + line);
}
else if (line == "DataFacade2")
{
df = new DataFacade2();
//s.Check("DataFaceSimulationsettings: instantiated " + line);
}
else
{
throw new Exception("DataFacade not loaded, check the following appsetting in web.config -> 'DataFaceSimulationsettings'");
}
}
示例6: Page_Load
// ////////////////////////////////////////////////////////////////////////
// EVENTS
//
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Security check
if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"]))
{
if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_REPORTS"]))
{
Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
}
}
// Initialize viewstate variables
System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader();
ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString();
// Prepare initial data for client
ddlProjectTimeState.SelectedValue = "Approved";
tkrdpStartDate.SelectedDate = DateTime.Now;
tkrdpEndDate.SelectedDate = DateTime.Now;
// Register delegates
this.RegisterDelegates();
}
else
{
// Register delegates
this.RegisterDelegates();
}
}
示例7: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.cnOrderTrackerDB = new System.Data.SqlClient.SqlConnection();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlCommand2 = new System.Data.SqlClient.SqlCommand();
this.custData1 = new OrderTrackerv2.HOOemployees.Secure.CustData();
((System.ComponentModel.ISupportInitialize)(this.custData1)).BeginInit();
//
// cnOrderTrackerDB
//
this.cnOrderTrackerDB.ConnectionString = ((string)(configurationAppSettings.GetValue("cnOrderTrackerDB.ConnectionString", typeof(string))));
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.SelectCommand = this.sqlCommand2;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Customers", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("SID", "SID"),
new System.Data.Common.DataColumnMapping("name", "name"),
new System.Data.Common.DataColumnMapping("email", "email"),
new System.Data.Common.DataColumnMapping("phone", "phone")})});
//
// sqlCommand2
//
this.sqlCommand2.CommandText = "SELECT SID, name, phone, email FROM dbo.Customers";
this.sqlCommand2.Connection = this.cnOrderTrackerDB;
//
// custData1
//
this.custData1.DataSetName = "CustData";
this.custData1.Locale = new System.Globalization.CultureInfo("en-US");
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.custData1)).EndInit();
}
示例8: Encrypt
public static string Encrypt(string toEncrypt, bool useHashing)
{
byte[] keyArray;
byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);
System.Configuration.AppSettingsReader settingsReader = new System.Configuration.AppSettingsReader();
// Get the key from config file
string key = "9078a2e6-ed71-4607-b4d1-b68993880501";
//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);
}
示例9: GetApplicationSecurityContext
/// <summary>
/// Gets the application security context.
/// </summary>
/// <returns></returns>
public ApplicationSecurityContext GetApplicationSecurityContext()
{
System.Configuration.AppSettingsReader appSettingsReader = new System.Configuration.AppSettingsReader();
var appGuidstr = appSettingsReader.GetValue("gatekeeper-app-guid", typeof(string)) as string;
var appGuid = new Guid(appGuidstr);
return new ApplicationSecurityContext(appGuid);
}
示例10: GenerateMethodMap
public static void GenerateMethodMap()
{
Mil = new MethodInclusion();
string line;
System.Configuration.AppSettingsReader r = new System.Configuration.AppSettingsReader();
string path = (string)r.GetValue("MethodInclusionList", typeof(String));
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader(path);
while ((line = file.ReadLine()) != null)
{
Mil.list.Add(line, line);
}
file.Close();
//read a file which contains information on what to apply
//the file will be a key and values list, method name, followed by sleep time,
//a boolean to throw method exceptions or not and a bool to hold onto a unmanaged reference
Type myType = (typeof(RentalServiceClient));
// Get the public methods.
sim = new Sim();
MethodInfo[] myArrayMethodInfo = myType.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
// initialise methods
foreach (MethodInfo methodInfo in myArrayMethodInfo)
{
SimulationAction sa = new SimulationAction();
sa.methodname = methodInfo.Name;
sa.consumeheap = false;
sa.sleep = 1;
sa.throwException = false;
sa.consumecpu = false;
if (Mil.list.ContainsKey(methodInfo.Name))
{
sim.methodSimulationMap.Add(sa);
}
}
}
示例11: Conexion
public Conexion()
{
System.Configuration.AppSettingsReader config = new System.Configuration.AppSettingsReader();
con = new SqlConnection();
//Data Source=ANDROMEDA\SQL2008R2;Initial Catalog=BDSGCRM;User ID=sa;Password=sqlserver
this.con.ConnectionString = (@"Data Source=ORION\SQL2008R2;Initial Catalog=TAXY_EMP;User ID=sa;Password=sqlserver");
strCadena = this.con.ConnectionString;
}
示例12: Encrypt
/// <summary>
/// Encrypts plaintext using AES 128bit key and a Chain Block Cipher and returns a base64 encoded string
/// </summary>
/// <param name="plainText">Plain text to encrypt</param>
/// <param name="key">Secret key</param>
/// <returns>Base64 encoded string</returns>
public static String Encrypt(String plainText, string securityKey = "")
{
System.Configuration.AppSettingsReader settingsReader = new System.Configuration.AppSettingsReader();
// Key web.config'den alınıyor
string key = securityKey == "" ? (string)settingsReader.GetValue("SecurityKey", typeof(String)) : HttpUtility.UrlDecode(securityKey);
var plainBytes = Encoding.UTF8.GetBytes(plainText);
return Convert.ToBase64String(Encrypt(plainBytes, GetRijndaelManaged(key)));
}
示例13: Page_Load
// ////////////////////////////////////////////////////////////////////////
// EVENTS
//
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Security check
if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"]))
{
if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_REPORTS"]))
{
Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
}
}
// Initialize viewstate variables
System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader();
ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString();
// Tag page
hdfCompanyId.Value = Convert.ToInt32(Session["companyID"]).ToString();
// Databind
ddlClient.DataBind();
ddlProject.DataBind();
// Prepare initial data
ddlProjectTimeState.SelectedValue = "(All)";
ddlClient.SelectedIndex = 0;
ddlProject.SelectedIndex = 0;
tkrdpStartDate.SelectedDate = DateTime.Now;
tkrdpEndDate.SelectedDate = DateTime.Now;
ProjectTimeWorkList projectTimeWorkList = new ProjectTimeWorkList(new DataSet());
projectTimeWorkList.LoadAndAddItem("(All)");
ddlTypeOfWork.DataSource = projectTimeWorkList.Table;
ddlTypeOfWork.DataValueField = "Work_";
ddlTypeOfWork.DataTextField = "Work_";
ddlTypeOfWork.DataBind();
ddlTypeOfWork.SelectedIndex = 0;
ProjectTimeWorkFunctionList projectTimeWorkFunctionList = new ProjectTimeWorkFunctionList(new DataSet());
projectTimeWorkFunctionList.LoadAndAddItem("(All)", "-1");
ddlFunction.DataSource = projectTimeWorkFunctionList.Table;
ddlFunction.DataValueField = "Function_";
ddlFunction.DataTextField = "Function_";
ddlFunction.DataBind();
ddlFunction.SelectedIndex = 0;
// Register delegates
this.RegisterDelegates();
}
else
{
// Register delegates
this.RegisterDelegates();
}
}
示例14: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.spellButton = new System.Windows.Forms.Button();
this.demoRichText = new System.Windows.Forms.RichTextBox();
this.spelling = new NetSpell.SpellChecker.Spelling(this.components);
this.wordDictionary = new NetSpell.SpellChecker.Dictionary.WordDictionary(this.components);
this.SuspendLayout();
//
// spellButton
//
this.spellButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.spellButton.Location = new System.Drawing.Point(344, 368);
this.spellButton.Name = "spellButton";
this.spellButton.Size = new System.Drawing.Size(80, 23);
this.spellButton.TabIndex = 3;
this.spellButton.Text = "Spell Check";
this.spellButton.Click += new System.EventHandler(this.spellButton_Click);
//
// demoRichText
//
this.demoRichText.AcceptsTab = true;
this.demoRichText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.demoRichText.AutoWordSelection = true;
this.demoRichText.Location = new System.Drawing.Point(16, 16);
this.demoRichText.Name = "demoRichText";
this.demoRichText.ShowSelectionMargin = true;
this.demoRichText.Size = new System.Drawing.Size(408, 344);
this.demoRichText.TabIndex = 2;
this.demoRichText.Text = "Becuase people are realy bad spelers, ths produc was desinged to prevent speling " +
"erors in a text area like ths.";
//
// spelling
//
this.spelling.Dictionary = this.wordDictionary;
this.spelling.ReplacedWord += new NetSpell.SpellChecker.Spelling.ReplacedWordEventHandler(this.spelling_ReplacedWord);
this.spelling.EndOfText += new NetSpell.SpellChecker.Spelling.EndOfTextEventHandler(this.spelling_EndOfText);
this.spelling.DeletedWord += new NetSpell.SpellChecker.Spelling.DeletedWordEventHandler(this.spelling_DeletedWord);
//
// wordDictionary
//
this.wordDictionary.DictionaryFolder = ((string)(configurationAppSettings.GetValue("wordDictionary.DictionaryFolder", typeof(string))));
//
// DemoForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(440, 406);
this.Controls.Add(this.spellButton);
this.Controls.Add(this.demoRichText);
this.Name = "DemoForm";
this.Text = "NetSpell Demo";
this.ResumeLayout(false);
}
示例15: CCTerminal
public CCTerminal()
{
cc = new CardConsumer();
System.Configuration.AppSettingsReader r = new System.Configuration.AppSettingsReader();
string ip = (string)r.GetValue("CreditCardServiceIP", typeof(String));
string port = (string)r.GetValue("CreditCardServicePort", typeof(String));
cc.Bind(ip, port);
}