public SubjectMethodExistsForDuckProxySubjectCoder(IProxyCodeBuilder pcb, Type methodExistsSubjectType, Type realSubjectType)
 {
     _methodExistsSubjectType = methodExistsSubjectType;
     _realSubjectType = realSubjectType;
     var pcd = MethodIndexFactory.GetProxyClassDescriptorForSubjectType(methodExistsSubjectType);
     _methodIndexProxyType = pcb.ProxyCoderContext.ProxyModule.GetTypeFromProxyClassDescriptor(pcd);
     _ftb = pcb.SelfTypeBuilder;
     _smiMethod = GenerateStaticFromMethodIndex();
 }
        public SubjectMethodExistsForDuckProxySubjectCoder(IProxyCodeBuilder pcb, Type methodExistsSubjectType, Type realSubjectType)
        {
            _methodExistsSubjectType = methodExistsSubjectType;
            _realSubjectType         = realSubjectType;
            var pcd = MethodIndexFactory.GetProxyClassDescriptorForSubjectType(methodExistsSubjectType);

            _methodIndexProxyType = pcb.ProxyCoderContext.ProxyModule.GetTypeFromProxyClassDescriptor(pcd);
            _ftb       = pcb.SelfTypeBuilder;
            _smiMethod = GenerateStaticFromMethodIndex();
        }
        void EmitCtorForSafeDirectProxy(ILGenerator gen, Type returnType)
        {
            // The argument for the constructor is already on the stack (which is the return value
            // from the method call on the real subject).
            var pcd = new ProxyClassDescriptor(
                new RealSubjectMixin(returnType, new SafeDirectProxySubject(returnType), new SafeProxyMetaSubject()));
            IFooType proxyType = _proxyModule.GetTypeFromProxyClassDescriptor(pcd);
            var      ctor      = proxyType.GetConstructor(new[] { returnType });

            // ReSharper disable once AssignNullToNotNullAttribute
            gen.Emit(OpCodes.Newobj, ctor);
            // Needed for PEVerify
            gen.Emit(OpCodes.Castclass, returnType);
        }
 public static void PushInstanceOnStackFor(IFooType proxyType, ILGenerator gen)
 {
     var method = proxyType.GetMethod(InstanceGetMethodName, Type.EmptyTypes);
     gen.Emit(OpCodes.Call, method);
 }
Beispiel #5
0
        public static void PushInstanceOnStackFor(IFooType proxyType, ILGenerator gen)
        {
            var method = proxyType.GetMethod(InstanceGetMethodName, Type.EmptyTypes);

            gen.Emit(OpCodes.Call, method);
        }