本文整理汇总了C#中Compiler.GetDedicatedMethod方法的典型用法代码示例。如果您正苦于以下问题:C# Compiler.GetDedicatedMethod方法的具体用法?C# Compiler.GetDedicatedMethod怎么用?C# Compiler.GetDedicatedMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compiler
的用法示例。
在下文中一共展示了Compiler.GetDedicatedMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitDedicatedMethod
bool EmitDedicatedMethod(Compiler.CompilerContext ctx, Compiler.Local valueFrom, bool read)
{
System.Reflection.Emit.MethodBuilder method = ctx.GetDedicatedMethod(key, read);
if (method == null) return false;
using (Compiler.Local token = new ProtoBuf.Compiler.Local(ctx, typeof(SubItemToken)))
{
Type rwType = read ? typeof(ProtoReader) : typeof(ProtoWriter);
ctx.LoadValue(valueFrom);
if (!read) // write requires the object for StartSubItem; read doesn't
{
if (type.IsValueType) { ctx.LoadNullRef(); }
else { ctx.CopyValue(); }
}
ctx.LoadReaderWriter();
ctx.EmitCall(rwType.GetMethod("StartSubItem"));
ctx.StoreValue(token);
// note: value already on the stack
ctx.LoadReaderWriter();
ctx.EmitCall(method);
// handle inheritance (we will be calling the *base* version of things,
// but we expect Read to return the "type" type)
if (read && type != method.ReturnType) ctx.Cast(this.type);
ctx.LoadValue(token);
ctx.LoadReaderWriter();
ctx.EmitCall(rwType.GetMethod("EndSubItem"));
}
return true;
}
示例2: EmitDedicatedMethod
bool EmitDedicatedMethod(Compiler.CompilerContext ctx, Compiler.Local valueFrom, bool read)
{
#if SILVERLIGHT
return false;
#else
MethodBuilder method = ctx.GetDedicatedMethod(key, read);
if (method == null) return false;
using (Compiler.Local token = new ProtoBuf.Compiler.Local(ctx, ctx.MapType(typeof(SubItemToken))))
{
Type rwType = ctx.MapType(read ? typeof(ProtoReader) : typeof(ProtoWriter));
ctx.LoadValue(valueFrom);
if (!read) // write requires the object for StartSubItem; read doesn't
{ // (if recursion-check is disabled [subtypes] then null is fine too)
if (type.IsValueType || !recursionCheck) { ctx.LoadNullRef(); }
else { ctx.CopyValue(); }
}
ctx.LoadReaderWriter();
ctx.EmitCall(rwType.GetMethod("StartSubItem"));
ctx.StoreValue(token);
// note: value already on the stack
ctx.LoadReaderWriter();
ctx.EmitCall(method);
// handle inheritance (we will be calling the *base* version of things,
// but we expect Read to return the "type" type)
if (read && type != method.ReturnType) ctx.Cast(this.type);
ctx.LoadValue(token);
ctx.LoadReaderWriter();
ctx.EmitCall(rwType.GetMethod("EndSubItem"));
}
return true;
#endif
}