Ejemplo n.º 1
0
        public static SimpleConfig LoadFrom(NameValueCollection appSettings)
        {
            SimpleConfig co = new SimpleConfig();

            co.config_loc = "composite";
            string[] keys = appSettings.AllKeys;
            for (int i = 0; i < keys.Length; i++)
            {
                co.appSettings.Add(keys[i], appSettings[keys[i]]);
            }
            return(co);
        }
Ejemplo n.º 2
0
        public static SimpleConfig LoadFrom(Configuration c)
        {
            SimpleConfig co = new SimpleConfig();

            co.config_loc = c.FilePath;
            string[] keys = c.AppSettings.Settings.AllKeys;
            for (int i = 0; i < keys.Length; i++)
            {
                co.appSettings.Add(keys[i], c.AppSettings.Settings[keys[i]].Value);
            }
            return(co);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigLoader"/> class from the local machine config
        /// Note, there may be four machine config files per machine depending on the version of dotnet install and processor architecture
        /// throws an exception when authmode is specified and credentials are not
        /// throws an exception when no urls are specified for dcs and pcs and we are not operating in offline mode
        /// </summary>
        public ConfigLoader()
        {
            try
            {
                Configuration machineconfig = ConfigurationManager.OpenMachineConfiguration();
                LoadFrom(SimpleConfig.LoadFrom(machineconfig));
            }catch (Exception ex)
            {
                Console.Out.WriteLine(ex);
            }
            try
            {
                Configuration localApp = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                LoadFrom(SimpleConfig.LoadFrom(localApp));
            }
            catch (Exception ex) {
                //Logger.error(ex, "Error caught loading the config");
                Console.Out.WriteLine(ex);
            }
            try {
                System.Configuration.Configuration configuration = null;
                if (System.Web.HttpContext.Current != null) //this is null in wcf services running in iis express and probably self hosted services
                {
                    configuration =
                        System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
                    LoadFrom(SimpleConfig.LoadFrom(configuration));
                }
            }
            catch (Exception ex) {
                //Logger.error(ex, "Error caught loading the config");
                Console.Out.WriteLine(ex);
            }
            if (WebConfigurationManager.AppSettings != null)
            {
                LoadFrom(SimpleConfig.LoadFrom(WebConfigurationManager.AppSettings));
            }



            ValidateConfig();
        }
Ejemplo n.º 4
0
        public static SimpleConfig LoadFrom(String delimitedSettings)
        {
            SimpleConfig co = new SimpleConfig();

            string[] lines = delimitedSettings.Split(new string[] { LineDelimitor }, StringSplitOptions.RemoveEmptyEntries);


            for (int i = 0; i < lines.Length; i++)
            {
                string[] items = lines[i].Split(new string[] { NameValueDelimitor }, StringSplitOptions.RemoveEmptyEntries);
                if (items.Length == 2)
                {
                    co.appSettings.Add(items[0], items[1]);
                }
                else
                {
                    //parsing error/invalid config
                    Logger.warn("invalid config recieved from ACS service");
                }
            }
            return(co);
        }
Ejemplo n.º 5
0
        public static SimpleConfig LoadFrom(String delimitedSettings)
        {
            SimpleConfig co = new SimpleConfig();
            string[] lines = delimitedSettings.Split(new string[] { LineDelimitor }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < lines.Length; i++)
            {
                string[] items = lines[i].Split(new string[] { NameValueDelimitor }, StringSplitOptions.RemoveEmptyEntries);
                if (items.Length == 2)
                {
                    co.appSettings.Add(items[0], items[1]);
                }
                else
                {
                    //parsing error/invalid config
                    Logger.warn("invalid config recieved from ACS service");
                }
            }
            return co;
        }
Ejemplo n.º 6
0
 public static SimpleConfig LoadFrom(Configuration c)
 {
     SimpleConfig co = new SimpleConfig();
     co.config_loc = c.FilePath;
     string[] keys = c.AppSettings.Settings.AllKeys;
     for (int i = 0; i < keys.Length; i++)
     {
         co.appSettings.Add(keys[i], c.AppSettings.Settings[keys[i]].Value);
     }
     return co;
 }
Ejemplo n.º 7
0
        private void LoadFrom(SimpleConfig config)
        {
            try
            {
                configfilepath = config.config_loc;

                try
                {

                    string x = config.appSettings[IgnoreListKey];
                    if (!String.IsNullOrEmpty(x))
                        ignoreList.AddRange(x.Trim().Split('|'));
                }
                catch { }

                try
                {
                    _logLevel = (LogLevel)Enum.Parse(typeof(LogLevel), config.appSettings[LogLevelKey]);
                }
                catch {
                    _logLevel = LogLevel.WARN;
                }

                try
                {
                    string x = config.appSettings[AuthModePasswordKey];

                    if (!String.IsNullOrEmpty(x))
                        password = x;
                }
                catch { }
                try
                {
                    string x = config.appSettings[AuthModeUsernameKey];

                    if (!String.IsNullOrEmpty(x))
                        username = x;
                }
                catch { }
                try
                {
                    string x = config.appSettings[AuthModePKIInfoKey];

                    if (!String.IsNullOrEmpty(x))
                        pkiinfo = x;
                }
                catch { }

                try
                {
                    string x = config.appSettings[DCSUrlKey];

                    if (!String.IsNullOrEmpty(x))
                        dcsurl.AddRange(x.Trim().Split('|'));
                }
                catch { }
                try
                {
                    string x = config.appSettings[SSUrlKey];

                    if (!String.IsNullOrEmpty(x))
                        ssurl.AddRange(x.Trim().Split('|'));
                }
                catch { }
                try
                {
                    string x = config.appSettings[PCSUrlKey];
                    if (!String.IsNullOrEmpty(x))
                        pcsurl.AddRange(x.Trim().Split('|'));
                }
                catch { }

                try
                {
                    DCSalgo = (Algorithm)Enum.Parse(typeof(Algorithm), config.appSettings[UddiFindTypekey]);
                }
                catch { }
                try
                {
                    DCSalgo = (Algorithm)Enum.Parse(typeof(Algorithm), config.appSettings[DCSlagokey]);
                }
                catch { }
                try
                {
                    PCSalgo = (Algorithm)Enum.Parse(typeof(Algorithm), config.appSettings[PCSlagokey]);
                }
                catch { }
                try
                {
                    authMode = (AuthMode)Enum.Parse(typeof(AuthMode), config.appSettings[AuthModeKey]);
                }
                catch { }
                try
                {
                    DeadMessageDuration = (long)long.Parse(config.appSettings[DeadMsgkey]);
                }
                catch { }
                try
                {
                    DependencyInjectionEnabled = (bool)bool.Parse(config.appSettings[DepInjkey]);
                }
                catch { }
                try
                {
                    UddiEnabled = (bool)bool.Parse(config.appSettings[UddiEnabledKey]);
                }
                catch { }

                try
                {
                    DNSEnabled = (bool)bool.Parse(config.appSettings[DNSEnabledKey]);
                }
                catch { }

                try
                {
                    ServiceUnavailableBehavior = (UnavailableBehavior)Enum.Parse(typeof(UnavailableBehavior), config.appSettings[AgentBevKey]);
                }
                catch { }
                try
                {
                    DCSretrycount = Int32.Parse(config.appSettings[DCSlretrykey]);
                }
                catch { }
                try
                {
                    PCSretrycount = Int32.Parse(config.appSettings[PCSlretrykey]);
                }
                catch { }
                try
                {
                    DiscoveryInterval = Int32.Parse(config.appSettings[discoveryInterval]);
                }
                catch { }
                try
                {
                    UddiInquiryUrl = (config.appSettings[UddiURLKey]);
                }
                catch { }
                try
                {
                    UddiSecurityUrl = (config.appSettings[UddiSecUrlKey]);
                }
                catch { }
                try
                {
                    UddiAuthRequired = bool.Parse(config.appSettings[UddiAuthKey]);
                }
                catch { }

                try
                {
                    UddiUsername = (config.appSettings[UddiUsernameKey]);
                }
                catch { }
                try
                {
                    UddiEncryptedPassword = (config.appSettings[UddipwdKey]);
                }
                catch { }
                try
                {
                    UddiDCSLookup = (config.appSettings[UddiDCSkey]);
                }
                catch { }
                try
                {
                    UddiPCSLookup = (config.appSettings[UddiPCSkey]);
                }
                catch { }
                try
                {
                    _uddifindType = (UddiFindType)Enum.Parse(typeof(UddiFindType), (config.appSettings[UddiFindTypekey]));
                }
                catch { }

                try
                {
                    operatingmode = (OperationMode)Enum.Parse(typeof(OperationMode), (config.appSettings[operatingModeKey]));
                }
                catch { }

                try
                {
                    PersistLocation = (config.appSettings[PersistKey]);
                }
                catch { }

            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigLoader"/> class from a <see cref="SimpleConfig"/> option
 /// Note, there may be four machine config files per machine depending on the version of dotnet install and processor architecture
 /// throws an exception when authmode is specified and credentials are not
 /// throws an exception when no urls are specified for dcs and pcs and we are not operating in offline mode
 /// </summary>
 public ConfigLoader(SimpleConfig cfg)
 {
     LoadFrom(cfg);
     ValidateConfig();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigLoader"/> class from a <see cref="SimpleConfig"/> option
 /// Note, there may be four machine config files per machine depending on the version of dotnet install and processor architecture
 /// throws an exception when authmode is specified and credentials are not
 /// throws an exception when no urls are specified for dcs and pcs and we are not operating in offline mode
 /// </summary>
 public ConfigLoader(SimpleConfig cfg)
 {
     LoadFrom(cfg);
     ValidateConfig();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigLoader"/> class using a mapped machine config
 /// throws an exception when authmode is specified and credentials are not
 /// throws an exception when no urls are specified for dcs and pcs and we are not operating in offline mode
 /// </summary>
 public ConfigLoader(Configuration machineconfig)
 {
     LoadFrom(SimpleConfig.LoadFrom(machineconfig));
     ValidateConfig();
 }
Ejemplo n.º 11
0
        private void LoadFrom(SimpleConfig config)
        {
            try
            {
                configfilepath = config.config_loc;

                try
                {
                    string x = config.appSettings[IgnoreListKey];
                    if (!String.IsNullOrEmpty(x))
                    {
                        ignoreList.AddRange(x.Trim().Split('|'));
                    }
                }
                catch { }

                try
                {
                    _logLevel = (LogLevel)Enum.Parse(typeof(LogLevel), config.appSettings[LogLevelKey]);
                }
                catch {
                    _logLevel = LogLevel.WARN;
                }

                try
                {
                    string x = config.appSettings[AuthModePasswordKey];

                    if (!String.IsNullOrEmpty(x))
                    {
                        password = x;
                    }
                }
                catch { }
                try
                {
                    string x = config.appSettings[AuthModeUsernameKey];

                    if (!String.IsNullOrEmpty(x))
                    {
                        username = x;
                    }
                }
                catch { }
                try
                {
                    string x = config.appSettings[AuthModePKIInfoKey];

                    if (!String.IsNullOrEmpty(x))
                    {
                        pkiinfo = x;
                    }
                }
                catch { }



                try
                {
                    string x = config.appSettings[DCSUrlKey];

                    if (!String.IsNullOrEmpty(x))
                    {
                        dcsurl.AddRange(x.Trim().Split('|'));
                    }
                }
                catch { }
                try
                {
                    string x = config.appSettings[SSUrlKey];

                    if (!String.IsNullOrEmpty(x))
                    {
                        ssurl.AddRange(x.Trim().Split('|'));
                    }
                }
                catch { }
                try
                {
                    string x = config.appSettings[PCSUrlKey];
                    if (!String.IsNullOrEmpty(x))
                    {
                        pcsurl.AddRange(x.Trim().Split('|'));
                    }
                }
                catch { }

                try
                {
                    DCSalgo = (Algorithm)Enum.Parse(typeof(Algorithm), config.appSettings[UddiFindTypekey]);
                }
                catch { }
                try
                {
                    DCSalgo = (Algorithm)Enum.Parse(typeof(Algorithm), config.appSettings[DCSlagokey]);
                }
                catch { }
                try
                {
                    PCSalgo = (Algorithm)Enum.Parse(typeof(Algorithm), config.appSettings[PCSlagokey]);
                }
                catch { }
                try
                {
                    authMode = (AuthMode)Enum.Parse(typeof(AuthMode), config.appSettings[AuthModeKey]);
                }
                catch { }
                try
                {
                    DeadMessageDuration = (long)long.Parse(config.appSettings[DeadMsgkey]);
                }
                catch { }
                try
                {
                    DependencyInjectionEnabled = (bool)bool.Parse(config.appSettings[DepInjkey]);
                }
                catch { }
                try
                {
                    UddiEnabled = (bool)bool.Parse(config.appSettings[UddiEnabledKey]);
                }
                catch { }

                try
                {
                    DNSEnabled = (bool)bool.Parse(config.appSettings[DNSEnabledKey]);
                }
                catch { }


                try
                {
                    ServiceUnavailableBehavior = (UnavailableBehavior)Enum.Parse(typeof(UnavailableBehavior), config.appSettings[AgentBevKey]);
                }
                catch { }
                try
                {
                    DCSretrycount = Int32.Parse(config.appSettings[DCSlretrykey]);
                }
                catch { }
                try
                {
                    PCSretrycount = Int32.Parse(config.appSettings[PCSlretrykey]);
                }
                catch { }
                try
                {
                    DiscoveryInterval = Int32.Parse(config.appSettings[discoveryInterval]);
                }
                catch { }
                try
                {
                    UddiInquiryUrl = (config.appSettings[UddiURLKey]);
                }
                catch { }
                try
                {
                    UddiSecurityUrl = (config.appSettings[UddiSecUrlKey]);
                }
                catch { }
                try
                {
                    UddiAuthRequired = bool.Parse(config.appSettings[UddiAuthKey]);
                }
                catch { }

                try
                {
                    UddiUsername = (config.appSettings[UddiUsernameKey]);
                }
                catch { }
                try
                {
                    UddiEncryptedPassword = (config.appSettings[UddipwdKey]);
                }
                catch { }
                try
                {
                    UddiDCSLookup = (config.appSettings[UddiDCSkey]);
                }
                catch { }
                try
                {
                    UddiPCSLookup = (config.appSettings[UddiPCSkey]);
                }
                catch { }
                try
                {
                    _uddifindType = (UddiFindType)Enum.Parse(typeof(UddiFindType), (config.appSettings[UddiFindTypekey]));
                }
                catch { }

                try
                {
                    operatingmode = (OperationMode)Enum.Parse(typeof(OperationMode), (config.appSettings[operatingModeKey]));
                }
                catch { }


                try
                {
                    PersistLocation = (config.appSettings[PersistKey]);
                }
                catch { }
            }
            catch (Exception)
            {
            }
        }