summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/Source/CommandLine/ParseArgumentsResult.cs
blob: fc7fab6646e750f25c4b03f640043433369b9032 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright © Microsoft Corporation.
// This source file is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Microsoft.Ddue.Tools.CommandLine {

    public sealed class ParseArgumentsResult {

        internal Dictionary < string, ParseResult > errors = new Dictionary < string, ParseResult >();

        internal List < string > nonoptions = new List < string >();

        // data

        internal OptionCollection options;

        internal ParseArgumentsResult() { }

        // accessors

        public OptionCollection Options {
            get {
                return (options);
            }
        }

        public bool Success {
            get {
                if (errors.Count == 0) {
                    return (true);
                } else {
                    return (false);
                }
            }
        }

        public ReadOnlyCollection < string > UnusedArguments {

            get {
                return (new ReadOnlyCollection < string >(nonoptions));
            }
        }

        public void WriteParseErrors(TextWriter writer) {

            if (writer == null) throw new ArgumentNullException("writer");
            foreach (KeyValuePair < string, ParseResult > error in errors) {
                writer.WriteLine("{0}: {1}", error.Value, error.Key);

            }

        }

    }


}