示例#1
0
        public void clean()
        {
            TcpChannel channel = new TcpChannel();

            ChannelServices.RegisterChannel(channel, false);
            String            reference = "tcp://localhost:50001/MyRemoteObjectName";
            MyRemoteInterface obj       = (MyRemoteInterface)Activator.GetObject(
                typeof(MyRemoteInterface), reference);

            // The GetManuallyMarshaledObject() method uses RemotingServices.Marshal()
            // to create an ObjRef object for a SampleTwo object.
            ObjRef objRefSampleTwo = obj.GetManuallyMarshaledObject();

            SampleTwo objectSampleTwo = (SampleTwo)RemotingServices.Unmarshal(objRefSampleTwo);
        }
示例#2
0
    public static void Main()
    {
        // System.Runtime.Remoting.RemotingServices.Unmarshal
        // <Snippet2>
        ChannelServices.RegisterChannel(new HttpChannel());

        SampleService objectSample = (SampleService)Activator.GetObject(typeof(SampleService),
                                                                        "http://localhost:9000/MySampleService/SampleService.soap");

        // The GetManuallyMarshaledObject() method uses RemotingServices.Marshal()
        // to create an ObjRef object for a SampleTwo object.
        ObjRef objRefSampleTwo = objectSample.GetManuallyMarshaledObject();

        SampleTwo objectSampleTwo = (SampleTwo)RemotingServices.Unmarshal(objRefSampleTwo);

        objectSampleTwo.PrintMessage("ObjRef successfuly unmarshaled.");
        // </Snippet2>
    }
示例#3
0
        public void verify_naming_collisions()
        {
            var parser = new Parser();

            var one = new SampleOne();
            var two = new SampleTwo();

            Assert.IsTrue(parser.Parse <SampleOne>("0 == Vehicle.Car").Invoke(one));
            Assert.AreEqual(0, parser.GetFields().Count);
            Assert.AreEqual(1, parser.GetConsts().Count);
            Assert.IsTrue(parser.Parse <SampleOne>("Vehicle == Vehicle.Car").Invoke(one));
            Assert.AreEqual(1, parser.GetFields().Count);
            Assert.AreEqual(1, parser.GetConsts().Count);

            Assert.IsTrue(parser.Parse <SampleTwo>("-1 == Vehicle.Car").Invoke(two));
            Assert.AreEqual(1, parser.GetFields().Count);
            Assert.AreEqual(0, parser.GetConsts().Count);
            Assert.IsTrue(parser.Parse <SampleTwo>("Vehicle.Car != ParserTest.Vehicle.Car").Invoke(two));
            Assert.AreEqual(1, parser.GetFields().Count);
            Assert.AreEqual(1, parser.GetConsts().Count);
        }
        public void verify_naming_collisions()
        {
            var parser = new Parser();

            var one = new SampleOne();
            var two = new SampleTwo();

            Assert.IsTrue(parser.Parse<SampleOne>("0 == Vehicle.Car").Invoke(one));
            Assert.AreEqual(0, parser.GetFields().Count);
            Assert.AreEqual(1, parser.GetConsts().Count);
            Assert.IsTrue(parser.Parse<SampleOne>("Vehicle == Vehicle.Car").Invoke(one));
            Assert.AreEqual(1, parser.GetFields().Count);
            Assert.AreEqual(1, parser.GetConsts().Count);

            Assert.IsTrue(parser.Parse<SampleTwo>("-1 == Vehicle.Car").Invoke(two));
            Assert.AreEqual(1, parser.GetFields().Count);
            Assert.AreEqual(0, parser.GetConsts().Count);
            Assert.IsTrue(parser.Parse<SampleTwo>("Vehicle.Car != ParserTest.Vehicle.Car").Invoke(two));
            Assert.AreEqual(1, parser.GetFields().Count);
            Assert.AreEqual(1, parser.GetConsts().Count);
        }