我有双向连接的两端Stream,我想做一些沟通.流后面的底层实现并不重要,我想在这个Stream层面上工作......
我不想为流实现我自己的通信协议,而是希望使用所有现有的WCF优势来使用双向(请求/响应+回调)WCF通信通道来包装现有流.
我的问题是,我怎么能这样做......?
更新:
我走了实现自定义传输的道路.我有这个工作,但我仍然不是很满意它...
我已经实现了一个IDuplexSessionChannel包装流,以及适当的IChannelFactory和IChannelListener用于创建通道工厂的绑定元素.现在,我只是通过连接的流,并最终在创建它时将它们传递到传输通道.
所以,我可以通过流创建客户端代理来访问服务,如下所示:
var callback = new MyCallback();
var instanceContext = new InstanceContext( callback );
var pipeFactory = new DuplexChannelFactory<IMyService>( instanceContext, new StreamBinding(clientStream),
new EndpointAddress("stream://localhost/MyService"));
var serviceProxy = pipeFactory.CreateChannel();
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,似乎WCF设置为使用a ServiceHost创建通道的服务器端,通过IChannelListener.在我的情况下,我已经有一个连接流,我将无法再侦听任何传入的连接.我可以解决这个问题,但我宁愿不使用a ServiceHost来创建频道的服务器端,因为我最终得到了很多模糊的样板和黑客来使它工作.
问题
因此,我正在寻找更好的方法来获取IDuplexSessionChannels,并将它们包装到服务器端和客户端的Channel代理中.
或者可能是不需要的不同ServiceHost实现IChannelListener.
真的,这里的问题是我不想要单个服务器,多个客户端安排,我的WCF服务和客户端之间有1-1关系.有没有正确的方法来实例化其中一个?
换句话说,我想在不使用ServiceHost的情况下创建服务器端服务实例.
在此阶段,任何建议都将受到赞赏.
使用以下代码,我希望每次更新viewModel.item observable时都会执行更新函数.我可以看到我的init和更新函数按照预期在页面加载时触发,但是当我单击我的按钮更新observable的值时则不会.
标记:
<button id='addButton'>item++</button>
<br/>
<span>viewModel.item = </span>
<span data-bind='text: $data.item(), bind: viewModel.item'></span>
Run Code Online (Sandbox Code Playgroud)
脚本:
$(document).ready(function() {
$('#addButton').click(function() {
viewModel.item(viewModel.item() + 1);
});
var viewModel = {
item: ko.observable(1)
};
ko.bindingHandlers.bind = {
init: function(element, valueAccessor) {
alert('init');
},
update: function(element, valueAccessor) {
alert('update');
}
};
ko.applyBindings(viewModel);
});
Run Code Online (Sandbox Code Playgroud)
我浏览了一些类似的问题,但没有找到类似的例子.我在这里创建了一个JSFiddle .
我有一个带有自定义绑定的WCF服务,它在http或https上工作正常.但我完全不知道如何在http和https上提供它?
也可以这样做吗?
这是我在web.config中的配置.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyWCFService">
<endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
contract="MyWCFService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在尝试调用ko.renderTemplate()自定义绑定.
但是我找不到任何有关它的用法的文档,特别是渲染模式参数.
上面的站点有一个部分"您可以直接从自定义绑定中呈现模板",其中简要描述了参数renderTemplate().
渲染模式参数的其他可用选项有哪些?
另外,有没有renderTemplate()我可能错过的文档和渲染引擎选项?
如何配置自定义绑定和MTOM编码?我有一个自定义绑定,如下所示,
<customBinding>
<binding name="stsBinding">
<security authenticationMode="UserNameOverTransport"
requireDerivedKeys="false"
keyEntropyMode="ServerEntropy"
requireSecurityContextCancellation="false"
requireSignatureConfirmation="false">
</security>
<httpsTransport />
</binding>
</customBinding>
Run Code Online (Sandbox Code Playgroud)
我的MTOM绑定如下,
<basicHttpBinding>
<binding name="HttpStreaming"
maxReceivedMessageSize="2147483647"
messageEncoding="Mtom"
transferMode="Streamed"/>
</basicHttpBinding>
Run Code Online (Sandbox Code Playgroud)
我该如何结合这个?
我想在KnockoutJS中创建一个'条件点击'绑定.基本上这是一个标准的点击绑定,就像你在Knockout中使用它一样,但是需要满足一个条件才能执行附加的函数.就我而言,最好的选择是创建一个自定义绑定处理程序,然后在允许的情况下调用标准单击绑定.
ko.bindingHandlers.safeClick = {
'init': function(element, valueAccessor, allBindingsAccessor, context) {
$(element).click(function() {
if(mycondition == true) {
// call the standard click binding here -> this is the part I don't know
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
我想用这个自定义绑定替换所有标准点击绑定.因此,以正确的方式调用click绑定非常重要,因此HTML中提供的所有参数都会传递给该函数.例如:
<a href="#" data-bind="click: basevm.gotopage.bind($data, '#homepage')">Home</a>
<a href="#" data-bind="click: itemvm.activateItem">Activate</a>
Run Code Online (Sandbox Code Playgroud)
这些需要被替换
<a href="#" data-bind="safeClick: basevm.gotopage.bind($data, '#homepage')">Home</a>
<a href="#" data-bind="safeClick: itemvm.activateItem">Activate</a>
Run Code Online (Sandbox Code Playgroud)
如果你能帮我解决自定义绑定中缺少的部分,我将非常感激.
我有一个从文件字段扩展的组件,我添加了一个自定义属性'serverPath',我也定义了getter和setter.
代码:
Ext.define('MyApp.ux.Field.File',{
extend:'Ext.form.field.File',
xtype:'myfilefield',
serverPath:'',
getServerPath:function(){
return this.serverPath;
},
setServerPath:function(serverPath){
this.serverPath = serverPath;
}
});
Ext.create('MyApp.ux.Field.File',{
bind:{
serverPath:'{serverPath}'
},
viewModel:{
type:'myViewModel'
}
});
Run Code Online (Sandbox Code Playgroud)
我不会粘贴myViewModel的定义.很简单.
结果证明绑定没有生效.
有人可以帮忙吗?
我在这里面临一个问题.我正在做一个客户端/服务器项目,这是WCF Web服务调用来获取数据.由于传输的大量数据,我必须以编程方式(而不是通过配置文件)将我的绑定更改为自定义绑定.
我正在创建一个新的用户定义绑定,也就是自定义绑定.该类的例子是:
public class MyCustomBinding : CustomBinding
Run Code Online (Sandbox Code Playgroud)
并覆盖函数BindingElementCollection:
public override BindingElementCollection CreateBindingElements()
{
WSHttpBinding wSHttpBinding = new WSHttpBinding("RMSKeberosBinding"); //this is to load the configuration from app.config. because i want to copy the setting of wsHttpConfig to my custom binding.
BindingElementCollection wSHttpBindingElementCollection = wSHttpBinding.CreateBindingElements();
TransactionFlowBindingElement transactionFlowBindingElement = wSHttpBindingElementCollection.Remove<TransactionFlowBindingElement>();
SymmetricSecurityBindingElement securityElement = wSHttpBindingElementCollection.Remove<SymmetricSecurityBindingElement>();
MessageEncodingBindingElement textElement = wSHttpBindingElementCollection.Remove<MessageEncodingBindingElement>();
HttpTransportBindingElement transportElement = wSHttpBindingElementCollection.Remove<HttpTransportBindingElement>();
GZipMessageEncodingBindingElement gzipElement = new GZipMessageEncodingBindingElement(); // this is from microsoft sample. i want to add gzip as a compress to …Run Code Online (Sandbox Code Playgroud) 我正在使用以下jsfiddle的基本形式http://jsfiddle.net/rniemeyer/8D5aj/
ko.bindingHandlers.hidden = {
update: function(element, valueAccessor) {
ko.bindingHandlers.visible.update(element, function() { return !ko.utils.unwrapObservable(valueAccessor()); });
}
};
ko.bindingHandlers.clickToEdit = {
init: function(element, valueAccessor) {
var observable = valueAccessor(),
link = document.createElement("a"),
input = document.createElement("input");
element.appendChild(link);
element.appendChild(input);
observable.editing = ko.observable(false);
ko.applyBindingsToNode(link, {
text: observable,
hidden: observable.editing,
click: observable.editing.bind(null, true)
});
ko.applyBindingsToNode(input, {
value: observable,
visible: observable.editing,
hasfocus: observable.editing,
event: {
keyup: function(data, event) {
//if user hits enter, set editing to false, which makes field lose focus
if (event.keyCode === 13) …Run Code Online (Sandbox Code Playgroud) 我一直在寻找一个样本来为淘汰赛创建一个自定义倒数计时器绑定!
我发现了这个问题jQuery倒数计时器并适应Knockout Js.
custom-binding ×10
knockout.js ×5
wcf ×4
javascript ×2
binding ×1
c# ×1
connection ×1
extjs5 ×1
gzip ×1
http ×1
https ×1
jquery ×1
mtom ×1
templates ×1
viewmodel ×1
wcf-binding ×1