Inheritance: ConfigurationElementCollection
Beispiel #1
0
 public void Init(NameValueConfigurationCollection props)
 {
     Console.WriteLine("EventWriterFilter.Init");
     foreach (NameValueConfigurationElement prop in props)
     {
         Console.WriteLine("{0}={1}", prop.Name, prop.Value);
     }
 }
 public void Init(NameValueConfigurationCollection props)
 {
     _filteredTypes = new List<Message>();
     var types = props[MESSAGE_TYPES_PARAMETER_NAME].Value.Split(';');
     foreach (var type in types)
     {
         if (Enum.IsDefined(typeof(Message), type))
             _filteredTypes.Add((Message) Enum.Parse(typeof (Message), type));
     }
 }
 private static NameValueConfigurationCollection getSettings()
 {
     if (settings == null)
     {
         lock (settingsLock)
         {
             settings = ProviderHelper.GetSection("DataObject.Settings") as NameValueConfigurationCollection;
         }
     }
     return settings;
 }
Beispiel #4
0
 public void Init(NameValueConfigurationCollection props)
 {
     Console.WriteLine("EventFormatter.Init");
     foreach (NameValueConfigurationElement prop in props)
     {
         Console.WriteLine("{0}={1}", prop.Name, prop.Value);
     }
     if(props["format"] != null && !String.IsNullOrEmpty(props["format"].Value))
     {
         _fieldId = props["format"].Value;
     }
 }
Beispiel #5
0
 public void Init(NameValueConfigurationCollection props)
 {
     if (props[PAR_FORMAT] != null && !String.IsNullOrEmpty(props[PAR_FORMAT].Value))
     {
         _userFormat = props[PAR_FORMAT].Value;
         _format = StringFormatParser.Parse(_userFormat, out _messageNames);
         _format = _format.Replace("\\n", "\n").Replace("\\r", "\r").Replace("\\t", "\t");
     }
     else
     {
         _format = StringFormatParser.Parse(DEFAULT_FORMAT, out _messageNames);
     }
     if (props[PAR_ARRAY_DELIMITER] != null && !String.IsNullOrEmpty(props[PAR_ARRAY_DELIMITER].Value))
     {
         dumperSetting.EnumerableDelimiter = props[PAR_ARRAY_DELIMITER].Value;
     }
     if(props[PAR_SINGLE_FILE_PROPS] != null && !String.IsNullOrEmpty(props[PAR_SINGLE_FILE_PROPS].Value))
     {
         _singleFileProps.Clear();
         _singleFileProps.AddRange(props[PAR_SINGLE_FILE_PROPS].Value.Split(';'));
     }
 }
        /// <summary>
        /// Checks to see if settings for the remote driver exists.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="browserType">Type of the browser.</param>
        /// <param name="remoteWebDriver">The created remote web driver.</param>
        /// <returns><c>true</c> if the settings exist; otherwise <c>false</c>.</returns>
        private static bool RemoteDriverExists(NameValueConfigurationCollection settings, BrowserType browserType, out IWebDriver remoteWebDriver)
        {
            var remoteUri = GetRemoteDriverUri(settings);

            if (remoteUri == null)
            {
                remoteWebDriver = null;
                return false;
            }

            DesiredCapabilities capability;
            switch (browserType)
            {
                case BrowserType.IE:
                    capability = DesiredCapabilities.InternetExplorer();
                    break;
                case BrowserType.FireFox:
                    capability = DesiredCapabilities.Firefox();
                    break;
                case BrowserType.Chrome:
                    capability = DesiredCapabilities.Chrome();
                    break;
                case BrowserType.Safari:
                    capability = DesiredCapabilities.Safari();
                    break;
                case BrowserType.Opera:
                    capability = DesiredCapabilities.Opera();
                    break;
                case BrowserType.Android:
                    capability = DesiredCapabilities.Android();
                    break;
                case BrowserType.iPhone:
                    capability = DesiredCapabilities.IPhone();
                    break;
                case BrowserType.iPad:
                    capability = DesiredCapabilities.IPad();
                    break;
                case BrowserType.PhantomJS:
                    capability = DesiredCapabilities.PhantomJS();
                    break;
				case BrowserType.Edge:
					capability = DesiredCapabilities.Edge();
					break;
                default:
                    throw new InvalidOperationException(string.Format("Browser Type '{0}' is not supported as a remote driver.", browserType));
            }

            // Add any additional settings that are not reserved
            var envRegex = new System.Text.RegularExpressions.Regex("\\$\\{(.+)\\}");
            var reservedSettings = new[] { RemoteUrlSetting };
            foreach (var setting in settings.OfType<NameValueConfigurationElement>()
                                            .Where(s => reservedSettings.All(r => !string.Equals(r, s.Name, StringComparison.OrdinalIgnoreCase))))
            {
                // Support environment variables
                var value = setting.Value;
                var match = envRegex.Match(value);
                if (match.Success)
                {
                    value = SettingHelper.GetEnvironmentVariable(match.Groups[1].Value);
                }

                capability.SetCapability(setting.Name, value);
            }

            remoteWebDriver = new RemoteScreenshotWebDriver(remoteUri, capability);
            return true;
        }
        /// <summary>
        /// Gets the remote driver URI.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <returns>The URI if the setting is valid, otherwise <c>null</c>.</returns>
        /// <exception cref="System.Configuration.ConfigurationErrorsException">Thrown if the URI is not valid.</exception>
        private static Uri GetRemoteDriverUri(NameValueConfigurationCollection settings)
        {
            var remoteSetting = settings[RemoteUrlSetting];

            if (remoteSetting == null || string.IsNullOrWhiteSpace(remoteSetting.Value))
            {
                return null;
            }

            Uri remoteUri;
            if (!Uri.TryCreate(remoteSetting.Value, UriKind.Absolute, out remoteUri))
            {
                throw new ConfigurationErrorsException(
                    string.Format("The {0} setting is not a valid URI: {1}", RemoteUrlSetting, remoteSetting.Value));
            }

            return remoteUri;
        }
Beispiel #8
0
 public void Init(NameValueConfigurationCollection props)
 {
 }
 public void Init(NameValueConfigurationCollection props)
 {
     _minFreeSpaces.Add(DEFAULT_LOG_NAME, DEFAULT_MIN_FREE_SPACE);
     if (!EventDispatcher.GroupByFieldDefined)
     {
         foreach (TraceEventType traceEventType in Enum.GetValues(typeof(TraceEventType)))
         {
             _minFreeSpaces.Add(traceEventType.ToString(), DEFAULT_MIN_FREE_SPACE);
         }
     }
     foreach (NameValueConfigurationElement prop in props)
     {
         _minFreeSpaces[prop.Name] = Convert.ToInt32(prop.Value);
     }
 }
        protected virtual ValueDictionary ProcessTokens(
            NameValueConfigurationCollection collection)
        {
            ValueDictionary tokens = new ValueDictionary();
            if (collection == null)
                return tokens;

            foreach (string key in collection.AllKeys)
                tokens.Add(key, collection[key].Value);

            return tokens;
        }
        protected virtual ValueDictionary ProcessDefaults(
            NameValueConfigurationCollection collection)
        {
            ValueDictionary defaults = new ValueDictionary();
            if(collection == null)
                return defaults;

            foreach (string key in collection.AllKeys)
                defaults.Add(key, collection[key].Value);

            return defaults;
        }