本文整理汇总了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;
}
}
示例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;
}
}
示例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);
}
示例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));
}
示例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;
}
示例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));
}
示例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;
}
}
示例8: Form1
public Form1()
{
InitializeComponent();
AppSettingsReader appReader = new AppSettingsReader();
_url = appReader.GetValue("URL", typeof(string)).ToString();
_savePath = appReader.GetValue("SavePath", typeof(string)).ToString();
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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 { }
}
示例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;
}
示例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);
}