Example #1
0
 /// <summary>
 /// Constructs a new object to describe the provided type.
 /// </summary>
 /// <param name="type">Type to describe.</param>
 /// <param name="parseHandler">Delegate used to parse strings with the
 /// given type.</param>
 /// <param name="completionHandler">Delegate used to generate
 /// completions with the given type.</param>
 /// <param name="displayName">The type's human-readable name.</param>
 private SimpleArgumentType(Type type, SimpleArgumentTypeParseHandler <object> parseHandler, SimpleArgumentTypeCompletionHandler completionHandler, string displayName = null)
     : base(type)
 {
     _parseHandler      = parseHandler;
     _completionHandler = completionHandler;
     _displayName       = displayName;
 }
Example #2
0
 /// <summary>
 /// Primary construction method.
 /// </summary>
 /// <typeparam name="T">Type to describe.</typeparam>
 /// <param name="parseHandler">Delegate used to parse strings with the
 /// given type.</param>
 /// <param name="completionHandler">Delegate used to complete strings with
 /// the given type.</param>
 /// <param name="displayName">The type's human-readable name.</param>
 /// <returns>The constructed object.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="parseHandler"/>
 /// is null.</exception>
 public static SimpleArgumentType Create <T>(SimpleArgumentTypeParseHandler <T> parseHandler, SimpleArgumentTypeCompletionHandler completionHandler = null, string displayName = null)
 {
     if (parseHandler == null)
     {
         throw new ArgumentNullException(nameof(parseHandler));
     }
     return(new SimpleArgumentType(typeof(T), s => parseHandler(s), completionHandler, displayName));
 }
 public static SimpleArgumentType Create <T>(SimpleArgumentTypeParseHandler <T> parseHandler, SimpleArgumentTypeCompletionHandler completionHandler = null, string displayName = null)
 {
     Debug.Assert(parseHandler != null);
     return(new SimpleArgumentType(typeof(T), s => parseHandler(s), completionHandler, displayName));
 }