diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-09-20 21:18:59 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-09-21 08:06:22 -0700 |
commit | bbe3f9cc9c8a1e5909273c1a162a63ea7a66afd8 (patch) | |
tree | c91f66e642c4d26fca266e226b3f2765f546d700 /tools/Sandcastle/Source/CommandLine/Option.cs | |
parent | 627014f0bbc3fd576277375e70f8391d150b0a67 (diff) | |
download | DotNetOpenAuth-bbe3f9cc9c8a1e5909273c1a162a63ea7a66afd8.zip DotNetOpenAuth-bbe3f9cc9c8a1e5909273c1a162a63ea7a66afd8.tar.gz DotNetOpenAuth-bbe3f9cc9c8a1e5909273c1a162a63ea7a66afd8.tar.bz2 |
Switched out the Sandcastle binaries for the source code.
Diffstat (limited to 'tools/Sandcastle/Source/CommandLine/Option.cs')
-rw-r--r-- | tools/Sandcastle/Source/CommandLine/Option.cs | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/tools/Sandcastle/Source/CommandLine/Option.cs b/tools/Sandcastle/Source/CommandLine/Option.cs new file mode 100644 index 0000000..fb9ed00 --- /dev/null +++ b/tools/Sandcastle/Source/CommandLine/Option.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +using System; +using System.IO; +using System.Collections.Generic; + +namespace Microsoft.Ddue.Tools.CommandLine { + + public abstract class Option { + + internal bool processed; + + protected bool present; + protected object value; + private string description; + + // Data Members + + private string name; + private bool required; + + // Constructors + + protected Option(string name) { + foreach (char character in name) { + if (!(Char.IsLetter(character) || (character == '?'))) throw new ArgumentException("Names must consist of letters.", "name"); + } + this.name = name; + } + + protected Option(string name, string description) : this(name) { + this.description = description; + } + + protected Option(string name, string description, bool required) : this(name, description) { + this.required = required; + } + + public string Description { + get { + return (description); + } + set { + if (processed) throw new InvalidOperationException(); + description = value; + } + } + + public virtual bool IsPresent { + get { + if (!processed) throw new InvalidOperationException(); + return (present); + } + } + + public bool IsRequired { + get { + return (required); + } + set { + if (processed) throw new InvalidOperationException(); + required = value; + } + } + + // Accessors + + public string Name { + get { + return (name); + } + set { + if (processed) throw new InvalidOperationException(); + name = value; + } + } + + public virtual Object Value { + get { + if (!processed) throw new InvalidOperationException(); + return (value); + } + } + + // To be implemented by children + + internal abstract ParseResult ParseArgument(string args); + + internal abstract void WriteTemplate(TextWriter writer); + + } + +} |