Complete builders, start work on using them

This commit is contained in:
FiniteReality
2016-11-15 20:53:18 +00:00
parent f95154af23
commit af433c82cc
11 changed files with 416 additions and 408 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Discord.Commands.Builders;
namespace Discord.Commands
{
public class ParameterInfo
{
private readonly TypeReader _reader;
internal ParameterInfo(ParameterBuilder builder, CommandInfo command, CommandService service)
{
Command = command;
Name = builder.Name;
Summary = builder.Summary;
IsOptional = builder.Optional;
IsRemainder = builder.Remainder;
IsMultiple = builder.Multiple;
ParameterType = builder.ParameterType;
DefaultValue = builder.DefaultValue;
_reader = builder.TypeReader;
}
public CommandInfo Command { get; }
public string Name { get; }
public string Summary { get; }
public bool IsOptional { get; }
public bool IsRemainder { get; }
public bool IsMultiple { get; }
public Type ParameterType { get; }
public object DefaultValue { get; }
public async Task<TypeReaderResult> Parse(CommandContext context, string input)
{
return await _reader.Read(context, input).ConfigureAwait(false);
}
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name}{(IsOptional ? " (Optional)" : "")}{(IsRemainder ? " (Remainder)" : "")}";
}
}