Defines that the string[] argument accepts all arguments provided to the command, useage:
void MyCommand([AllArguments] string[] arguments)
or
void MyCommand([AllArguments] string[] arguments, ICommandInterpreter ci)
Syntax
Example
Library/Library.Test/TestCmdInterpreter.cs
C# | Copy Code |
---|
CommandInterpreter ci = new CommandInterpreter(new TestCommands());
IOption option = ci.Options[0];
//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);
{
CommandFilterAttribute a = new CommandFilterAttribute();
Assert.IsFalse(a.Visible);
a.Visible = true;
Assert.IsFalse(a.Visible);
}
{
CommandAttribute a = new CommandAttribute();
a.DisplayName = "test";
a.AliasNames = new string[] { "alias" };
Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
IDisplayInfo di = a;
di.Help();//no-op
}
{
AllArgumentsAttribute a = new AllArgumentsAttribute();
Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
} |
VB.NET | Copy Code |
---|
Dim ci As New CommandInterpreter(New TestCommands())
Dim [option] As IOption = ci.Options(0)
'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)
If True Then
Dim a As New CommandFilterAttribute()
Assert.IsFalse(a.Visible)
a.Visible = True
Assert.IsFalse(a.Visible)
End If
If True Then
Dim a As New CommandAttribute()
a.DisplayName = "test"
a.AliasNames = New String() {"alias"}
Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
Dim di As IDisplayInfo = a
di.Help()
'no-op
End If
If True Then
Dim a As New AllArgumentsAttribute()
Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If |
Inheritance Hierarchy
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also