2012-04-24 12 views
1

IEndpointBehavior実装を使用してConnectionOrientedTransportBindingElement(たとえばConnectionBufferSize)のプロパティの値を変更することはできますか?バインディングを拡張するためのIEndpointBehaviorの実装

var host = new ServiceHost(typoef(ISomeService), new Uri(service)); 
var endpoint = host.AddServiceEndpoint(typeof (ISomeService), new NetTcpBinding(), string.Empty); 
endpoint.Behaviors.Add(new MyCustomEndpointBehavior()); 
// ... 

class MyCustomEndpointBehavior : IEndpointBehavior { 
    // .... 
    public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { 
     // what to do here? 
    } 
} 

答えて

1

ビヘイビアを使用してバインディング内部を変更することはできません。あなたはConnectionBufferSize here

について

<customBinding> 
    <binding name="MyCustomBinding"> 
    <binaryMessageEncoding /> 
    <tcpTransport connectionBufferSize="256192" maxOutputDelay="00:00:30" transferMode="Streamed"> 
    </tcpTransport> 
    </binding> 
</customBinding> 

またはコード

var host = new ServiceHost(typeof(Service1), new Uri("net.tcp://someservice")); 

      //binding stack - order matters! 
      var myCustomNetTcpBindingStack = new List<BindingElement>(); 

      //session - if reliable 
      var session = new ReliableSessionBindingElement(); 
      myCustomNetTcpBindingStack.Add(session); 

      //transaction flow 
      myCustomNetTcpBindingStack.Add(new TransactionFlowBindingElement(TransactionProtocol.OleTransactions)); 


      //encoding 
      myCustomNetTcpBindingStack.Add(new BinaryMessageEncodingBindingElement()); 

      //security 
      //var security = SecurityBindingElement.CreateUserNameOverTransportBindingElement(); 
      //myCustomNetTcpBindingStack.Add(security); 

      //transport 
      var transport = new TcpTransportBindingElement(); 
      transport.ConnectionBufferSize = 64 * 1024; 
      myCustomNetTcpBindingStack.Add(transport); 


      var myCustomNetTcpBinding = new CustomBinding(myCustomNetTcpBindingStack); 

      host.AddServiceEndpoint(typeof(IService1), myCustomNetTcpBinding, string.Empty); 

      host.Open(); 

良いポスト設定を介して、またはコードを介して、カスタムバインディング構築する必要があります

関連する問題