예제 #1
0
 /// <summary>
 /// Configures component by passing configuration parameters.
 /// </summary>
 /// <param name="config">configuration parameters to be set.</param>
 public virtual void Configure(ConfigParams config)
 {
     ReadConnections(config);
 }
예제 #2
0
 /// <summary>
 /// Configures the specified configuration.
 /// </summary>
 /// <param name="config">The configuration.</param>
 public abstract void Configure(ConfigParams config);
예제 #3
0
        public override void Configure(ConfigParams config)
        {
            base.Configure(config);

            _maxPageSize = config.GetAsIntegerWithDefault("options.max_page_size", _maxPageSize);
        }
        /// <summary>
        /// Reads container configuration from YAML file.
        /// </summary>
        /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param>
        /// <param name="path">a path to component configuration file.</param>
        /// <param name="parameters">values to parameters the configuration or null to skip parameterization.</param>
        /// <returns>the read container configuration</returns>
        public static ContainerConfig ReadFromYamlFile(string correlationId, string path, ConfigParams parameters)
        {
            var config = YamlConfigReader.ReadConfig(correlationId, path, parameters);

            return(ContainerConfig.FromConfig(config));
        }
예제 #5
0
 /// <summary>
 /// Configures component by passing configuration parameters.
 /// </summary>
 /// <param name="config">configuration parameters to be set.</param>
 /// <param name="configAsDefault">boolean parameter for default configuration. If "true"
 /// the default value will be added to the result.</param>
 public void Configure(ConfigParams config, bool configAsDefault = true)
 {
     _credentials.AddRange(CredentialParams.ManyFromConfig(config, configAsDefault));
 }
 public void Configure(ConfigParams config)
 {
     MaxPageSize  = config.GetAsIntegerWithDefault("options.max_page_size", MaxPageSize);
     MaxErrorSize = config.GetAsIntegerWithDefault("options.max_error_size", MaxErrorSize);
     MaxTotalSize = config.GetAsIntegerWithDefault("options.max_total_size", MaxTotalSize);
 }
예제 #7
0
 public void Configure(ConfigParams config)
 {
     throw new NotImplementedException();
 }
예제 #8
0
 /// <summary>
 /// Configures component by passing configuration parameters.
 /// </summary>
 /// <param name="config">configuration parameters.</param>
 public override void Configure(ConfigParams config)
 {
     Timeout = config.GetAsLongWithDefault("timeout", Timeout);
     MaxSize = config.GetAsLongWithDefault("max_size", MaxSize);
 }
예제 #9
0
 /// <summary>
 /// Configures component by passing configuration parameters.
 /// </summary>
 /// <param name="config">configuration parameters to be set.</param>
 public virtual void Configure(ConfigParams config)
 {
     _dependencyResolver.Configure(config);
 }
예제 #10
0
 public virtual GameResult SetConfigParams(ConfigParams configParams)
 {
     ConfigParam = configParams;
     return(new GameResult());
 }
예제 #11
0
        /// <summary>
        /// Creates a new ContainerConfig object filled with key-value pairs from
        /// specified object. The value is converted into ConfigParams object which is
        /// used to create the object.
        /// </summary>
        /// <param name="value">an object with key-value pairs used to initialize a new ContainerConfig.</param>
        /// <returns>a new ContainerConfig object.</returns>
        public static ContainerConfig FromObject(object value)
        {
            var config = ConfigParams.FromValue(value);

            return(FromConfig(config));
        }
예제 #12
0
 /// <summary>
 /// Creates a new instance of the component configuration.
 /// </summary>
 /// <param name="descriptor">(optional) a components descriptor (locator).</param>
 /// <param name="type">(optional) a components type descriptor.</param>
 /// <param name="config">(optional) component configuration parameters.</param>
 public ComponentConfig(Descriptor descriptor, TypeDescriptor type, ConfigParams config)
 {
     Descriptor = descriptor;
     Type       = type;
     Config     = config;
 }
예제 #13
0
 /// <summary>
 /// Configures component by passing configuration parameters.
 /// </summary>
 /// <param name="config">configuration parameters to be set.</param>
 public void Configure(ConfigParams config)
 {
     _connectionResolver.Configure(config, false);
     _credentialResolver.Configure(config, false);
 }
예제 #14
0
        private string ComposeUri(List <ConnectionParams> connections, CredentialParams credential)
        {
            // If there is a uri then return it immediately
            foreach (var connection in connections)
            {
                var fullUri = connection.GetAsNullableString("uri");//connection.Uri;
                if (fullUri != null)
                {
                    return(fullUri);
                }
            }

            // Define hosts
            var hosts = "";

            foreach (var connection in connections)
            {
                var host = connection.Host;
                var port = connection.Port;

                if (hosts.Length > 0)
                {
                    hosts += ",";
                }
                hosts += host + (port == 0 ? "" : ":" + port);
            }

            // Define database
            var database = "";

            foreach (var connection in connections)
            {
                database = connection.GetAsNullableString("database") ?? database;
            }
            if (database.Length > 0)
            {
                database = "/" + database;
            }

            // Define authentication part
            var auth = "";

            if (credential != null)
            {
                var username = credential.Username;
                if (username != null)
                {
                    var password = credential.Password;
                    if (password != null)
                    {
                        auth = username + ":" + password + "@";
                    }
                    else
                    {
                        auth = username + "@";
                    }
                }
            }

            // Define additional parameters parameters
            var options = ConfigParams.MergeConfigs(connections.ToArray()).Override(credential);

            options.Remove("uri");
            options.Remove("host");
            options.Remove("port");
            options.Remove("database");
            options.Remove("username");
            options.Remove("password");
            var parameters = "";
            var keys       = options.Keys;

            foreach (var key in keys)
            {
                if (parameters.Length > 0)
                {
                    parameters += "&";
                }

                parameters += key;

                var value = options.GetAsString(key);
                if (value != null)
                {
                    parameters += "=" + value;
                }
            }
            if (parameters.Length > 0)
            {
                parameters = "?" + parameters;
            }

            // Compose uri
            var uri = "mongodb://" + auth + hosts + database + parameters;

            return(uri);
        }
예제 #15
0
 public void Configure(ConfigParams config)
 {
 }
예제 #16
0
        public override void Configure(ConfigParams config)
        {
            base.Configure(config);

            _cosmosDbApiEnabled = config.GetAsBooleanWithDefault("cosmosdb_api_enabled", true);
        }
예제 #17
0
 /// <summary>
 /// Configures component by passing configuration parameters.
 /// </summary>
 /// <param name="config">configuration parameters to be set.</param>
 public virtual void Configure(ConfigParams config)
 {
     _interval     = config.GetAsLongWithDefault("interval", _interval);
     _resetTimeout = config.GetAsLongWithDefault("reset_timeout", _resetTimeout);
 }
        /// <summary>
        /// Reads container configuration from JSON or YAML file. The type of the file is determined by file extension.
        /// </summary>
        /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param>
        /// <param name="path">a path to component configuration file.</param>
        /// <param name="parameters">values to parameters the configuration or null to skip parameterization.</param>
        /// <returns>the read container configuration</returns>
        public static ContainerConfig ReadFromFile(string correlationId, string path, ConfigParams parameters)
        {
            if (path == null)
            {
                throw new ConfigException(correlationId, "NO_PATH", "Missing config file path");
            }

            var ext = Path.GetExtension(path);

            if (ext.Equals(".json"))
            {
                return(ReadFromJsonFile(correlationId, path, parameters));
            }

            if (ext.Equals(".yaml") || ext.Equals(".yml"))
            {
                return(ReadFromYamlFile(correlationId, path, parameters));
            }

            // By default read as Yaml
            return(ReadFromYamlFile(correlationId, path, parameters));
        }
예제 #19
0
        /// <summary>
        /// Retrieves a single CredentialParams from configuration parameters from
        /// "credential" section.If "credentials" section is present instead, then is
        /// returns only the first credential element.
        /// </summary>
        /// <param name="config">ConfigParams, containing a section named "credential(s)".</param>
        /// <param name="configAsDefault">boolean parameter for default configuration. If "true"
        /// the default value will be added to the result.</param>
        /// <returns>the generated CredentialParams object.</returns>
        public static CredentialParams FromConfig(ConfigParams config, bool configAsDefault = true)
        {
            var connections = ManyFromConfig(config, configAsDefault);

            return(connections.Count > 0 ? connections[0] : null);
        }
        private ConfigParams ComposeOptions(List <ConnectionParams> connections, CredentialParams credential)
        {
            credential = credential ?? new CredentialParams();

            // Construct options and copy over credentials
            var options = new ConfigParams().SetDefaults(credential);

            var globalUri      = "";
            var serversBuilder = new StringBuilder();

            // Process connections, find or construct uri
            foreach (var connection in connections)
            {
                options = options.SetDefaults(connection);

                if (globalUri != "")
                {
                    continue;
                }

                var uri = connection.Uri;
                if (!string.IsNullOrEmpty(uri))
                {
                    globalUri = uri;
                    continue;
                }

                if (serversBuilder.Length > 0)
                {
                    serversBuilder.Append(",");
                }

                var host = connection.Host;
                serversBuilder.Append(host);

                var port = connection.GetAsIntegerWithDefault("port", 1883);
                serversBuilder.Append(":");
                serversBuilder.Append(port.ToString());
            }

            // Set connection uri
            if (globalUri != "")
            {
                var pos = globalUri.IndexOf("://");
                if (pos > 0)
                {
                    globalUri = globalUri.Substring(pos + 3);
                }

                pos = globalUri.IndexOf("@");
                if (pos > 0)
                {
                    var userPass = globalUri.Substring(0, pos);
                    globalUri = globalUri.Substring(pos + 1);
                    pos       = userPass.IndexOf(":");
                    if (pos > 0)
                    {
                        var username = userPass.Substring(0, pos);
                        options.SetAsObject("username", username);
                        var password = userPass.Substring(pos + 1);
                        options.SetAsObject("password", password);
                    }
                    else
                    {
                        options.SetAsObject("username", userPass);
                    }
                }

                pos = globalUri.IndexOf("?");
                if (pos > 0)
                {
                    globalUri = globalUri.Substring(0, pos);
                }

                options.SetAsObject("servers", globalUri);
            }
            else
            {
                options.SetAsObject("servers", serversBuilder.ToString());
            }

            return(options);
        }