Example #1
0
        public object RecreateInterfaceProxy(string generatorType)
        {
            var @interface = DeserializeTypeFromString("__theInterface");
            var targetType = DeserializeTypeFromString("__targetFieldType");

            InterfaceProxyWithTargetGenerator generator;

            if (generatorType == ProxyTypeConstants.InterfaceWithTarget)
            {
                generator = new InterfaceProxyWithTargetGenerator(scope, @interface);
            }
            else if (generatorType == ProxyTypeConstants.InterfaceWithoutTarget)
            {
                generator = new InterfaceProxyWithoutTargetGenerator(scope, @interface);
            }
            else if (generatorType == ProxyTypeConstants.InterfaceWithTargetInterface)
            {
                generator = new InterfaceProxyWithTargetInterfaceGenerator(scope, @interface);
            }
            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.GenerateCode(targetType, interfaces, proxyGenerationOptions);

            return(FormatterServices.GetSafeUninitializedObject(proxyType));
        }
Example #2
0
        public Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, Type targetType, ProxyGenerationOptions options)
        {
            AssertValidType(interfaceToProxy);
            AssertValidTypes(additionalInterfacesToProxy);

            var generator = new InterfaceProxyWithTargetGenerator(scope, interfaceToProxy)
            {
                Logger = logger
            };

            return(generator.GenerateCode(targetType, additionalInterfacesToProxy, options));
        }