Browse Source

Add a doc

pull/1123/head
Joe4evr 7 years ago
parent
commit
27dc92cdce
2 changed files with 6 additions and 2 deletions
  1. +4
    -0
      src/Discord.Net.Commands/Attributes/NamedArgumentTypeAttribute.cs
  2. +2
    -2
      test/Discord.Net.Tests/Tests.TypeReaders.cs

+ 4
- 0
src/Discord.Net.Commands/Attributes/NamedArgumentTypeAttribute.cs View File

@@ -2,6 +2,10 @@ using System;


namespace Discord.Commands namespace Discord.Commands
{ {
/// <summary>
/// Instructs the command system to treat command paramters of this type
/// as a collection of named arguments matching to its properties.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class NamedArgumentTypeAttribute : Attribute { } public sealed class NamedArgumentTypeAttribute : Attribute { }
} }

+ 2
- 2
test/Discord.Net.Tests/Tests.TypeReaders.cs View File

@@ -25,7 +25,7 @@ namespace Discord
Assert.NotNull(param); Assert.NotNull(param);
Assert.True(param.IsRemainder); Assert.True(param.IsRemainder);


var result = await param.ParseAsync(null, "foo: 42 bar: hello");
var result = await param.ParseAsync(null, "bar: hello foo: 42");
Assert.True(result.IsSuccess); Assert.True(result.IsSuccess);


var m = result.BestMatch as ArgumentType; var m = result.BestMatch as ArgumentType;
@@ -51,7 +51,7 @@ namespace Discord
Assert.NotNull(param); Assert.NotNull(param);
Assert.True(param.IsRemainder); Assert.True(param.IsRemainder);


var result = await param.ParseAsync(null, "bar: 《hello》 foo: 42");
var result = await param.ParseAsync(null, "foo: 42 bar: 《hello》");
Assert.True(result.IsSuccess); Assert.True(result.IsSuccess);


var m = result.BestMatch as ArgumentType; var m = result.BestMatch as ArgumentType;


Loading…
Cancel
Save