本文整理汇总了C#中Builder.UnMarshal方法的典型用法代码示例。如果您正苦于以下问题:C# Builder.UnMarshal方法的具体用法?C# Builder.UnMarshal怎么用?C# Builder.UnMarshal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Builder
的用法示例。
在下文中一共展示了Builder.UnMarshal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WrapMethodCore
//.........这里部分代码省略.........
{
var parameterType = parameter.ParameterType.GetElementType();
argument = builder.Marshal(argument, parameterType);
// Create a local to hold the value.
var tmpLocal = builder.AddLocal(
parameterType,
"tmp"
);
// Add the assignment to the statements.
builder.AddStatement(Expression.Assign(tmpLocal, argument));
// And use the temp local as the parameter.
argument = tmpLocal;
// Register it so that we do a write-back later on.
outParameters.Add(Tuple.Create(parameter, tmpLocal, index));
}
else
{
argument = builder.Marshal(argument, parameter.ParameterType);
}
// Add the argument to the list.
arguments.Add(argument);
// Move on to the next argument.
index++;
}
// Call the method.
Expression methodCall = Expression.Call(
methodThis,
method,
arguments
);
// Are we returning a value?
ParameterExpression returnLocal = null;
if (method.ReturnType != typeof(void))
{
returnLocal = builder.AddLocal(method.ReturnType, "return");
methodCall = Expression.Assign(
returnLocal,
methodCall
);
}
// Add the method call to the statements.
builder.AddStatement(methodCall);
// Process any out parameters.
foreach (var outParameter in outParameters)
{
// Put the result back into the arguments array if the array
// is long enough.
builder.AddStatement(Expression.IfThen(
Expression.GreaterThan(
Expression.ArrayLength(argumentsParameter),
Expression.Constant(outParameter.Item3)
),
Expression.Assign(
Expression.ArrayAccess(
argumentsParameter,
Expression.Constant(outParameter.Item3)
),
Expression.Call(
builder.Marshaller,
_marshalClr.MakeGenericMethod(outParameter.Item1.ParameterType.GetElementType()),
outParameter.Item2
)
)
));
}
// Create the result.
builder.AddStatement(
returnLocal != null
? builder.UnMarshal(returnLocal, method.ReturnType)
: Expression.Field(null, typeof(JsUndefined).GetField("Instance"))
);
return builder.Compile<JsFunction>();
}
示例2: WrapGetPropertyCore
private static JsFunction WrapGetPropertyCore(PropertyInfo property)
{
var builder = new Builder();
builder.AddRuntimeParameter();
builder.AddThisParameter(typeof(object));
builder.AddParameter(typeof(JsObject), "callee");
builder.AddParameter(typeof(object[]), "arguments");
var method = property.GetGetMethod();
builder.AddStatement(builder.UnMarshal(
Expression.Property(
builder.MarshalThis(method.DeclaringType, method.IsStatic),
property
),
method.ReturnType
));
return builder.Compile<JsFunction>();
}
示例3: WrapIndexerGetterCore
private static WrappedIndexerGetter WrapIndexerGetterCore(MethodInfo method)
{
var builder = new Builder();
builder.AddGlobalParameter();
builder.AddThisParameter(typeof(JsObject));
var indexParameter = builder.AddParameter(typeof(object), "index");
builder.AddStatement(builder.UnMarshal(
Expression.Call(
builder.MarshalThis(method.DeclaringType, method.IsStatic),
method,
builder.Marshal(indexParameter, method.GetParameters()[0].ParameterType)
),
method.ReturnType
));
return builder.Compile<WrappedIndexerGetter>();
}
示例4: WrapGetFieldCore
private static JsFunction WrapGetFieldCore(FieldInfo field)
{
var builder = new Builder();
builder.AddRuntimeParameter();
builder.AddThisParameter(typeof(object));
builder.AddParameter(typeof(JsObject), "callee");
builder.AddParameter(typeof(object[]), "arguments");
builder.AddStatement(builder.UnMarshal(
Expression.Field(
builder.MarshalThis(field.DeclaringType, field.IsStatic),
field
),
field.FieldType
));
return builder.Compile<JsFunction>();
}