/**
  * The execution of this behavior comes rather late.
  * Anyone that inspects the service description in the meantime,
  * such as for metadata generation, won't see the protection level that we want to use.
  *
  * One way of doing it is at when create HostFactory
  *
  * ServiceEndpoint endpoint = host.Description.Endpoints.Find(typeof(IService));
  * OperationDescription operation = endpoint.Contract.Operations.Find("Action");
  * MessageDescription message = operation.Messages.Find("http://tempuri.org/IService/ActionResponse");
  * MessageHeaderDescription header = message.Headers[new XmlQualifiedName("aheader", "http://tempuri.org/")];
  * header.ProtectionLevel = ProtectionLevel.Sign;
  *
  * **/
 public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
 {
     ChannelProtectionRequirements requirements = bindingParameters.Find<ChannelProtectionRequirements>();
     XmlQualifiedName qName = new XmlQualifiedName(header, ns);
     MessagePartSpecification part = new MessagePartSpecification(qName);
     requirements.OutgoingSignatureParts.AddParts(part, action);
 }
		public void AddBindingParameters(
			ServiceDescription serviceDescription,
			ServiceHostBase serviceHostBase,
			Collection<ServiceEndpoint> endpoints,
			BindingParameterCollection bindingParameters)
		{
		}
 /// <summary>
 /// 
 /// </summary>
 /// <param name="contractDescription"></param>
 /// <param name="endpoint"></param>
 /// <param name="bindingParameters"></param>
 public void AddBindingParameters(
     ContractDescription contractDescription,
     ServiceEndpoint endpoint,
     BindingParameterCollection bindingParameters)
 {
     // empty
 }
 public void AddBindingParameters(ServiceDescription serviceDescription,
                                  ServiceHostBase serviceHostBase,
                                  System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints,
                                  BindingParameterCollection bindingParameters)
 {
     //no-op
 }
 /// <summary>
 /// Provides the ability to pass custom data to binding elements to support the contract implementation.
 /// </summary>
 /// <param name="serviceDescription">
 /// The service description of the service.
 /// </param>
 /// <param name="serviceHostBase">
 /// The host of the service.
 /// </param>
 /// <param name="endpoints">
 /// The service endpoints.
 /// </param>
 /// <param name="bindingParameters">
 /// Custom objects to which binding elements have access.
 /// </param>
 public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
 {
     foreach (ChannelDispatcher chanDisp in serviceHostBase.ChannelDispatchers)
     {
         chanDisp.ErrorHandlers.Add(new ErrorHandler(this._messageFaultBuilder));
     }
 }
		void IContractBehavior.AddBindingParameters (
			ContractDescription description,
			ServiceEndpoint endpoint,
			BindingParameterCollection parameters)
		{
			throw new NotImplementedException ();
		}
 /// <summary>
 /// Adds the binding parameters.
 /// </summary>
 /// <param name="description">The description.</param>
 /// <param name="serviceHostBase">The service host base.</param>
 /// <param name="endpoints">The endpoints.</param>
 /// <param name="parameters">The parameters.</param>
 void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters)
 {
     if (throttlingBehavior != null)
     {
         ((IServiceBehavior)throttlingBehavior).AddBindingParameters(description, serviceHostBase, endpoints, parameters);
     }
 }
Пример #8
0
 public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
 {
     foreach (var operation in endpoint.Contract.Operations)
     {
         operation.Behaviors.Add(this);
     }
 }
Пример #9
0
		public void Use ()
		{
			var b = new ServiceDiscoveryBehavior ();
			b.AnnouncementEndpoints.Add (new UdpAnnouncementEndpoint ());
			IServiceBehavior sb = b;
			var host = new ServiceHost (new Uri ("http://localhost:37564"));

			var bc = new BindingParameterCollection ();
			sb.AddBindingParameters (host.Description, host, host.Description.Endpoints, bc);
			Assert.AreEqual (0, bc.Count, "#1");

			Assert.AreEqual (0, host.Extensions.Count, "#2-1");
			sb.Validate (host.Description, host);
			// ... should "validate" not "apply dispatch behavior" do "add host extension" job? I doubt that.
			Assert.AreEqual (1, host.Extensions.Count, "#2-2");
			var dse = host.Extensions.Find<DiscoveryServiceExtension> ();
			Assert.IsNotNull (dse, "#2-3");
			Assert.AreEqual (0, dse.PublishedEndpoints.Count, "#2-4");

			Assert.AreEqual (0, host.ChannelDispatchers.Count, "#3-1");
			sb.ApplyDispatchBehavior (host.Description, host);
			Assert.AreEqual (0, host.Description.Endpoints.Count, "#3-2");
			Assert.AreEqual (2, host.ChannelDispatchers.Count, "#3-3"); // for online and offline announcements
			Assert.AreEqual (0, dse.PublishedEndpoints.Count, "#3-4"); // discovery endpoints are not "published"
			int idx = 0;
			foreach (var cdisb in host.ChannelDispatchers) {
				var cdis = cdisb as ChannelDispatcher;
				string head = "#4." + idx + ".";
				Assert.IsNull (cdis, head + "dispatcher");
				if (cdisb.Listener != null)
					Assert.AreEqual ("urn:schemas-microsoft-org:ws:2008:07:discovery", cdisb.Listener.Uri.ToString (), head + "uri");
				// else ... WHOA! .NET "OnlineAnnouncementChannelDispatcher" type does not seem to provide the listener.
				idx++;
			}
		}
Пример #10
0
		void IServiceBehavior.AddBindingParameters (
			ServiceDescription description,
			ServiceHostBase serviceHostBase,
			Collection<ServiceEndpoint> endpoints,
			BindingParameterCollection parameters)
		{
		}
Пример #11
0
        public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
        {
            //see if ChunkingBindingParameter already exists
            ChunkingBindingParameter param =
                parameters.Find<ChunkingBindingParameter>();
            if (param == null)
            {
                param = new ChunkingBindingParameter();
                parameters.Add(param);
            }

            if ((appliesTo & ChunkingAppliesTo.InMessage)
                          == ChunkingAppliesTo.InMessage)
            {
                //add input message's action to ChunkingBindingParameter
                param.AddAction(description.Messages[0].Action);
            }
            if (!description.IsOneWay &&
                ((appliesTo & ChunkingAppliesTo.OutMessage)
                            == ChunkingAppliesTo.OutMessage))
            {
                //add output message's action to ChunkingBindingParameter
                param.AddAction(description.Messages[1].Action);
            }
        }
Пример #12
0
 public virtual void AddBindingParameters(ServiceDescription serviceDescription,
                                          ServiceHostBase serviceHostBase,
                                          Collection<ServiceEndpoint> endpoints,
                                          BindingParameterCollection bindingParameters)
 {
     throw new NotImplementedException();
 }
		void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
		{
			if (endpoint == null)
				throw new ArgumentNullException ("endpoint");
			if (bindingParameters == null)
				throw new ArgumentNullException ("bindingParameters");
		}
Пример #14
0
        public void AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters)
        {
            if (_innerOperationBehavior == null)
                return;

            (_innerOperationBehavior as IOperationBehavior).AddBindingParameters(operationDescription, bindingParameters);
        }
Пример #15
0
        internal static ClientRuntime BuildProxyBehavior(ServiceEndpoint serviceEndpoint, out BindingParameterCollection parameters)
        {
            parameters = new BindingParameterCollection();
            SecurityContractInformationEndpointBehavior.ClientInstance.AddBindingParameters(serviceEndpoint, parameters);

            AddBindingParameters(serviceEndpoint, parameters);

            ContractDescription contractDescription = serviceEndpoint.Contract;
            ClientRuntime clientRuntime = new ClientRuntime(contractDescription.Name, contractDescription.Namespace);
            clientRuntime.ContractClientType = contractDescription.ContractType;

            IdentityVerifier identityVerifier = serviceEndpoint.Binding.GetProperty<IdentityVerifier>(parameters);
            if (identityVerifier != null)
            {
                clientRuntime.IdentityVerifier = identityVerifier;
            }

            for (int i = 0; i < contractDescription.Operations.Count; i++)
            {
                OperationDescription operation = contractDescription.Operations[i];

                if (!operation.IsServerInitiated())
                {
                    DispatcherBuilder.BuildProxyOperation(operation, clientRuntime);
                }
                else
                {
                    DispatcherBuilder.BuildDispatchOperation(operation, clientRuntime.CallbackDispatchRuntime);
                }
            }

            DispatcherBuilder.ApplyClientBehavior(serviceEndpoint, clientRuntime);
            return clientRuntime;
        }
 public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints,
     BindingParameterCollection bindingParameters)
 {
     foreach (var operation in endpoints.SelectMany(val => val.Contract.Operations.Where(x => x.Behaviors.Find<ExceptionHandlerOperationBehavior>() == null)))
     {
         operation.Behaviors.Add(new ExceptionHandlerOperationBehavior());
     }
 }
 /// <summary>
 ///    Provides the ability to pass custom data to binding elements to support the contract implementation
 /// </summary>
 /// <param name="serviceDescription">The service description of the service.</param>
 /// <param name="serviceHostBase">The host of the service.</param>
 /// <param name="endpoints">The service endpoints.</param>
 /// <param name="bindingParameters">The service endpoints.</param>
 public void AddBindingParameters(
    ServiceDescription serviceDescription,
    ServiceHostBase serviceHostBase,
    Collection<ServiceEndpoint> endpoints,
    BindingParameterCollection bindingParameters)
 {
    //not apply for this sample
 }
 void IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters)
 {
     if (parameters == null)
     {
         throw FxTrace.Exception.ArgumentNull("parameters");
     }
     parameters.Add(this.virtualPathExtension);
 }
 void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters)
 {
     // Forward the call if we created a ServiceThrottlingBehavior.
     if (this.throttlingBehavior != null)
     {
         ((IServiceBehavior)this.throttlingBehavior).AddBindingParameters(description, serviceHostBase, endpoints, parameters);
     }
 }
 void IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters)
 {
     if (parameters == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("parameters"));
     }
     parameters.Add(this);
 }
Пример #21
0
 public void AddBindingParameters(
     ServiceDescription serviceDescription,
     ServiceHostBase serviceHostBase,
     Collection<ServiceEndpoint> endpoints,
     BindingParameterCollection bindingParameters)
 {
     AutoMapBootstrap.InitMap();
 }
Пример #22
0
		void IServiceBehavior.AddBindingParameters (
			ServiceDescription description,
			ServiceHostBase serviceHostBase,
			Collection<ServiceEndpoint> endpoints,
			BindingParameterCollection parameters)
		{
			throw new NotImplementedException ();
		}
 void IOperationBehavior.AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
 {
     if (parameters == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
     }
     this.ApplyBehavior(description, parameters);
 }
Пример #24
0
 /// <summary>
 /// Registers custom contract binding parameters
 /// </summary>
 /// <param name="desc">
 /// The WCF contract description
 /// </param>
 /// <param name="endpoint">
 /// The WCF contract endpoint
 /// </param>
 /// <param name="binding">
 /// The WCF endpoint binding parameters
 /// </param>
 public virtual void AddBindingParameters(
     ContractDescription desc,
     ServiceEndpoint endpoint,
     BindingParameterCollection binding)
 {
     foreach (OperationDescription op in desc.Operations)
     AddBindingParameters(op, binding);
 }
Пример #25
0
		public void AddBiningParameters ()
		{
			var se = CreateEndpoint ();
			var b = new WebHttpBehavior ();
			var pl = new BindingParameterCollection ();
			b.AddBindingParameters (se, pl);
			Assert.AreEqual (0, pl.Count, "#1");
		}
 internal ExportedPolicyConversionContext(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
     : base(endpoint)
 {
     this.bindingElements = endpoint.Binding.CreateBindingElements();
     this.bindingAssertions = new PolicyAssertionCollection();
     this.operationBindingAssertions = new Dictionary<OperationDescription, PolicyAssertionCollection>();
     this.messageBindingAssertions = new Dictionary<MessageDescription, PolicyAssertionCollection>();
     this.faultBindingAssertions = new Dictionary<FaultDescription, PolicyAssertionCollection>();
     this.bindingParameters = bindingParameters;
 }
		public void AddBindingParameters ()
		{
			IEndpointBehavior eb = new CallbackBehaviorAttribute ();
			var cd = ContractDescription.GetContract (typeof (IFoo));
			var se = new ServiceEndpoint (cd);
			Assert.AreEqual (0, se.Behaviors.Count, "#1");
			var pc = new BindingParameterCollection ();
			eb.AddBindingParameters (se, pc);
			Assert.AreEqual (0, pc.Count, "#2");
			Assert.AreEqual (0, se.Behaviors.Count, "#3");
		}
 private static Dictionary<DirectionalAction, TransactionFlowOption> EnsureDictionary(BindingParameterCollection parameters)
 {
     Dictionary<DirectionalAction, TransactionFlowOption> dictionary = parameters.Find<Dictionary<DirectionalAction, TransactionFlowOption>>();
     if (dictionary == null)
     {
         dictionary = new Dictionary<DirectionalAction, TransactionFlowOption> {
             dictionary
         };
     }
     return dictionary;
 }
 /// <summary>
 /// Provides the ability to pass custom data to binding elements to support the contract implementation.
 /// </summary>
 /// <param name="serviceDescription">The service description of the service.</param><param name="serviceHostBase">The host of the service.</param><param name="endpoints">The service endpoints.</param><param name="bindingParameters">Custom objects to which binding elements have access.</param>
 void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
 {
     endpoints
         .SelectMany(x => x.Contract.Operations)
         .Where(x => x.DeclaringContract.ContractType != typeof(IMetadataExchange))
         .ToList()
         .ForEach(x =>
         {
             if (!x.Behaviors.Any(b => b.GetType() == GetType()))
                 x.Behaviors.Add(this);
         });
 }
        public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
        {
            //ContentNegotiationBindingElement contentNegotiation = new ContentNegotiationBindingElement();
            //contentNegotiation.CompressionMode = SmartCompressionMode.Optimistic;

            //binding = contentNegotiation.PlugIn(binding);

            //foreach (var endpoint in endpoints)
            //{
            //    endpoint.Binding = contentNegotiation.PlugIn(endpoint.Binding);
            //}
        }
Пример #31
0
 void IOperationBehavior.AddBindingParameters(OperationDescription operationDescription, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
     // do nothing
 }
Пример #32
0
        public virtual bool CanBuildChannelFactory <TChannel>(BindingParameterCollection parameters)
        {
            BindingContext context = new BindingContext(new CustomBinding(this), parameters);

            return(context.CanBuildInnerChannelFactory <TChannel>());
        }
Пример #33
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="serviceDescription"></param>
 /// <param name="serviceHostBase"></param>
 /// <param name="endpoints"></param>
 /// <param name="bindingParameters"></param>
 public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
 }
Пример #34
0
        public virtual bool CanBuildChannelListener <TChannel>(BindingParameterCollection parameters) where TChannel : class, IChannel
        {
            BindingContext context = new BindingContext(new CustomBinding(this), parameters);

            return(context.CanBuildInnerChannelListener <TChannel>());
        }
Пример #35
0
        public T GetProperty <T>(BindingParameterCollection parameters) where T : class
        {
            BindingContext context = new BindingContext(new CustomBinding(this), parameters);

            return(context.GetInnerProperty <T>());
        }
Пример #36
0
 private void ValidateSecurityCapabilities(ISecurityCapabilities runtimeSecurityCapabilities, BindingParameterCollection parameters)
 {
     if (!SecurityCapabilities.IsEqual(this.GetProperty <ISecurityCapabilities>(parameters), runtimeSecurityCapabilities))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SecurityCapabilitiesMismatched", new object[] { this })));
     }
 }
Пример #37
0
        public virtual IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingParameterCollection parameters) where TChannel : class, IChannel
        {
            UriBuilder builder = new UriBuilder(this.Scheme, DnsCache.MachineName);

            return(this.BuildChannelListener <TChannel>(builder.Uri, string.Empty, ListenUriMode.Unique, parameters));
        }
Пример #38
0
 public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
     // No implementation necessary
 }
Пример #39
0
 public void AddBindingParameters(OperationDescription operationDescription, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
     //throw new NotImplementedException();
 }
Пример #40
0
 void IContractBehavior.AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
 }
Пример #41
0
 void IEndpointBehavior.AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
 }
Пример #42
0
        private void ValidateSecurityCapabilities(ISecurityCapabilities runtimeSecurityCapabilities, BindingParameterCollection parameters)
        {
            ISecurityCapabilities bindingSecurityCapabilities = this.GetProperty <ISecurityCapabilities>(parameters);

            if (!SecurityCapabilities.IsEqual(bindingSecurityCapabilities, runtimeSecurityCapabilities))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR.Format(SR.SecurityCapabilitiesMismatched, this)));
            }
        }
Пример #43
0
        public virtual IChannelListener <TChannel> BuildChannelListener <TChannel>(Uri listenUriBaseAddress, string listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters) where TChannel : class, IChannel
        {
            this.EnsureInvariants();
            BindingContext context = new BindingContext(new CustomBinding(this), parameters, listenUriBaseAddress, listenUriRelativeAddress, listenUriMode);
            IChannelListener <TChannel> listener = context.BuildInnerChannelListener <TChannel>();

            context.ValidateBindingElementsConsumed();
            this.ValidateSecurityCapabilities(listener.GetProperty <ISecurityCapabilities>(), parameters);
            return(listener);
        }
Пример #44
0
 public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
     //throw new NotImplementedException();
 }
Пример #45
0
 public virtual IChannelListener <TChannel> BuildChannelListener <TChannel>(Uri listenUriBaseAddress, string listenUriRelativeAddress, BindingParameterCollection parameters) where TChannel : class, IChannel
 {
     return(this.BuildChannelListener <TChannel>(listenUriBaseAddress, listenUriRelativeAddress, ListenUriMode.Explicit, parameters));
 }
 public void AddBindingParameters(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection <ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
     //提供方法执行的上下文环境
     //OperationContext context = OperationContext.Current;
     //获取传进的消息属性
     //MessageProperties properties = context.IncomingMessageProperties;
     ///获取消息发送的远程终结点IP和端口
     //RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
     //throw new NotImplementedException();
 }
Пример #47
0
 public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
     return;
 }
Пример #48
0
 public ChannelBuilder(ChannelBuilder channelBuilder)
 {
     _binding           = new CustomBinding(channelBuilder.Binding);
     _bindingParameters = channelBuilder.BindingParameters;
 }
Пример #49
0
 void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection <ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
 {
 }
Пример #50
0
 private BindingContext(CustomBinding binding,
                        BindingElementCollection remainingBindingElements,
                        BindingParameterCollection parameters)
 {
     Initialize(binding, remainingBindingElements, parameters);
 }