Ejemplo n.º 1
0
        /// <summary>
        ///     Check if an option is enabled for an application or a runtime.
        /// </summary>
        /// <param name="optionName">
        ///     Name of the option.
        /// </param>
        /// <param name="applicationName">
        ///     Name of an application.
        /// </param>
        /// <param name="runtimeName">
        ///     Name of a runtime.
        /// </param>
        /// <returns>
        ///     true if the option is enabled; false otherwise.
        /// </returns>
        public bool OptionEnabled(string optionName, string applicationName, string runtimeName)
        {
            if (!PlugInConfigurationValidation.ValidateElementName(optionName))
            {
                return(false);
            }

            var option = FindOption(optionName);

            if (option == null)
            {
                return(false);
            }

            if (!string.IsNullOrWhiteSpace(applicationName) &&
                PlugInConfigurationValidation.ValidateElementName(applicationName))
            {
                if (option.Applications.Contains(applicationName, Comparer))
                {
                    return(true);
                }
            }

            if (!string.IsNullOrWhiteSpace(runtimeName) &&
                PlugInConfigurationValidation.ValidateElementName(runtimeName))
            {
                return(option.Runtimes.Contains(runtimeName, Comparer));
            }

            return(false);
        }
        /// <summary>
        ///     Create an configuration option.
        /// </summary>
        /// <param name="name">
        ///     Option name.
        /// </param>
        /// <param name="description">
        ///     Option description.
        /// </param>
        public ConfigurationOption(string name, string description)
        {
            if (!PlugInConfigurationValidation.ValidateElementName(name))
            {
                throw new ArgumentException(message:
                                            string.Format("The name is invalid '{0}': {1}", name, PlugInConfigurationValidation.ValidCharactersMessage),
                                            nameof(name));
            }

            this.Name        = name;
            this.Description = description;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Create a plug-in configuration.
        /// </summary>
        /// <param name="name">
        ///     Name of the plug-in.
        /// </param>
        /// <param name="version">
        ///     Version of the configuration.
        /// </param>
        /// <param name="options">
        ///     A set of option to include in the configuration.
        /// </param>
        public PlugInConfiguration(string name, SemanticVersion version, ISet <ConfigurationOption> options)
        {
            Guard.NotNullOrWhiteSpace(name, nameof(name));
            Guard.NotNull(version, nameof(version));
            Guard.NotNull(options, nameof(options));

            if (!PlugInConfigurationValidation.ValidateElementName(name))
            {
                throw new ArgumentException(message:
                                            "The name is invalid: " + PlugInConfigurationValidation.ValidCharactersMessage,
                                            nameof(name));
            }

            this.PlugInName = name;
            this.Version    = version;
            this.options    = new List <ConfigurationOption>(options);
            this.Options    = this.options.AsReadOnly();
        }