本文整理汇总了C#中Builder.AddGlobalParameter方法的典型用法代码示例。如果您正苦于以下问题:C# Builder.AddGlobalParameter方法的具体用法?C# Builder.AddGlobalParameter怎么用?C# Builder.AddGlobalParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Builder
的用法示例。
在下文中一共展示了Builder.AddGlobalParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WrapIndexerSetterCore
private static WrappedIndexerSetter WrapIndexerSetterCore(MethodInfo method)
{
var builder = new Builder();
builder.AddGlobalParameter();
builder.AddThisParameter(typeof(JsObject));
var indexParameter = builder.AddParameter(typeof(object), "index");
var argument = builder.AddParameter(typeof(object), "value");
var parameters = method.GetParameters();
builder.AddStatement(Expression.Call(
builder.MarshalThis(method.DeclaringType, method.IsStatic),
method,
builder.Marshal(indexParameter, parameters[0].ParameterType),
builder.Marshal(argument, parameters[1].ParameterType)
));
return builder.Compile<WrappedIndexerSetter>();
}
示例2: WrapConstructorCore
private static WrappedConstructor WrapConstructorCore(ConstructorInfo constructor)
{
var builder = new Builder();
builder.AddGlobalParameter();
var argumentsParameter = builder.AddParameter(typeof(object[]), "arguments");
var parameters = constructor.GetParameters();
var arguments = new List<Expression>();
for (int i = 0; i < parameters.Length; i++)
{
// Get the argument from the array, or undefined there is none,
// and marshal it.
arguments.Add(builder.Marshal(
Expression.Condition(
Expression.GreaterThan(
Expression.ArrayLength(argumentsParameter),
Expression.Constant(i)
),
Expression.ArrayAccess(
argumentsParameter,
Expression.Constant(i)
),
Expression.Field(null, typeof(JsUndefined).GetField("Instance")),
typeof(object)
),
parameters[i].ParameterType
));
}
// Construct the new object. This does **NOT** un-marshal the
// result; this is done at the call site.
builder.AddStatement(Expression.Convert(
Expression.New(
constructor,
arguments
),
typeof(object)
));
return builder.Compile<WrappedConstructor>();
}