public Type CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy,
                                                          ProxyGenerationOptions options)
        {
            AssertValidType(interfaceToProxy);
            AssertValidTypes(additionalInterfacesToProxy);

            var generator = new InterfaceProxyWithoutTargetGenerator(ModuleScope, interfaceToProxy)
            {
                Logger = Logger
            };

            return(generator.GenerateCode(typeof(object), additionalInterfacesToProxy, options));
        }
Ejemplo n.º 2
0
        public object RecreateInterfaceProxy(string generatorType)
        {
            var @interface = DeserializeTypeFromString("__theInterface");
            var targetType = DeserializeTypeFromString("__targetFieldType");

            BaseInterfaceProxyGenerator generator;

            if (generatorType == ProxyTypeConstants.InterfaceWithTarget)
            {
                generator = new InterfaceProxyWithTargetGenerator(
                    scope,
                    @interface,
                    interfaces,
                    targetType,
                    proxyGenerationOptions
                    );
            }
            else if (generatorType == ProxyTypeConstants.InterfaceWithoutTarget)
            {
                generator = new InterfaceProxyWithoutTargetGenerator(
                    scope,
                    @interface,
                    interfaces,
                    targetType,
                    proxyGenerationOptions
                    );
            }
            else if (generatorType == ProxyTypeConstants.InterfaceWithTargetInterface)
            {
                generator = new InterfaceProxyWithTargetInterfaceGenerator(
                    scope,
                    @interface,
                    interfaces,
                    targetType,
                    proxyGenerationOptions
                    );
            }
            else
            {
                throw new InvalidOperationException(
                          string.Format(
                              "Got value {0} for the interface generator type, which is not known for the purpose of serialization.",
                              generatorType
                              )
                          );
            }

            var proxyType = generator.GetProxyType();

            return(FormatterServices.GetSafeUninitializedObject(proxyType));
        }
Ejemplo n.º 3
0
        public Type CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy,
                                                          ProxyGenerationOptions options)
        {
            AssertValidType(interfaceToProxy, nameof(interfaceToProxy));
            AssertValidTypes(additionalInterfacesToProxy, nameof(additionalInterfacesToProxy));
            AssertValidMixins(options, nameof(options));

            var generator = new InterfaceProxyWithoutTargetGenerator(scope, interfaceToProxy, additionalInterfacesToProxy, typeof(object), options)
            {
                Logger = logger
            };

            return(generator.GetProxyType());
        }