예제 #1
0
        /// <summary>
        /// Attempts to construct and return a provider that uses analysis properties provided on the command line
        /// </summary>
        /// <param name="commandLineArguments">List of command line arguments (optional)</param>
        /// <returns>False if errors occurred when constructing the provider, otherwise true</returns>
        /// <remarks>If no properties were provided on the command line then an empty provider will be returned</remarks>
        public static bool TryCreateProvider(IEnumerable <ArgumentInstance> commandLineArguments, ILogger logger, out IAnalysisPropertyProvider provider)
        {
            if (commandLineArguments == null)
            {
                throw new ArgumentNullException("commandLineArguments");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            IEnumerable <Property> validProperties;

            if (ExtractAndValidateProperties(commandLineArguments, logger, out validProperties))
            {
                if (validProperties.Any())
                {
                    provider = new CmdLineArgPropertyProvider(validProperties);
                }
                else
                {
                    provider = EmptyPropertyProvider.Instance;
                }

                return(true);
            }

            provider = null;
            return(false);
        }
        /// <summary>
        /// Attempts to construct and return a provider that uses analysis properties provided on the command line
        /// </summary>
        /// <param name="commandLineArguments">List of command line arguments (optional)</param>
        /// <returns>False if errors occurred when constructing the provider, otherwise true</returns>
        /// <remarks>If no properties were provided on the command line then an empty provider will be returned</remarks>
        public static bool TryCreateProvider(IEnumerable<ArgumentInstance> commandLineArguments, ILogger logger, out IAnalysisPropertyProvider provider)
        {
            if (commandLineArguments == null)
            {
                throw new ArgumentNullException("commandLineArguments");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            IEnumerable<Property> validProperties;
            if (ExtractAndValidateProperties(commandLineArguments, logger, out validProperties))
            {
                if (validProperties.Any())
                {
                    provider = new CmdLineArgPropertyProvider(validProperties);
                }
                else
                {
                    provider = EmptyPropertyProvider.Instance;
                }

                return true;
            }

            provider = null;
            return false;
        }