Ng.CommandHelpers.GetArguments C# (CSharp) Метод

GetArguments() публичный статический Метод

public static GetArguments ( string args, int start ) : string>.IDictionary
args string
start int
Результат string>.IDictionary
        public static IDictionary<string, string> GetArguments(string[] args, int start)
        {
            var unprocessedArguments = new Dictionary<string, string>();

            if ((args.Length - 1) % 2 != 0)
            {
                Trace.TraceError("Unexpected number of arguments");
                return null;
            }

            for (var i = start; i < args.Length; i += 2)
            {
                // Remove hyphen from the beginning of the argument name.
                var argumentName = args[i].TrimStart(Arguments.Prefix);
                // Remove quotes (if any) from the start and end of the argument value.
                var argumentValue = args[i + 1].Trim(Arguments.Quote);
                unprocessedArguments.Add(argumentName, argumentValue);
            }

            var secretInjector = GetSecretInjector(unprocessedArguments);

            return new SecretDictionary(secretInjector, unprocessedArguments);
        }

Usage Example

        public static void Run(string[] args)
        {
            IDictionary <string, string> arguments = CommandHelpers.GetArguments(args, 1);

            if (arguments == null || arguments.Count == 0)
            {
                PrintUsage();
                return;
            }

            Lucene.Net.Store.Directory srcDirectory = CommandHelpers.GetCopySrcLuceneDirectory(arguments);
            if (srcDirectory == null)
            {
                Console.WriteLine("problem with src arguments");
                PrintUsage();
                return;
            }

            Lucene.Net.Store.Directory destDirectory = CommandHelpers.GetCopyDestLuceneDirectory(arguments);
            if (destDirectory == null)
            {
                Console.WriteLine("problem with dest arguments");
                PrintUsage();
                return;
            }

            Lucene.Net.Store.Directory.Copy(srcDirectory, destDirectory, true);

            Console.WriteLine("All Done");
        }
All Usage Examples Of Ng.CommandHelpers::GetArguments