public UserManagerImplementation()
        {
            // Get configuration source
            this._source = ConfigurationSourceFactory.Create(UserSettings.SectionName);

            // Load & Clone configuration (so not read-only)
            this.Load();

            // Determine configuration file path
            if (this.Source is SystemConfigurationSource)
            {
                this._filePath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            }
            else if (this.Source is FileConfigurationSource)
            {
                ConfigurationSourceSection configurationSourceSection =
                    ConfigurationSourceSection.GetConfigurationSourceSection();

                FileConfigurationSourceElement objectConfiguration
                    = (FileConfigurationSourceElement)configurationSourceSection.Sources.Get(UserSettings.SectionName);

                FileConfigurationSourceElement e = (FileConfigurationSourceElement)objectConfiguration;
                this._filePath = objectConfiguration.FilePath;
            }
        }
示例#2
0
        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);
        }
 private static ConfigurationSourceSection GetConfigurationSourceSection()
 {
     //find the configuration source section ie system (app.config) or sql************
     return(ConfigurationSourceSection.GetConfigurationSourceSection());
 }