本文整理汇总了C#中System.Configuration.AppSettingsReader.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# System.Configuration.AppSettingsReader.GetValue方法的具体用法?C# System.Configuration.AppSettingsReader.GetValue怎么用?C# System.Configuration.AppSettingsReader.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Configuration.AppSettingsReader
的用法示例。
在下文中一共展示了System.Configuration.AppSettingsReader.GetValue方法的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: 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);
}
示例3: SetupFMSAxml
FMSAxml SetupFMSAxml()
{
var asr = new System.Configuration.AppSettingsReader();
var fms = new FMSAxml(
theServer: (string)asr.GetValue("TestServerName", typeof(string)),
theAccount: (string)asr.GetValue("TestServerUser", typeof(string)),
thePort: (int)asr.GetValue("TestServerPort", typeof(int)),
thePW: (string)asr.GetValue("TestServerPass", typeof(string))
);
return fms;
}
示例4: 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();
}
示例5: 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);
}
示例6: 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);
}
示例7: 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'");
}
}
示例8: 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();
}
示例9: 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();
}
}
示例10: 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"));
}
示例11: 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);
}
}
}
示例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: AmazonSQSMessageRetrievalInterface
public AmazonSQSMessageRetrievalInterface()
{
string awsAccessKeyId, awsSecretAccessKey;
try
{
System.Configuration.AppSettingsReader settings = new System.Configuration.AppSettingsReader();
awsAccessKeyId = (string)settings.GetValue("AwsAccessKeyId", typeof(string));
awsSecretAccessKey = (string)settings.GetValue("AwsSecretAccessKey", typeof(string));
queueUrl = (string)settings.GetValue("QueueUrl", typeof(string));
}
catch (InvalidOperationException)
{
throw new ApplicationException(
"Could not read AwsAccessKeyId or AwsSecretAccessKey from the configuration."
);
}
sqs = new AmazonSQSClient(awsAccessKeyId, awsSecretAccessKey);
}
示例15: ClientTests
public ClientTests()
{
#if PORTABLE
var appSettings = new System.Configuration.AppSettingsReader();
_storeLocation = appSettings.GetValue("BrightstarDB.StoreLocation", typeof (string)) as string;
#else
var appSettings = System.Configuration.ConfigurationManager.AppSettings;
_storeLocation = appSettings.Get("BrightstarDB.StoreLocation");
#endif
}