Beispiel #1
0
        public void CreateSerializable()
        {
            MySerializableClass proxy = (MySerializableClass)
                                        generator.CreateClassProxy(typeof(MySerializableClass), new StandardInterceptor());

            Assert.IsTrue(proxy.GetType().IsSerializable);
        }
Beispiel #2
0
        public void DeserializationWithSpecificModuleScope()
        {
            ProxyObjectReference.SetScope(generator.ProxyBuilder.ModuleScope);
            MySerializableClass first  = generator.CreateClassProxy <MySerializableClass>(new StandardInterceptor());
            MySerializableClass second = SerializeAndDeserialize(first);

            Assert.AreSame(first.GetType(), second.GetType());
        }
Beispiel #3
0
        public void ProxyGenerationOptionsRespectedOnDeserialization()
        {
            MethodFilterHook       hook    = new MethodFilterHook("(get_Current)|(GetExecutingObject)");
            ProxyGenerationOptions options = new ProxyGenerationOptions(hook);

            options.AddMixinInstance(new SerializableMixin());
            options.Selector = new SerializableInterceptorSelector();

            MySerializableClass proxy = (MySerializableClass)generator.CreateClassProxy(
                typeof(MySerializableClass),
                new Type[0],
                options,
                new StandardInterceptor());

            Assert.AreEqual(proxy.GetType(), proxy.GetType().GetMethod("get_Current").DeclaringType);
            Assert.AreNotEqual(proxy.GetType(), proxy.GetType().GetMethod("CalculateSumDistanceNow").DeclaringType);
            Assert.AreEqual(proxy.GetType().BaseType, proxy.GetType().GetMethod("CalculateSumDistanceNow").DeclaringType);
            ProxyGenerationOptions options2 =
                (ProxyGenerationOptions)proxy.GetType().GetField("proxyGenerationOptions").GetValue(null);

            Assert.IsNotNull(Array.Find(options2.MixinsAsArray(), delegate(object o) { return(o is SerializableMixin); }));
            Assert.IsNotNull(options2.Selector);

            MySerializableClass otherProxy = (MySerializableClass)SerializeAndDeserialize(proxy);

            Assert.AreEqual(otherProxy.GetType(), otherProxy.GetType().GetMethod("get_Current").DeclaringType);
            Assert.AreNotEqual(otherProxy.GetType(), otherProxy.GetType().GetMethod("CalculateSumDistanceNow").DeclaringType);
            Assert.AreEqual(otherProxy.GetType().BaseType,
                            otherProxy.GetType().GetMethod("CalculateSumDistanceNow").DeclaringType);
            options2 = (ProxyGenerationOptions)otherProxy.GetType().GetField("proxyGenerationOptions").GetValue(null);
            Assert.IsNotNull(Array.Find(options2.MixinsAsArray(), delegate(object o) { return(o is SerializableMixin); }));
            Assert.IsNotNull(options2.Selector);
        }
Beispiel #4
0
        public void CreateSerializable()
        {
            ProxyObjectReference.ResetScope();

            MySerializableClass proxy = (MySerializableClass)
                                        generator.CreateClassProxy(typeof(MySerializableClass), new StandardInterceptor());

            Assert.IsTrue(proxy.GetType().IsSerializable);
        }
Beispiel #5
0
        public void ReusingModuleScopeFromProxyObjectReference()
        {
            ProxyGenerator generatorWithSpecificModuleScope =
                new ProxyGenerator(new DefaultProxyBuilder(ProxyObjectReference.ModuleScope));

            Assert.AreSame(generatorWithSpecificModuleScope.ProxyBuilder.ModuleScope, ProxyObjectReference.ModuleScope);
            MySerializableClass first =
                generatorWithSpecificModuleScope.CreateClassProxy <MySerializableClass>(new StandardInterceptor());
            MySerializableClass second = SerializeAndDeserialize(first);

            Assert.AreSame(first.GetType(), second.GetType());
        }