Permalink
Browse files

more xmldoc

  • Loading branch information...
1 parent 86e90df commit c9253f4ca56eab7421a1e9b07e1dca954b5a99b3 @adrianaisemberg adrianaisemberg committed Oct 31, 2011
Showing with 397 additions and 81 deletions.
  1. +3 −0 CLAP/FileSystemHelper.cs
  2. +10 −0 CLAP/IValidation.cs
  3. +1 −5 CLAP/Method.cs
  4. +3 −0 CLAP/MethodInvoker.cs
  5. +84 −61 CLAP/MultiParser.cs
  6. +1 −5 CLAP/Parameter.cs
  7. +11 −1 CLAP/ParametersExpressionValidator.cs
  8. +284 −9 CLAP/Parser.cs
View
@@ -2,6 +2,9 @@
namespace CLAP
{
+ /// <summary>
+ /// A helper for file reading to allow mocking for tests
+ /// </summary>
public static class FileSystemHelper
{
public static IFileSystem FileHandler { get; set; }
View
@@ -1,8 +1,15 @@
namespace CLAP
{
+ /// <summary>
+ /// Validation of collections of parameters and values
+ /// </summary>
public interface ICollectionValidation
{
+ /// <summary>
+ /// Gets an instance of the collection validator
+ /// </summary>
+ /// <returns></returns>
ICollectionValidator GetValidator();
/// <summary>
@@ -11,6 +18,9 @@ public interface ICollectionValidation
string Description { get; }
}
+ /// <summary>
+ /// Validation of collections of parameters and values
+ /// </summary>
public interface ICollectionValidator
{
void Validate(ValueInfo[] properties);
View
@@ -36,11 +36,7 @@ public sealed class Method
#region Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="method">The <see cref="MethodInfo"/> to describe</param>
- public Method(MethodInfo method)
+ internal Method(MethodInfo method)
{
Debug.Assert(method != null);
View
@@ -3,6 +3,9 @@
namespace CLAP
{
+ /// <summary>
+ /// A helper for method invoking to allow mocking for tests
+ /// </summary>
public static class MethodInvoker
{
public static IMethodInvoker Invoker { get; set; }
View
@@ -5,6 +5,9 @@
namespace CLAP
{
+ /// <summary>
+ /// A parser of one or more classes
+ /// </summary>
public abstract class MultiParser
{
#region Fields
@@ -16,6 +19,9 @@ public abstract class MultiParser
#region Properties
+ /// <summary>
+ /// Parser registration
+ /// </summary>
public ParserRegistration Register { get; private set; }
#endregion Properties
@@ -38,7 +44,7 @@ protected MultiParser()
#endregion Constructors
- #region Methods
+ #region Private Methods
private void Init()
{
@@ -52,65 +58,6 @@ private void Init()
Register = new ParserRegistration(GetHelpString, ValuesFactory.GetValueForParameter);
}
- public void RunStatic(string[] args)
- {
- RunTargets(args, null);
- }
-
- public void RunTargets(string[] args, params object[] targets)
- {
- // no args
- //
- if (args.None() || args.All(a => string.IsNullOrEmpty(a)))
- {
- HandleEmptyArguments(targets);
-
- return;
- }
-
- ParserRunner parser;
-
- if (m_types.Length == 1)
- {
- parser = GetSingleTypeParser(args, targets, Register);
- }
- else
- {
- Debug.Assert(m_types.Length > 1);
-
- parser = GetMultiTypesParser(args, targets, Register);
- }
-
- Debug.Assert(parser != null);
-
- var index = m_types.ToList().IndexOf(parser.Type);
-
- Debug.Assert(index >= 0);
-
- var target = targets.None() ? null : targets[index];
-
- parser.Run(args, target);
- }
-
- public string GetHelpString()
- {
- var sb = new StringBuilder();
-
- foreach (var type in m_types)
- {
- var pr = new ParserRunner(type, Register);
-
- sb.AppendLine(type.Name);
- sb.AppendLine("".PadLeft(30, '-'));
-
- sb.AppendLine(pr.GetHelpString());
-
- sb.AppendLine();
- }
-
- return sb.ToString();
- }
-
private void HandleEmptyArguments(object[] targets)
{
if (Register.RegisteredEmptyHandler != null)
@@ -209,6 +156,82 @@ private ParserRunner GetSingleTypeParser(string[] args, object obj, ParserRegist
return parser;
}
- #endregion Methods
+ #endregion Private Methods
+
+ #region Public Methods
+
+ /// <summary>
+ /// Run a parser of static verbs
+ /// </summary>
+ /// <param name="args">The user arguments</param>
+ public void RunStatic(string[] args)
+ {
+ RunTargets(args, null);
+ }
+
+ /// <summary>
+ /// Run a parser of instance verbs against instances of the verb classes
+ /// </summary>
+ /// <param name="args">The user arguments</param>
+ /// <param name="targets">The instances of the verb classes</param>
+ public void RunTargets(string[] args, params object[] targets)
+ {
+ // no args
+ //
+ if (args.None() || args.All(a => string.IsNullOrEmpty(a)))
+ {
+ HandleEmptyArguments(targets);
+
+ return;
+ }
+
+ ParserRunner parser;
+
+ if (m_types.Length == 1)
+ {
+ parser = GetSingleTypeParser(args, targets, Register);
+ }
+ else
+ {
+ Debug.Assert(m_types.Length > 1);
+
+ parser = GetMultiTypesParser(args, targets, Register);
+ }
+
+ Debug.Assert(parser != null);
+
+ var index = m_types.ToList().IndexOf(parser.Type);
+
+ Debug.Assert(index >= 0);
+
+ var target = targets.None() ? null : targets[index];
+
+ parser.Run(args, target);
+ }
+
+ /// <summary>
+ /// Gets a help string that describes all the parser information for the user
+ /// </summary>
+ public string GetHelpString()
+ {
+#warning TODO: this is crap
+ var sb = new StringBuilder();
+
+ foreach (var type in m_types)
+ {
+ var pr = new ParserRunner(type, Register);
+
+ sb.AppendLine(type.Name);
+ sb.AppendLine("".PadLeft(30, '-'));
+
+ sb.AppendLine(pr.GetHelpString());
+
+ sb.AppendLine();
+ }
+
+ return sb.ToString();
+ }
+
+ #endregion Public Methods
}
}
View
@@ -42,11 +42,7 @@ public sealed class Parameter
#region Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="parameter">The <see cref="ParameterInfo"/> to describe</param>
- public Parameter(ParameterInfo parameter)
+ internal Parameter(ParameterInfo parameter)
{
Debug.Assert(parameter != null);
@@ -3,9 +3,19 @@
namespace CLAP
{
+ /// <summary>
+ /// Validates a collection of named parameters or properties against a boolean expression
+ /// </summary>
internal class ParametersExpressionValidator : ICollectionValidator
{
+ /// <summary>
+ /// The expression
+ /// </summary>
public string Expression { get; private set; }
+
+ /// <summary>
+ /// Whether the expression should be treated as case-sensitive
+ /// </summary>
public bool CaseSensitive { get; private set; }
internal ParametersExpressionValidator(string expression, bool caseSensitive)
@@ -47,4 +57,4 @@ public void Validate(ValueInfo[] parameters)
}
}
}
-}
+}
Oops, something went wrong.

0 comments on commit c9253f4

Please sign in to comment.