fork from 1.3
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
namespace FreeSR.Shared.Command.Convert
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class CommandParameterConverterAttribute : Attribute
|
||||
{
|
||||
public Type Type { get; }
|
||||
|
||||
public CommandParameterConverterAttribute(Type type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FreeSR.Shared.Command.Convert
|
||||
{
|
||||
public interface ICommandParameterConverter
|
||||
{
|
||||
bool TryConvert(string parameter, out object result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace FreeSR.Shared.Command.Convert
|
||||
{
|
||||
[CommandParameterConverter(typeof(string))]
|
||||
public class StringCommandParameterConverter : ICommandParameterConverter
|
||||
{
|
||||
public bool TryConvert(string parameter, out object result)
|
||||
{
|
||||
result = parameter;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace FreeSR.Shared.Command.Convert
|
||||
{
|
||||
[CommandParameterConverter(typeof(uint))]
|
||||
public class UIntCommandParameterConverter : ICommandParameterConverter
|
||||
{
|
||||
public bool TryConvert(string parameter, out object result)
|
||||
{
|
||||
result = null;
|
||||
if (!uint.TryParse(parameter, out uint parseResult))
|
||||
return false;
|
||||
|
||||
result = parseResult;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user