Bingding模型
public abstract class Binding : IDefaultCommunicationTimeouts
public virtual IChannelListener<TChannel> BuildChannelListener<TChannel>(Uri listenUriBaseAddress, string listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters) where TChannel : class, IChannel
{
this.EnsureInvariants();
BindingContext bindingContext = new BindingContext(new CustomBinding(this), parameters, listenUriBaseAddress, listenUriRelativeAddress, listenUriMode);
IChannelListener<TChannel> channelListener = bindingContext.BuildInnerChannelListener<TChannel>();
bindingContext.ValidateBindingElementsConsumed();
this.ValidateSecurityCapabilities(channelListener.GetProperty<ISecurityCapabilities>(), parameters);
return channelListener;
}
通过当前绑定创建CustomBinding, BindingContext bindingContext = new BindingContext()创建绑定上下文,bindingContext.BuildInnerChannelListener<TChannel>();创建信道监听器管道,返回最上层的信道监听器
public class BindingContext
{
private CustomBinding binding;
private BindingParameterCollection bindingParameters;
private Uri listenUriBaseAddress;
private ListenUriMode listenUriMode;
private string listenUriRelativeAddress;
private BindingElementCollection remainingBindingElements;
[__DynamicallyInvokable]
public CustomBinding Binding
{
[__DynamicallyInvokable, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get
{
return this.binding;
}
}
[__DynamicallyInvokable]
public BindingParameterCollection BindingParameters
{
[__DynamicallyInvokable, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get
{
return this.bindingParameters;
}
}
public Uri ListenUriBaseAddress
{
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get
{
return this.listenUriBaseAddress;
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
set
{
this.listenUriBaseAddress = value;
}
}
public ListenUriMode ListenUriMode
{
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get
{
return this.listenUriMode;
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
set
{
this.listenUriMode = value;
}
}
public string ListenUriRelativeAddress
{
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get
{
return this.listenUriRelativeAddress;
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
set
{
this.listenUriRelativeAddress = value;
}
}
[__DynamicallyInvokable]
public BindingElementCollection RemainingBindingElements
{
[__DynamicallyInvokable, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get
{
return this.remainingBindingElements;
}
}
[__DynamicallyInvokable]
public BindingContext(CustomBinding binding, BindingParameterCollection parameters) : this(binding, parameters, null, string.Empty, ListenUriMode.Explicit)
{
}
public BindingContext(CustomBinding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, string listenUriRelativeAddress, ListenUriMode listenUriMode)
{
if (binding == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("binding");
}
if (listenUriRelativeAddress == null)
{
listenUriRelativeAddress = string.Empty;
}
if (!ListenUriModeHelper.IsDefined(listenUriMode))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("listenUriMode"));
}
this.Initialize(binding, binding.Elements, parameters, listenUriBaseAddress, listenUriRelativeAddress, listenUriMode);
}
[__DynamicallyInvokable]
public IChannelFactory<TChannel> BuildInnerChannelFactory<TChannel>()
{
return this.RemoveNextElement().BuildChannelFactory<TChannel>(this);
}
public IChannelListener<TChannel> BuildInnerChannelListener<TChannel>() where TChannel : class, IChannel
{
return this.RemoveNextElement().BuildChannelListener<TChannel>(this);
}
[__DynamicallyInvokable]
public bool CanBuildInnerChannelFactory<TChannel>()
{
BindingContext bindingContext = this.Clone();
return bindingContext.RemoveNextElement().CanBuildChannelFactory<TChannel>(bindingContext);
}
public bool CanBuildInnerChannelListener<TChannel>() where TChannel : class, IChannel
{
BindingContext bindingContext = this.Clone();
return bindingContext.RemoveNextElement().CanBuildChannelListener<TChannel>(bindingContext);
}
[__DynamicallyInvokable]
public T GetInnerProperty<T>() where T : class
{
if (this.remainingBindingElements.Count == )
{
return default(T);
}
BindingContext bindingContext = this.Clone();
return bindingContext.RemoveNextElement().GetProperty<T>(bindingContext);
}
[__DynamicallyInvokable]
public BindingContext Clone()
{
return new BindingContext(this.binding, this.remainingBindingElements, this.bindingParameters, this.listenUriBaseAddress, this.listenUriRelativeAddress, this.listenUriMode);
}
private BindingElement RemoveNextElement()
{
BindingElement bindingElement = this.remainingBindingElements.Remove<BindingElement>();
if (bindingElement != null)
{
return bindingElement;
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString("NoChannelBuilderAvailable", new object[]
{
this.binding.Name,
this.binding.Namespace
})));
}
internal void ValidateBindingElementsConsumed()
{
if (this.RemainingBindingElements.Count != )
{
StringBuilder stringBuilder = new StringBuilder();
foreach (BindingElement current in this.RemainingBindingElements)
{
if (stringBuilder.Length > )
{
stringBuilder.Append(CultureInfo.CurrentCulture.TextInfo.ListSeparator);
stringBuilder.Append(" ");
}
string text = current.GetType().ToString();
stringBuilder.Append(text.Substring(text.LastIndexOf('.') + ));
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString("NotAllBindingElementsBuilt", new object[]
{
stringBuilder.ToString()
})));
}
}
private BindingContext(CustomBinding binding, BindingElementCollection remainingBindingElements, BindingParameterCollection parameters, Uri listenUriBaseAddress, string listenUriRelativeAddress, ListenUriMode listenUriMode)
{
this.Initialize(binding, remainingBindingElements, parameters, listenUriBaseAddress, listenUriRelativeAddress, listenUriMode);
}
private void Initialize(CustomBinding binding, BindingElementCollection remainingBindingElements, BindingParameterCollection parameters, Uri listenUriBaseAddress, string listenUriRelativeAddress, ListenUriMode listenUriMode)
{
this.binding = binding;
this.remainingBindingElements = new BindingElementCollection(remainingBindingElements);
this.bindingParameters = new BindingParameterCollection(parameters);
this.listenUriBaseAddress = listenUriBaseAddress;
this.listenUriRelativeAddress = listenUriRelativeAddress;
this.listenUriMode = listenUriMode;
}
}
Bingding模型的更多相关文章
- 1. AMQP 0-9-1模型简介(官网直译)
关于这篇指导文档 本文提供了AMQP 0-9-1协议的一个概述,它是RabbitMQ所支持的协议之一. AMQP 0-9-1是什么 AMQP 0-9-1(Advanced Message Queuin ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库
在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...
- ASP.NET Core MVC/WebAPi 模型绑定探索
前言 相信一直关注我的园友都知道,我写的博文都没有特别枯燥理论性的东西,主要是当每开启一门新的技术之旅时,刚开始就直接去看底层实现原理,第一会感觉索然无味,第二也不明白到底为何要这样做,所以只有当你用 ...
- ASP.NET路由模型解析
大家好,我又来吹牛逼了 ~-_-~ 转载请注明出处:来自吹牛逼之<ASP.NET路由模型解析> 背景:很多人知道Asp.Net中路由怎么用的,却不知道路由模型内部的运行原理,今天我就给大家 ...
- 高性能IO模型浅析
高性能IO模型浅析 服务器端编程经常需要构造高性能的IO模型,常见的IO模型有四种: (1)同步阻塞IO(Blocking IO):即传统的IO模型. (2)同步非阻塞IO(Non-blocking ...
- 探索ASP.NET MVC5系列之~~~4.模型篇---包含模型常用特性和过度提交防御
其实任何资料里面的任何知识点都无所谓,都是不重要的,重要的是学习方法,自行摸索的过程(不妥之处欢迎指正) 汇总:http://www.cnblogs.com/dunitian/p/4822808.ht ...
- 隐马尔科夫模型python实现简单拼音输入法
在网上看到一篇关于隐马尔科夫模型的介绍,觉得简直不能再神奇,又在网上找到大神的一篇关于如何用隐马尔可夫模型实现中文拼音输入的博客,无奈大神没给可以运行的代码,只能纯手动网上找到了结巴分词的词库,根据此 ...
- webapi - 模型验证
本次要和大家分享的是webapi的模型验证,讲解的内容可能不单单是做验证,但都是围绕模型来说明的:首先来吐槽下,今天下午老板为自己买了套新办公家具,看起来挺好说明老板有钱,不好的是我们干技术的又成了搬 ...
- 谈谈一些有趣的CSS题目(二)-- 从条纹边框的实现谈盒子模型
开本系列,讨论一些有趣的 CSS 题目,抛开实用性而言,一些题目为了拓宽一下解决问题的思路,此外,涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题中有你感觉 ...
随机推荐
- golang 关于golang.org/x包问题
关于golang.org/x包问题 由于谷歌被墙,跟谷歌相关的模块无法通过go get来下载,解决方法: git clone https://github.com/golang/net.git $GO ...
- 本机连接调试Erlang结点与rebar3编译
今天需要实时查看目标结点上的相关信息,于是查阅了关于远程Shell使用的资料,最终采用JCL的方式与本机上的erlang结点交互.在使用erl shell时需要指定目标结点的cookie以及当前结点名 ...
- C++之匿名对象解析
我们知道在C++的创建对象是一个费时,费空间的一个操作.有些固然是必不可少,但还有一些对象却在我们不知道的情况下被创建了.通常以下三种情况会产生临时对象: 1,以值的方式给函数传参: 2,类型 ...
- POI实现DOC/DOCX转HTML
1.使用HWPF处理DOC public class DocToHtml { private static final String encoding = "UTF-8"; pub ...
- ubuntu 使用命令行清空回收站
sudo rm -rf ~/.local/share/Trash/*
- asio socket设置 server地址与端口的两种方式
1. 用解释器的方法, 常用来解析域名, 如 // query("www.163.com","80"), 也可以 query("www.163.co ...
- springboot开启远程调试
远程调试maven设置 The run goal forks a process for the boot application. It is possible to specify jvm arg ...
- React.js:template
ylbtech-React.js: 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 作者:ylbtech出处:http://ylbtec ...
- spring中的依赖注入
Ioc的作用: 降低程序间的耦合(依赖关系) 依赖关系的管理: 以后都交给Spring来维护 在当前类需要用到其他类的对象,由Spring为我们提供, 我们只需要在配置文件中说明 依赖关系的维护,就称 ...
- meta标签常用属性
Keywords(关键词) 说明:告诉搜索引擎你网页的关键字(keywords)使用方法:<meta name="keywords" content="标签,属性, ...