当前位置: 首页>>代码示例>>C#>>正文


C# TypeBuilder.AddInterfaceImplementation方法代码示例

本文整理汇总了C#中TypeBuilder.AddInterfaceImplementation方法的典型用法代码示例。如果您正苦于以下问题:C# TypeBuilder.AddInterfaceImplementation方法的具体用法?C# TypeBuilder.AddInterfaceImplementation怎么用?C# TypeBuilder.AddInterfaceImplementation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeBuilder的用法示例。


在下文中一共展示了TypeBuilder.AddInterfaceImplementation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddReadResolve

 private static void AddReadResolve(DynamicTypeWrapper wrapper, TypeBuilder tb)
 {
     MethodWrapper mw = wrapper.GetMethodWrapper("readResolve", "()Ljava.lang.Object;", false);
     if (mw != null && !wrapper.IsSubTypeOf(iobjectreference))
     {
         tb.AddInterfaceImplementation(JVM.Import(typeof(IObjectReference)));
         MethodBuilder getRealObject = tb.DefineMethod("IObjectReference.GetRealObject", MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.Final,
             Types.Object, new Type[] { JVM.Import(typeof(StreamingContext)) });
         getRealObject.SetCustomAttribute(securityCriticalAttribute);
         AttributeHelper.HideFromJava(getRealObject);
         tb.DefineMethodOverride(getRealObject, JVM.Import(typeof(IObjectReference)).GetMethod("GetRealObject"));
         CodeEmitter ilgen = CodeEmitter.Create(getRealObject);
         mw.Link();
         if (!wrapper.IsFinal)
         {
             // readResolve is only applicable if it exists on the actual type of the object, so if we're a subclass don't call it
             ilgen.Emit(OpCodes.Ldarg_0);
             ilgen.Emit(OpCodes.Callvirt, Compiler.getTypeMethod);
             ilgen.Emit(OpCodes.Ldtoken, wrapper.TypeAsBaseType);
             ilgen.Emit(OpCodes.Call, Compiler.getTypeFromHandleMethod);
             CodeEmitterLabel label = ilgen.DefineLabel();
             ilgen.EmitBeq(label);
             ilgen.Emit(OpCodes.Ldarg_0);
             ilgen.Emit(OpCodes.Ret);
             ilgen.MarkLabel(label);
         }
         ilgen.Emit(OpCodes.Ldarg_0);
         mw.EmitCall(ilgen);
         ilgen.Emit(OpCodes.Ret);
         ilgen.DoEmit();
     }
 }
开发者ID:LogosBible,项目名称:ikvm-fork,代码行数:32,代码来源:Serialization.cs

示例2: RemoveReadResolve

 private static void RemoveReadResolve(TypeBuilder tb)
 {
     tb.AddInterfaceImplementation(JVM.Import(typeof(IObjectReference)));
     MethodBuilder getRealObject = tb.DefineMethod("IObjectReference.GetRealObject", MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.Final,
         Types.Object, new Type[] { JVM.Import(typeof(StreamingContext)) });
     getRealObject.SetCustomAttribute(securityCriticalAttribute);
     AttributeHelper.HideFromJava(getRealObject);
     tb.DefineMethodOverride(getRealObject, JVM.Import(typeof(IObjectReference)).GetMethod("GetRealObject"));
     CodeEmitter ilgen = CodeEmitter.Create(getRealObject);
     ilgen.Emit(OpCodes.Ldarg_0);
     ilgen.Emit(OpCodes.Ret);
     ilgen.DoEmit();
 }
开发者ID:LogosBible,项目名称:ikvm-fork,代码行数:13,代码来源:Serialization.cs

示例3: AddGetObjectData

 private static void AddGetObjectData(TypeBuilder tb)
 {
     tb.AddInterfaceImplementation(JVM.Import(typeof(ISerializable)));
     MethodBuilder getObjectData = tb.DefineMethod("GetObjectData", MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.NewSlot, null,
         new Type[] { JVM.Import(typeof(SerializationInfo)), JVM.Import(typeof(StreamingContext)) });
     getObjectData.SetCustomAttribute(securityCriticalAttribute);
     AttributeHelper.HideFromJava(getObjectData);
     getObjectData.AddDeclarativeSecurity(SecurityAction.Demand, psetSerializationFormatter);
     tb.DefineMethodOverride(getObjectData, JVM.Import(typeof(ISerializable)).GetMethod("GetObjectData"));
     CodeEmitter ilgen = CodeEmitter.Create(getObjectData);
     ilgen.Emit(OpCodes.Ldarg_0);
     ilgen.Emit(OpCodes.Ldarg_1);
     TypeWrapper serializationHelper = ClassLoaderWrapper.LoadClassCritical("ikvm.internal.Serialization");
     MethodWrapper mw = serializationHelper.GetMethodWrapper("writeObject", "(Ljava.lang.Object;Lcli.System.Runtime.Serialization.SerializationInfo;)V", false);
     mw.Link();
     mw.EmitCall(ilgen);
     ilgen.Emit(OpCodes.Ret);
     ilgen.DoEmit();
 }
开发者ID:LogosBible,项目名称:ikvm-fork,代码行数:19,代码来源:Serialization.cs


注:本文中的TypeBuilder.AddInterfaceImplementation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。