public KeyValueInternalCollection(AppSettingsSection root) { _root = root; foreach (KeyValueConfigurationElement element in _root.Settings) { base.Add(element.Key, element.Value); } }
public virtual void OnBindToElementCollection(AppSettingsSection appSettings, CommanderSection commanderSettings, CurrentConfigurationElementCollection elementCollection) { var handler = BindToElementCollection; if (handler != null) { handler(this, new BindToElementCollectionEventArgs(appSettings, commanderSettings, elementCollection)); } }
public virtual void OnBindToElement(AppSettingsSection appSettings, CommanderSection commanderSettings, NamedConfigurationElement element) { var handler = BindToElement; if (handler != null) { handler(this, new BindToElementEventArgs(appSettings, commanderSettings, element)); } }
private static NameValueCollection BuildAppSettingsCollection(AppSettingsSection section) { var nvc = new NameValueCollection(); foreach (KeyValueConfigurationElement pair in section.Settings) { nvc.Add(pair.Key, pair.Value); } return nvc; }
public CommanderManager(ExportProvider container, AppSettingsSection appSettings, CommanderSection commanderSettings, IEnhancedFileSystemWatcherFactory enhancedFileSystemWatcherFactory) { NLogAppender.Initialize(); _container = container; _appSettings = appSettings; _commanderSettings = commanderSettings; _folderWatcherService = new FolderWatcherService(enhancedFileSystemWatcherFactory); IsRunning = false; }
protected override void Arrange() { base.Arrange(); AppSettings = new AppSettingsSection(); AppSettings.Settings.Add(new KeyValueConfigurationElement("Setting1", "Value1")); AppSettings.Settings.Add(new KeyValueConfigurationElement("Setting2", "Value2")); AppSettingsView = SectionViewModel.CreateSection(Container, "appSettings", AppSettings); }
public ConfigurationProvider(string assemblyLocation) { Configuration = ConfigurationManager.OpenExeConfiguration(assemblyLocation); if (!Configuration.HasFile) { throw new ApplicationException(string.Format("Configuration file not found: {0}", Configuration.FilePath)); } _appSettings = Configuration.AppSettings; }
private AppSettingsSection GetModuleSection(Configuration configuration) { var section = (AppSettingsSection) configuration.GetSection(Guid); if (section == null) { var newSection = new AppSettingsSection(); newSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToRoamingUser; configuration.Sections.Add(Guid, newSection); section = newSection; } return section; }
protected override void Arrange() { base.Arrange(); AppSettingsSection AppSettings = new AppSettingsSection(); AppSettings.Settings.Add(new KeyValueConfigurationElement("Setting1", "Value1")); AppSettings.Settings.Add(new KeyValueConfigurationElement("Setting2", "Value2")); settings = new MockAppSettingsViewModel(Container, "appSettings", AppSettings); settings.ElementViewModelServiceDependencies(Container.Resolve<ElementLookup>(), Container.Resolve<IApplicationModel>()); }
private AppSettingsSection GetConfiguration() { var configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming); AppSettingsSection section; if ((section = configuration.Sections["AppSettings"] as AppSettingsSection) == null) { section = new AppSettingsSection(); section.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser; configuration.Sections.Add("AppSettings", section); configuration.Save(); } return section; }
public StartHostingDlg() { StartHostingParameters = new StartHostingParams (); config = ConfigurationManager.OpenExeConfiguration (ConfigurationUserLevel.None); appSettings = (AppSettingsSection) config.GetSection ("appSettings"); List<string> keys = new List<string> (appSettings.Settings.AllKeys); if (keys.Contains ("lastHostPort")) StartHostingParameters.Port = int.Parse (appSettings.Settings["lastHostPort"].Value); if (keys.Contains ("lastNickname")) StartHostingParameters.Nickname = appSettings.Settings["lastNickname"].Value; DataContext = StartHostingParameters; InitializeComponent (); }
protected void Page_Load(object sender, EventArgs e) { CQGJPassportEntities cqgj = new CQGJPassportEntities(); if (Request.QueryString["ID"] != null) { if (Request.QueryString["userID"] != null) { int iID = int.Parse(Request.QueryString["userID"].ToString()); User usertemp = (from u in cqgj.User where u.UserID == iID select u).First(); Session["userobject"] = usertemp; } if (Request.QueryString["orgID"] != null) { string orgID = (Request.QueryString["orgID"].ToString()); b01 orgtemp = (from b in cqgj.b01 where b.b0111 == orgID select b).First(); Session["Org"] = orgtemp; } try { if (Session["userobject"] != null || Session["Org"] != null) { int iID = int.Parse(Request.QueryString["ID"].ToString()); User user; user = new User(); user = (from u in cqgj.User where u.UserID == iID select u).First(); Response.ContentType = user.PhotoType; Response.BinaryWrite((byte[])user.Photo); } else { System.Configuration.AppSettingsSection apsetting = new AppSettingsSection(); string str = apsetting.Settings["ssologin"].ToString(); Response.Redirect(str + "?url=" + System.Web.HttpUtility.UrlEncode(Request.Url.ToString())); } } catch { } } }
//##### INICIALIZA LOS DATOS DEL APPCONFIG ##### public ClassModConfig() { try { MiAppConfig = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath); //Se abre el app.config CadenaConexion = (ConnectionStringsSection)MiAppConfig.GetSection("connectionStrings"); //Obtengo la cadena de conexion MiConfig = (AppSettingsSection)MiAppConfig.GetSection("appSettings"); //Obtengo la seccion appSettings MiCnx = ConfigurationManager.ConnectionStrings["EnterpriseSolution.Properties.Settings.bdnominaConnectionString"]; //capturo cadena de conexion Estado = ConfigurationManager.AppSettings["Validador"]; Licencia = ConfigurationManager.AppSettings["Licencia"]; InfEmp = ConfigurationManager.AppSettings["InfEmp"]; Skins = ConfigurationManager.AppSettings["Skins"]; Update = ConfigurationManager.AppSettings["Update"]; } catch (Exception ex) { MsjErr.MsjBox(1, "ERR001-01", "No se pueden leer todos los valores del app.config - " + ex.ToString()); Environment.Exit(0); } }
public ConnectDlg() { InitializeComponent (); ConnectParameters = new ConnectParams(); config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); appSettings = (AppSettingsSection)config.GetSection("appSettings"); List<string> keys = new List<string>(appSettings.Settings.AllKeys); if (keys.Contains("lastHostname")) ConnectParameters.Hostname = appSettings.Settings["lastHostname"].Value; if (keys.Contains("lastPort")) ConnectParameters.Port = int.Parse(appSettings.Settings["lastPort"].Value); if (keys.Contains("lastNickname")) ConnectParameters.Nickname = appSettings.Settings["lastNickname"].Value; DataContext = ConnectParameters; ConnectParameters.PropertyChanged += ConnectParameters_PropertyChanged; _defaultTextboxTemplate = nickname.Template; }
public WebConfigSettingService(string configLocation = null, bool isVirtualPath = false) : base(configLocation) { //http://stackoverflow.com/questions/4738/using-configurationmanager-to-load-config-from-an-arbitrary-location/4746#4746 try { if (configLocation != null) { if (isVirtualPath) { _configuration = WebConfigurationManager.OpenWebConfiguration(configLocation); _settings = _configuration.AppSettings; } else { //ConfigurationFileMap fileMap = new ConfigurationFileMap(configLocation); //Path to your config file //_configuration = ConfigurationManager.OpenMappedMachineConfiguration(fileMap); ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = configLocation; _configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); //_settings = (AppSettingsSection)_configuration.GetSection("AppSettings"); _settings = _configuration.AppSettings; } } else { //No config file was sent in so we use default one _configuration = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current != null ? HttpContext.Current.Request.ApplicationPath : null); _settings = _configuration.AppSettings; } } catch (ConfigurationErrorsException e) { var eNew = new ConfigurationErrorsException("Could not load configuration. Either incorrect path was sent in or if no path was sent in web.config could not be found where expected",e); throw eNew; } }
static ConfigManager() { try { if (!Directory.Exists(PublicFolderPath)) { Directory.CreateDirectory(PublicFolderPath); } bool existed = true; if (!File.Exists(PublicConfigFilePath)) { CopyConfigFile(); existed = false; } ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap() { ExeConfigFilename = PublicConfigFilePath }; config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); appSection = config.AppSettings;//(AppSettingsSection)config.GetSection("appSettings"); if (!existed) { SetConfigurationValue(KeyName.version, Assembly.GetEntryAssembly().GetName().Version.ToString()); } } catch { } }
protected readonly string sparkCLRHome = Environment.GetEnvironmentVariable("SPARKCLR_HOME"); //set by sparkclr-submit.cmd #endregion Fields #region Constructors internal SparkCLRConfiguration(System.Configuration.Configuration configuration) { appSettings = configuration.AppSettings; }
public GlobalVars() { Configuration myDllConfig = ConfigurationManager.OpenExeConfiguration(this.GetType().Assembly.Location); myDllConfigAppSettings = (AppSettingsSection)myDllConfig.GetSection("appSettings"); }
private void Initialization(string ConfigPath) { fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = ConfigPath; config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); AppSettings = (AppSettingsSection)config.GetSection("appSettings"); ConnectionStrings = (ConnectionStringsSection)config.GetSection("connectionStrings"); }
/// <summary> /// 子类重载实现资源释放逻辑 /// </summary> /// <param name="disposing">从Dispose调用(释放所有资源)还是析构函数调用(释放非托管资源)</param> protected override void OnDispose(Boolean disposing) { base.OnDispose(disposing); if (disposing) { // 释放托管资源 fileMap = null; AppSettings = null; ConnectionStrings = null; config = null; } cacheLock.Dispose(); // 释放非托管资源 }
/// <summary>GetSection 用于改更AppSettings节点对像</summary> /// <param name="GroupsName"></param> /// <param name="SectionsName"></param> /// <param name="Create">如果节点不存在是否创建</param> public void GetAppSection(string GroupsName, string SectionsName, bool Create) { if (DME_Validation.IsNull(SectionsName)) { return; } if (DME_Validation.IsNull(GroupsName)) { if (!DME_Validation.IsNull(config.GetSection(SectionsName))) { AppSettings = (AppSettingsSection)config.GetSection(SectionsName); } else { if (Create) { AppSettings = new AppSettingsSection(); config.Sections.Add(SectionsName, AppSettings); } } } else { if (!DME_Validation.IsNull(config.GetSection(string.Format(@"{0}/{1}", GroupsName, SectionsName)))) { AppSettings = (AppSettingsSection)config.GetSection(string.Format(@"{0}/{1}", GroupsName, SectionsName)); } else { if (Create) { AppSettings = new AppSettingsSection(); if (config.GetSectionGroup(GroupsName) != null) { config.SectionGroups[GroupsName].Sections.Add(SectionsName, AppSettings); } else { config.SectionGroups.Add(GroupsName, new ConfigurationSectionGroup()); config.SectionGroups[GroupsName].Sections.Add(SectionsName, AppSettings); } } } } }
public AntiVirusElementCollectionPanelDataModel(AppSettingsSection appSettings) { AppSettings = appSettings; }
protected ConfigurationSection GetDefaultSection(string sectionName) { object section = GetAppWebSection(sectionName); if (section != null) { // AppSettingsSection doesn't returned from ConfirationManager, instead returned NameValueCollection. if (IsAppSettingsSection(sectionName)) { var appSection = new AppSettingsSection(); var appSettingsCollection = section as NameValueCollection; if (appSettingsCollection != null) for (int i = 0; i < appSettingsCollection.Count; i++) appSection.Settings.Add(appSettingsCollection.GetKey(i), appSettingsCollection[i]); return appSection; } } return section as ConfigurationSection; }
public CommandLineElementCollectionPanelDataModel(AppSettingsSection appSettings) { AppSettings = appSettings; }
private void saveSetting(AppSettingsSection app, string name, string value) { if (app.Settings[name] == null) app.Settings.Add(name, value); else app.Settings[name].Value = value; }
/// <summary> /// Initializes a new instance of the <see cref="PSRecoveryServicesClient" /> class with /// required current subscription. /// </summary> /// <param name="azureSubscription">Azure Subscription</param> public PSRecoveryServicesClient(IAzureProfile azureProfile) { System.Configuration.Configuration siteRecoveryConfig = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetExecutingAssembly().Location); System.Configuration.AppSettingsSection appSettings = (System.Configuration.AppSettingsSection)siteRecoveryConfig.GetSection("appSettings"); string resourceNamespace = string.Empty; string resourceType = string.Empty; // Get Resource provider namespace and type from config only if Vault context is not set // (hopefully it is required only for Vault related cmdlets) if (string.IsNullOrEmpty(asrVaultCreds.ResourceNamespace) || string.IsNullOrEmpty(asrVaultCreds.ARMResourceType)) { if (appSettings.Settings.Count == 0) { resourceNamespace = "Microsoft.SiteRecovery"; // ProviderNameSpace for Production is taken as default resourceType = ARMResourceTypeConstants.SiteRecoveryVault; } else { resourceNamespace = null == appSettings.Settings["ProviderNamespace"] ? "Microsoft.SiteRecovery" : appSettings.Settings["ProviderNamespace"].Value; resourceType = null == appSettings.Settings["ResourceType"] ? ARMResourceTypeConstants.SiteRecoveryVault : appSettings.Settings["ResourceType"].Value; } Utilities.UpdateCurrentVaultContext(new ASRVaultCreds() { ResourceNamespace = resourceNamespace, ARMResourceType = resourceType }); } if (null == endPointUri) { if (appSettings.Settings.Count == 0) { endPointUri = azureProfile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager); } else { if (null == appSettings.Settings["RDFEProxy"]) { endPointUri = azureProfile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager); } else { // Setting Endpoint to RDFE Proxy if (null == ServicePointManager.ServerCertificateValidationCallback) { ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificateErrorHandler; } endPointUri = new Uri(appSettings.Settings["RDFEProxy"].Value); } } } cloudCredentials = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(azureProfile.Context); this.recoveryServicesClient = AzureSession.ClientFactory.CreateCustomClient <SiteRecoveryVaultManagementClient>( asrVaultCreds.ResourceNamespace, asrVaultCreds.ARMResourceType, cloudCredentials, azureProfile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)); }
public string ValidateUserXml(string APXml) { Global glolalClass = new Global(); string strUserNameTag = "UserName"; string strUserPassTag = "Password"; string strUserIDTag = "UserID"; string strUserName = ""; string strUserPass = ""; string strUserID = ""; string strApcodeTag = "Apcode"; string strAdminTag = "Admin"; string strAdmin = ""; string strAPcode = ""; string Result = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Result></Result>"; string ResultSuccessTag = "success"; string ResultCode = "";//0为成功,-1为不存在此用户,-2密码错误,-3失败 try { strAPcode = glolalClass.GetSingleTagValue(APXml, strApcodeTag); } catch { ResultCode = "-3"; return glolalClass.CreateSingleTag(Result, ResultSuccessTag, ResultCode); } System.Configuration.AppSettingsSection apsetting = new AppSettingsSection(); string[] strApsetingName = ConfigurationManager.AppSettings.AllKeys; ; bool RightAP = false; for (int i = 0; i < ConfigurationManager.AppSettings.Count; i++) { string strAPsetting = ConfigurationManager.AppSettings[strApsetingName[i]].ToString(); if (strAPsetting.Equals(strAPcode.Trim())) { RightAP = true; i = ConfigurationManager.AppSettings.Count; } } if (!RightAP) { ResultCode = "-3"; return glolalClass.CreateSingleTag(Result, ResultSuccessTag, ResultCode); } else { try { strUserName = glolalClass.GetSingleTagValue(APXml, strUserNameTag); strUserPass = glolalClass.GetSingleTagValue(APXml, strUserPassTag); CQGJ.PassportModel.CQGJPassportEntities CQGJE = new CQGJPassportEntities(); var Querry = from u in CQGJE.User where u.Username == strUserName.Trim() select u; List<User> ListUser = Querry.ToList(); if (ListUser.Count() > 0) { if (ListUser.First().Password == strUserPass.Trim()) { ResultCode = "0"; strUserID = ListUser.First().UserID.ToString(); string strXMl = glolalClass.CreateSingleTag(Result, ResultSuccessTag, ResultCode); strXMl = glolalClass.CreateSingleTag(strXMl, strUserIDTag, strUserID); //strXMl = glolalClass.CreateSingleTag(strXMl, strAdminTag, ListUser.First().ad); return strXMl; } else { ResultCode = "-2"; return glolalClass.CreateSingleTag(Result, ResultSuccessTag, ResultCode); } } else { ResultCode = "-1"; return glolalClass.CreateSingleTag(Result, ResultSuccessTag, ResultCode); } } catch { ResultCode = "-3"; return glolalClass.CreateSingleTag(Result, ResultSuccessTag, ResultCode); } } }
protected virtual void InitAppSettings() { this.objAppsettings = (AppSettingsSection)objConfig.GetSection("appSettings"); }
private string loadSetting(AppSettingsSection app, string item) { return loadSetting(app, item, string.Empty); }
public AudioConversionElementCollectionPanelDataModel(AppSettingsSection appSettings) { AppSettings = appSettings; }
private string loadSetting(AppSettingsSection app, string item, string defaultItem) { KeyValueConfigurationElement kvce; kvce = app.Settings[item]; if (kvce != null) return kvce.Value; else return defaultItem; }