public MockSectionWithMultipleChildCollections() { this[childrenProperty] = new NamedElementCollection <TestHandlerData>(); this[moreChildrenProperty] = new NamedElementCollection <TestHandlerDataWithChildren>(); this[polymorphicChildrenProperty] = new NameTypeConfigurationElementCollection <TestHandlerData, CustomTestHandlerData>(); }
public MockSectionWithMultipleChildCollections() { this[childrenProperty] = new NamedElementCollection<TestHandlerData>(); this[moreChildrenProperty] = new NamedElementCollection<TestHandlerDataWithChildren>(); this[polymorphicChildrenProperty] = new NameTypeConfigurationElementCollection<TestHandlerData, CustomTestHandlerData>(); }
private static SqlConfigurationSource GetSelectedConfigurationSource(ConfigurationSourceSection section) { //find the selected configuration source ie system (app.config) or sql************ string selectedSource = section.SelectedSource; NameTypeConfigurationElementCollection <ConfigurationSourceElement> sources = section.Sources; SqlConfigurationSourceElement element = GetElement(selectedSource, sources); return(new SqlConfigurationSource(element.ConnectionString, element.GetStoredProcedure, element.SetStoredProcedure, element.RefreshStoredProcedure, element.RemoveStoredProcedure)); //************************************************************* }
public static ErrorType GetErrorType(string exceptionType, string opCoCode, string policyName) { ErrorType errorType = null; //read the config details from file or other source (db) to find the error handling section //find the configuration source section ConfigurationSourceSection section = ConfigurationSourceSection.GetConfigurationSourceSection(); //find the selected source where our config sections are stored string selectedSource = section.SelectedSource; NameTypeConfigurationElementCollection <ConfigurationSourceElement> sources = section.Sources; ConfigurationSourceElement element = sources.Get(selectedSource); if (element is SqlConfigurationSourceElement) { SqlConfigurationSourceElement sqlElement = element as SqlConfigurationSourceElement; SqlConfigurationSource configurationSource = new SqlConfigurationSource(sqlElement.ConnectionString, sqlElement.GetStoredProcedure, sqlElement.SetStoredProcedure, sqlElement.RefreshStoredProcedure, sqlElement.RemoveStoredProcedure); //find all the exception policies NamedElementCollection <ExceptionPolicyData> policies = ExceptionHandlingSettings.GetExceptionHandlingSettings(configurationSource).ExceptionPolicies; //find just the one specified if (policies != null) { ExceptionPolicyData specifiedPolicy = policies.Get(policyName); if (specifiedPolicy != null) { specifiedPolicy.ExceptionTypes.ForEach(delegate(ExceptionTypeData currentExceptionType) { if (currentExceptionType.Type.ToString() == exceptionType) { errorType = PopulateErrorType(policyName, opCoCode, currentExceptionType); } } ); } } } return(errorType); }
public void CanReadConfigurationElementsWithClearFromCollectionWithOverrides() { PolymorphicConfigurationElementCollectionTestSection section = ConfigurationManager.GetSection("withclear") as PolymorphicConfigurationElementCollectionTestSection; NameTypeConfigurationElementCollection <BasePolymorphicObjectData, CustomPolymorphicObjectData> elements = section.WithOverrides; Assert.AreEqual(2, elements.Count); Assert.AreSame(typeof(DerivedPolymorphicObject2Data), elements.Get("overrideprovider2").GetType()); Assert.AreSame(typeof(DerivedPolymorphicObject1Data), elements.Get("overrideprovider1b").GetType()); }
public LogFilterCollectionNodeBuilder(IServiceProvider serviceProvider, NameTypeConfigurationElementCollection<LogFilterData> logFilters) : base(serviceProvider) { this.logFilters = logFilters; }
public FormatterCollectionNodeBuilder(IServiceProvider serviceProvider, NameTypeConfigurationElementCollection <FormatterData> formatters) : base(serviceProvider) { this.formatters = formatters; }
public LogFilterCollectionNodeBuilder(IServiceProvider serviceProvider, NameTypeConfigurationElementCollection <LogFilterData> logFilters) : base(serviceProvider) { this.logFilters = logFilters; }
public static void ModifProtectedKeyFilename(string keyFilePath) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.HasFile) { ConfigurationSection configurationSection = config.Sections["securityCryptographyConfiguration"]; CryptographySettings cryptographySettings = configurationSection as CryptographySettings; NameTypeConfigurationElementCollection <SymmetricProviderData, CustomSymmetricCryptoProviderData> elementCollection = cryptographySettings.SymmetricCryptoProviders; SymmetricProviderData symmetricProviderData = elementCollection.Get("DESCryptoServiceProvider"); symmetricProviderData.ElementInformation.Properties["protectedKeyFilename"].Value = keyFilePath; config.Save(ConfigurationSaveMode.Minimal); } }
public static void ModifProtectedKeyFilename() { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.HasFile) { ConfigurationSection configurationSection = config.Sections["securityCryptographyConfiguration"]; CryptographySettings cryptographySettings = configurationSection as CryptographySettings; NameTypeConfigurationElementCollection <SymmetricProviderData, CustomSymmetricCryptoProviderData> elementCollection = cryptographySettings.SymmetricCryptoProviders; SymmetricProviderData symmetricProviderData = elementCollection.Get("AesCryptoServiceProvider"); string keyFilePath = symmetricProviderData.ElementInformation.Properties["protectedKeyFilename"].Value.ToString(); if (keyFilePath.Split('\\').Length == 1) { symmetricProviderData.ElementInformation.Properties["protectedKeyFilename"].Value = AppDomain.CurrentDomain.BaseDirectory + "\\" + keyFilePath; config.Save(ConfigurationSaveMode.Minimal); } } }
public FormatterCollectionNodeBuilder(IServiceProvider serviceProvider, NameTypeConfigurationElementCollection<FormatterData> formatters) : base(serviceProvider) { this.formatters = formatters; }
private static SqlConfigurationSourceElement GetElement(string selectedSource, NameTypeConfigurationElementCollection <ConfigurationSourceElement> sources) { return(sources.Get(selectedSource) as SqlConfigurationSourceElement); }
private static void CheckAndMergeStores() { SecuritySettings securitySettings = (SecuritySettings)ConfigurationManager.GetSection(SecuritySettings.SectionName); NameTypeConfigurationElementCollection <AuthorizationProviderData, CustomAuthorizationProviderData> providerElementCollection = securitySettings.AuthorizationProviders; LogEntry entry = new LogEntry(); entry.Severity = TraceEventType.Verbose; entry.Priority = -1; if (Logger.ShouldLog(entry)) { entry.Message = "Checking for authorization store merge files..."; Logger.Write(entry); } for (int i = 0; i < providerElementCollection.Count; i++) { AuthorizationProviderData providerData = providerElementCollection.Get(i); string toStoreLocation = providerData.ElementInformation.Properties["storeLocation"].Value as string; toStoreLocation = toStoreLocation.Replace("{currentPath}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); string toFileName = toStoreLocation.Replace("msxml://", ""); string fromFileName = Path.Combine(Path.Combine(Path.GetDirectoryName(toFileName), AZ_MERGE_FOLDER), Path.GetFileName(toFileName)); string fromStoreLocation = string.Format("msxml://{0}", fromFileName); if (File.Exists(fromFileName)) { if (Logger.ShouldLog(entry)) { entry.Message = string.Format("Found merge file \"{0}\".", fromFileName); Logger.Write(entry); } string backupFileName = Path.ChangeExtension(toFileName, "bak"); int counter = 0; while (File.Exists(backupFileName)) { counter++; backupFileName = Path.ChangeExtension(backupFileName, string.Format("bak{0}", counter)); } if (Logger.ShouldLog(entry)) { entry.Message = string.Format("Creating backup \"{0}\"...", backupFileName); Logger.Write(entry); } File.Copy(toFileName, backupFileName); FileInfo fi = new FileInfo(toFileName); fi.IsReadOnly = false; MergeStores(fromStoreLocation, toStoreLocation); string mergedFileName = Path.ChangeExtension(fromFileName, "merged"); counter = 0; while (File.Exists(mergedFileName)) { counter++; mergedFileName = Path.ChangeExtension(mergedFileName, string.Format("merged{0}", counter)); } if (Logger.ShouldLog(entry)) { entry.Message = string.Format("Renaming merge file to \"{0}\"...", mergedFileName); Logger.Write(entry); } File.Move(fromFileName, mergedFileName); if (Logger.ShouldLog(entry)) { entry.Message = string.Format("Merge complete."); Logger.Write(entry); } } } }
public AzManAuthorizationDao() { _storeDictionary = new Dictionary <string, AzAuthorizationStore>(); _applicationDictionary = new Dictionary <string, IAzApplication2>(); _operationDictionary = new Dictionary <string, Dictionary <string, int> >(); _watcherDictionary = new Dictionary <string, FileSystemWatcher>(); _syncLock = new ReaderWriterLockSlim(); SecuritySettings securitySettings = (SecuritySettings)ConfigurationManager.GetSection(SecuritySettings.SectionName); NameTypeConfigurationElementCollection <AuthorizationProviderData, CustomAuthorizationProviderData> providerElementCollection = securitySettings.AuthorizationProviders; for (int i = 0; i < providerElementCollection.Count; i++) { AuthorizationProviderData providerData = providerElementCollection.Get(i); string storeLocation = providerData.ElementInformation.Properties["storeLocation"].Value as string; storeLocation = storeLocation.Replace("{currentPath}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); string providerName = providerData.Name; string applicationName = providerData.ElementInformation.Properties["application"].Value as string; InitializeProvider(providerName, applicationName, storeLocation); } foreach (var entry in _watcherDictionary) { entry.Value.EnableRaisingEvents = true; } }