本文整理汇总了C#中Argument类的典型用法代码示例。如果您正苦于以下问题:C# Argument类的具体用法?C# Argument怎么用?C# Argument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Argument类属于命名空间,在下文中一共展示了Argument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
protected override IEnumerable<string> Format(Argument[] arguments)
{
var list = new List<string>();
string deferred = null;
foreach (var argument in arguments)
{
if (deferred != null)
{
deferred += ",";
}
foreach (var line in this.Format(argument))
{
if (deferred != null)
{
list.Add(deferred);
}
deferred = line;
}
}
if (deferred != null)
{
list.Add(deferred);
}
return list;
}
示例2: Invoke
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
{
if (input.Arguments.Count > 0)
{
var arguments = new Argument[input.Arguments.Count];
for (int i = 0; i < input.Arguments.Count; i++)
{
arguments[i] = new Argument
{
Name = input.Arguments.ParameterName(i),
Value = input.Arguments[i]
};
}
_tape.RecordRequest(arguments, input.MethodBase.ReflectedType, input.MethodBase.Name);
}
Console.WriteLine("> Intercepting " + input.MethodBase.Name);
Console.WriteLine("> Intercepting " + input.MethodBase.ReflectedType);
IMethodReturn methodReturn = getNext()(input, getNext);
Console.WriteLine("> Intercepted return value: " + methodReturn.ReturnValue.GetType().Name);
if (methodReturn.ReturnValue != null)
{
_tape.RecordResponse(methodReturn.ReturnValue, input.MethodBase.ReflectedType, input.MethodBase.Name);
}
return methodReturn;
}
示例3: GetResult
private IEnumerable<string> GetResult(string text)
{
var mock = new Mock<IRunner>();
mock.Setup(o => o.WorkingDirectory).Returns(Path.Combine(Environment.CurrentDirectory, "Test"));
_argument = ArgumentFactory.Create(mock.Object, text);
return _argument.Complete();
}
示例4: concat
private void concat(StringBuilder buf, Argument arg) {
Iterator<Token> it = arg.iterator();
while (it.hasNext()) {
Token tok = it.next();
buf.append(tok.getText());
}
}
示例5: IArgumentInfo_DefaultValue_returns_same_as_typed_property
public void IArgumentInfo_DefaultValue_returns_same_as_typed_property()
{
var arg = new Argument<string>(_parser, "short", "long", "foo", false);
arg.DefaultValue = "timmeh!";
Assert.Equal("timmeh!", ((IArgument)arg).DefaultValue);
}
示例6: Command
public Command(Argument[] arguments, string description, string group, string name)
{
Arguments = arguments;
Description = description;
Group = group;
Name = name;
}
示例7: Make
public static SCode Make(Primitive2 rator, Argument rand0, SCode rand1)
{
return
(rand0 is Argument0) ? PrimitiveIsCharEqA0.Make (rator, (Argument0) rand0, rand1)
: (rand0 is Argument1) ? PrimitiveIsCharEqA1.Make (rator, (Argument1) rand0, rand1)
: Unimplemented ();
}
示例8: GetValue
public object GetValue(Argument arg, int size)
{
switch (Tag)
{
case TypeTag.Boolean:
case TypeTag.Int8:
case TypeTag.UInt8:
case TypeTag.Int16:
case TypeTag.UInt16:
case TypeTag.Int32:
case TypeTag.UInt32:
case TypeTag.Int64:
case TypeTag.UInt64:
case TypeTag.Int:
case TypeTag.UInt:
case TypeTag.Long:
case TypeTag.ULong:
case TypeTag.SSize:
case TypeTag.Size:
case TypeTag.Float:
case TypeTag.Double:
return typeof(Argument).GetField(Tag.ToString()).GetValue(arg);
case TypeTag.Utf8:
return GObject.Marshaller.Utf8PtrToString((IntPtr) arg.Pointer);
default:
return null;
}
}
示例9: exception_is_thrown_when_argments_are_not_valid
public void exception_is_thrown_when_argments_are_not_valid()
{
_parser.IsValid = false;
var arg = new Argument<int>(_parser, "shortName", "longName", "description", true);
int value;
Assert.Throws<InvalidOperationException>(() => value = arg.Value);
}
示例10: Value_returns_default_value_when_IsMissing
public void Value_returns_default_value_when_IsMissing()
{
_parser.IsValid = true;
var arg = new Argument<string>(_parser, "short", "long", "foo", false);
arg.IsMissing = true;
arg.DefaultValue = "gobbles!";
Assert.Equal("gobbles!", arg.Value);
}
示例11: ArgumentUsageInfo
/// <summary>
/// Constructor that forms the info from the argument's metadata.
/// </summary>
/// <param name="setAttribute">Argument set attribute.</param>
/// <param name="arg">Argument metadata.</param>
public ArgumentUsageInfo(ArgumentSetAttribute setAttribute, Argument arg)
{
Syntax = arg.GetSyntaxHelp(setAttribute);
Description = arg.Attribute.HelpText;
Required = arg.IsRequired;
ShortName = arg.ShortName;
DefaultValue = TryGetDefaultValueString(setAttribute, arg);
}
示例12: Action
protected Action(Argument argument, IActionContainer container=null)
{
Argument = argument;
Container = container;
OptionStrings = new List<string>(Argument.OptionStrings ?? new string[] {});
Destination = Argument.Destination;
IsRequired = Argument.IsRequired;
}
示例13: Make
public static SCode Make(Primitive2 rator, Argument rand0, SCode rand1)
{
return
(rand0 is Argument0) ? PrimitiveIsObjectEqA0.Make (rator, (Argument0) rand0, rand1)
: (rand0 is Argument1) ? PrimitiveIsObjectEqA1.Make (rator, (Argument1) rand0, rand1)
: (rand1 is LexicalVariable) ? Unimplemented()
: (rand1 is Quotation) ? PrimitiveIsObjectEqAQ.Make (rator, rand0, (Quotation) rand1)
: new PrimitiveIsObjectEqA (rator, rand0, rand1);
}
示例14: Format
protected IEnumerable<string> Format(Argument argument)
{
var type = argument.GetType();
if (type == typeof(NamedArgument)) return Format((NamedArgument)argument);
if (type == typeof(PositionalArgument)) return Format((PositionalArgument)argument);
throw new ArgumentException("Unhandled type " + type.FullName, nameof(argument));
}
示例15: SetArgumentValue
internal void SetArgumentValue(IScriptExtent extent, object value)
{
if (this._argument == null)
{
this._argument = new Argument();
}
this._argument.value = value;
this._argument.extent = extent;
}