コード例 #1
0
        public void CanBuildChannelFactory()
        {
            // with HttpTransport
            var m = new WebMessageEncodingBindingElement();

            Assert.IsTrue(m.CanBuildChannelFactory <IRequestChannel> (CreateBindingContext()), "#1");
            Assert.IsFalse(m.CanBuildChannelFactory <IReplyChannel> (CreateBindingContext()), "#2");
            Assert.IsFalse(m.CanBuildChannelFactory <IRequestSessionChannel> (CreateBindingContext()), "#3");
            Assert.IsFalse(m.CanBuildChannelFactory <IDuplexChannel> (CreateBindingContext()), "#4");

            // actually they are from transport
            var h = new HttpTransportBindingElement();

            Assert.IsTrue(h.CanBuildChannelFactory <IRequestChannel> (CreateBindingContext()), "#5");
            Assert.IsFalse(h.CanBuildChannelFactory <IReplyChannel> (CreateBindingContext()), "#6");
            Assert.IsFalse(h.CanBuildChannelFactory <IRequestSessionChannel> (CreateBindingContext()), "#7");
            Assert.IsFalse(h.CanBuildChannelFactory <IDuplexChannel> (CreateBindingContext()), "#8");

            // with TcpTransport
            Assert.IsFalse(m.CanBuildChannelFactory <IRequestChannel> (CreateBindingContext2()), "#9");
            Assert.IsFalse(m.CanBuildChannelFactory <IReplyChannel> (CreateBindingContext2()), "#10");
            Assert.IsFalse(m.CanBuildChannelFactory <IRequestSessionChannel> (CreateBindingContext2()), "#11");
            Assert.IsFalse(m.CanBuildChannelFactory <IDuplexChannel> (CreateBindingContext2()), "#12");

            // ... yes, actually they are from transport
            var t = new TcpTransportBindingElement();

            Assert.IsFalse(t.CanBuildChannelFactory <IRequestChannel> (CreateBindingContext2()), "#13");
            Assert.IsFalse(t.CanBuildChannelFactory <IReplyChannel> (CreateBindingContext2()), "#14");
            Assert.IsFalse(t.CanBuildChannelFactory <IRequestSessionChannel> (CreateBindingContext2()), "#15");
            Assert.IsFalse(t.CanBuildChannelFactory <IDuplexChannel> (CreateBindingContext2()), "#16");
        }
コード例 #2
0
		public void CanBuildChannelFactory ()
		{
			// with HttpTransport
			var m = new WebMessageEncodingBindingElement ();
			Assert.IsTrue (m.CanBuildChannelFactory<IRequestChannel> (CreateBindingContext ()), "#1");
			Assert.IsFalse (m.CanBuildChannelFactory<IReplyChannel> (CreateBindingContext ()), "#2");
			Assert.IsFalse (m.CanBuildChannelFactory<IRequestSessionChannel> (CreateBindingContext ()), "#3");
			Assert.IsFalse (m.CanBuildChannelFactory<IDuplexChannel> (CreateBindingContext ()), "#4");

			// actually they are from transport
			var h = new HttpTransportBindingElement ();
			Assert.IsTrue (h.CanBuildChannelFactory<IRequestChannel> (CreateBindingContext ()), "#5");
			Assert.IsFalse (h.CanBuildChannelFactory<IReplyChannel> (CreateBindingContext ()), "#6");
			Assert.IsFalse (h.CanBuildChannelFactory<IRequestSessionChannel> (CreateBindingContext ()), "#7");
			Assert.IsFalse (h.CanBuildChannelFactory<IDuplexChannel> (CreateBindingContext ()), "#8");

			// with TcpTransport
			Assert.IsFalse (m.CanBuildChannelFactory<IRequestChannel> (CreateBindingContext2 ()), "#9");
			Assert.IsFalse (m.CanBuildChannelFactory<IReplyChannel> (CreateBindingContext2 ()), "#10");
			Assert.IsFalse (m.CanBuildChannelFactory<IRequestSessionChannel> (CreateBindingContext2 ()), "#11");
			Assert.IsFalse (m.CanBuildChannelFactory<IDuplexChannel> (CreateBindingContext2 ()), "#12");

			// ... yes, actually they are from transport
			var t = new TcpTransportBindingElement ();
			Assert.IsFalse (t.CanBuildChannelFactory<IRequestChannel> (CreateBindingContext2 ()), "#13");
			Assert.IsFalse (t.CanBuildChannelFactory<IReplyChannel> (CreateBindingContext2 ()), "#14");
			Assert.IsFalse (t.CanBuildChannelFactory<IRequestSessionChannel> (CreateBindingContext2 ()), "#15");
			Assert.IsFalse (t.CanBuildChannelFactory<IDuplexChannel> (CreateBindingContext2 ()), "#16");
		}
コード例 #3
0
		public void CanBuildChannelFactory ()
		{
			HttpTransportBindingElement be =
				new HttpTransportBindingElement ();
			BindingContext ctx = new BindingContext (
				new CustomBinding (), empty_params);
			Assert.IsTrue (be.CanBuildChannelFactory<IRequestChannel> (ctx), "#1");
			Assert.IsFalse (be.CanBuildChannelFactory<IInputChannel> (ctx), "#2");
			Assert.IsFalse (be.CanBuildChannelFactory<IReplyChannel> (ctx), "#3");
			Assert.IsFalse (be.CanBuildChannelFactory<IOutputChannel> (ctx), "#4");
			// seems like it does not support session channels by itself ?
			Assert.IsFalse (be.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#5");
			Assert.IsFalse (be.CanBuildChannelFactory<IInputSessionChannel> (ctx), "#6");
			Assert.IsFalse (be.CanBuildChannelFactory<IReplySessionChannel> (ctx), "#7");
			Assert.IsFalse (be.CanBuildChannelFactory<IOutputSessionChannel> (ctx), "#8");

			// IServiceChannel is not supported
			Assert.IsFalse (be.CanBuildChannelListener<IServiceChannel> (ctx), "#9");
		}
コード例 #4
0
ファイル: clientsnippets.cs プロジェクト: zhimaqiao51/docs
        public static void Snippet18()
        {
            // <Snippet18>
            CustomBinding binding = new CustomBinding();
            HttpTransportBindingElement element    = new HttpTransportBindingElement();
            BindingParameterCollection  parameters = new BindingParameterCollection();
            BindingContext context = new BindingContext(binding, parameters);

            bool bFlag = element.CanBuildChannelFactory <IRequestChannel>(context);
            // </Snippet18>
        }
コード例 #5
0
        public void CanBuildChannelFactory()
        {
            HttpTransportBindingElement be =
                new HttpTransportBindingElement();
            BindingContext ctx = new BindingContext(
                new CustomBinding(), empty_params);

            Assert.IsTrue(be.CanBuildChannelFactory <IRequestChannel> (ctx), "#1");
            Assert.IsFalse(be.CanBuildChannelFactory <IInputChannel> (ctx), "#2");
            Assert.IsFalse(be.CanBuildChannelFactory <IReplyChannel> (ctx), "#3");
            Assert.IsFalse(be.CanBuildChannelFactory <IOutputChannel> (ctx), "#4");
            // seems like it does not support session channels by itself ?
            Assert.IsFalse(be.CanBuildChannelFactory <IRequestSessionChannel> (ctx), "#5");
            Assert.IsFalse(be.CanBuildChannelFactory <IInputSessionChannel> (ctx), "#6");
            Assert.IsFalse(be.CanBuildChannelFactory <IReplySessionChannel> (ctx), "#7");
            Assert.IsFalse(be.CanBuildChannelFactory <IOutputSessionChannel> (ctx), "#8");

            // IServiceChannel is not supported
            Assert.IsFalse(be.CanBuildChannelListener <IServiceChannel> (ctx), "#9");
        }