当前位置: 首页>>代码示例>>C#>>正文


C# WebChannelFactory.Open方法代码示例

本文整理汇总了C#中WebChannelFactory.Open方法的典型用法代码示例。如果您正苦于以下问题:C# WebChannelFactory.Open方法的具体用法?C# WebChannelFactory.Open怎么用?C# WebChannelFactory.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebChannelFactory的用法示例。


在下文中一共展示了WebChannelFactory.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddTodos

        /// <summary>
        /// Perform a ITodoApi AddTodos request.
        /// </summary>
        private void AddTodos(string name, DateTime expirationDate)
        {
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    channel.CreateTodo(new TodoType() { Name = name, ExpirationDate = expirationDate });
                }
            }
        }
开发者ID:ptselvinoth,项目名称:samples,代码行数:16,代码来源:MainActivity.cs

示例2: CreateComplexObject

        public void CreateComplexObject()
        {
            using (var client = new WebChannelFactory<IDataTest>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    channel.CreateComplexObject(GetComplexObject());
                    ValidateHttpStatusResponse(HttpStatusCode.OK);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:14,代码来源:DataUnitTests.cs

示例3: GetTodos

        public void GetTodos()
        {
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var todos = channel.GetTodos();
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(3, todos.Todo.Length);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:16,代码来源:UnitTests.cs

示例4: CreateInts

        public void CreateInts()
        {
            using (var server = new WebServiceHost(new DataService(), new Uri(_hostAddress)))
            using (var client = new WebChannelFactory<IDataTest>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                server.Open();
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    channel.CreateInts( new []{24,42});
                    ValidateHttpStatusResponse(HttpStatusCode.OK);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:16,代码来源:DataUnitTests.cs

示例5: GetVersion

        public void GetVersion()
        {
            using (var server = new WebServiceHost( new TodoService(), new Uri(_hostAddress)))
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                server.Open();
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var version = channel.GetVersion();
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(VersionType.v1_0, version);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:18,代码来源:UnitTests.cs

示例6: GetTodo

        public void GetTodo()
        {
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var todo = channel.GetTodo("1");
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(true, todo.idSpecified);
                    Assert.AreEqual(1, todo.id);
                    Assert.AreEqual(false, todo.IsDone);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:18,代码来源:UnitTests.cs

示例7: SetupTest

        public void SetupTest()
        {
			_hostAddress = string.Format("http://{0}:9222/RestService/TodoService", ipAddress);
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    //GetVersion will reset the state of the server to it's initial state as well.
                    var version = channel.GetVersion();
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(VersionType.v1_0, version);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:18,代码来源:UnitTests.cs

示例8: GetTodos

		/// <summary>
		/// Perform a ITodoApi GetTodos request.
		/// </summary>
		private TodosType GetTodos()
		{
			using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
			{
				client.Open();
				var channel = client.CreateChannel();

				using (new OperationContextScope((IContextChannel)channel))
				{
					return channel.GetTodos();
				}
			}
		}
开发者ID:MahendrenGanesan,项目名称:samples,代码行数:16,代码来源:MainActivity.cs

示例9: GetTodosFiltered

        public void GetTodosFiltered()
        {
            using (var server = new WebServiceHost(new TodoService(), new Uri(_hostAddress)))
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                server.Open();
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var todos = channel.GetTodosFiltered(true);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(1, todos.Todo.Length);
                }

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var todos = channel.GetTodosFiltered(false);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(2, todos.Todo.Length);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:26,代码来源:UnitTests.cs

示例10: UpdateTodo

        public void UpdateTodo()
        {
            using (var server = new WebServiceHost(new TodoService(), new Uri(_hostAddress)))
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                server.Open();
                client.Open();
                var channel = client.CreateChannel();

                var todo = new TodoType();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    try
                    {
                        todo = channel.GetTodo("1");
                    }
                    catch (CommunicationException ex)
                    {
                        ValidateHttpStatusResponse(ex, HttpStatusCode.BadRequest);
                    }
                }

                todo.IsDone = true;

                using (new OperationContextScope((IContextChannel) channel))
                {
                    channel.UpdateTodo(todo.id.ToString(), todo);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:32,代码来源:UnitTests.cs

示例11: CreateTodo

        public void CreateTodo()
        {
            using (var server = new WebServiceHost(new TodoService(), new Uri(_hostAddress)))
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                server.Open();
                client.Open();
                var channel = client.CreateChannel();

                var todo = new TodoType { id = 6, idSpecified = true, IsDone = false, Name = "New Item", Description = "This items should be fixed!", ExpirationDate = DateTime.Now.AddDays(2) };

                using (new OperationContextScope((IContextChannel)channel))
                {
                    try
                    {
                        var newId = channel.CreateTodo(todo);
                    }
                    catch (CommunicationException ex)
                    {
                        ValidateHttpStatusResponse(ex, HttpStatusCode.BadRequest);  
                    }
                }

                todo.idSpecified = false;

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var newId = channel.CreateTodo(todo);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(4, newId);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:34,代码来源:UnitTests.cs

示例12: UpdateComplexObjects

        public void UpdateComplexObjects()
        {
            using (var client = new WebChannelFactory<IDataTest>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var input = GetComplexObjects();
                    var result = channel.UpdateComplexObjects(input);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);
                    MyAssert.AreEqual(input, result);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:16,代码来源:DataUnitTests.cs

示例13: UpdateUShorts

        public void UpdateUShorts()
        {
            using (var client = new WebChannelFactory<IDataTest>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var input = new[] { (ushort)42, (ushort)24, (ushort)33 };
                    var result = channel.UpdateUShorts(input);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);
                    Assert.AreEqual(input.Length, result.Length);
                    Assert.AreEqual(input, result);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:17,代码来源:DataUnitTests.cs

示例14: UpdateTimeSpans

        public void UpdateTimeSpans()
        {
            using (var client = new WebChannelFactory<IDataTest>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var input = new[] { new TimeSpan(1,2,3,4,5), new TimeSpan(4,4,5,6), new TimeSpan(3,3,3,3) };
                    var result = channel.UpdateTimeSpans(input);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);
                    Assert.AreEqual(input.Length, result.Length);
                    Assert.AreEqual(input, result);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:17,代码来源:DataUnitTests.cs

示例15: UpdateDateTimes

        public void UpdateDateTimes()
        {
            using (var client = new WebChannelFactory<IDataTest>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var input = new [] {DateTime.Now, DateTime.Now.AddDays(4).AddHours(2)};
                    var result = channel.UpdateDateTimes(input);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);
                    Assert.AreEqual(input.Length, result.Length);
                    Assert.AreEqual(input, result);
                }
            }
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:17,代码来源:DataUnitTests.cs


注:本文中的WebChannelFactory.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。