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


C# Description.ContractDescription类代码示例

本文整理汇总了C#中System.ServiceModel.Description.ContractDescription的典型用法代码示例。如果您正苦于以下问题:C# ContractDescription类的具体用法?C# ContractDescription怎么用?C# ContractDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AddBindingParameters

 /**
  * 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);
 }
开发者ID:cleancodenz,项目名称:ServiceBus,代码行数:21,代码来源:SignMessageHeaderBehavior.cs

示例2: ConfigureRouterViaCode

        private static void ConfigureRouterViaCode(ServiceHost serviceHost)
        {
            //This code sets up the Routing Sample via code.  Rename or delete the App.config file
            //and comment out this method call to run a config-based Routing Service

            //set up some communication defaults
            string deadAddress = "net.tcp://localhost:9090/servicemodelsamples/fakeDestination";
            string realAddress = "net.tcp://localhost:8080/servicemodelsamples/service";
            string routerAddress = "http://localhost/routingservice/router";

            //note that the calculator client will be communicating to the Routing Service via basic
            //HTTP, while the Routing Service is using Net.TCP to communicate to the calculator service.
            //This demonstrates the Routing Service's capability of bridging between different message
            //transports, formats, bindings, etc.  This automatic message conversion is governed by
            //whether or not SoapProcessing (enabled by default) is enabled on the Routing Configuration. 
            Binding routerBinding = new BasicHttpBinding();
            Binding clientBinding = new NetTcpBinding();
            
            //add the endpoint the router will use to recieve messages
            serviceHost.AddServiceEndpoint(typeof(IRequestReplyRouter), routerBinding, routerAddress);
            
            //create the client endpoint the router will route messages to
            //note that the contract description on the client endpoints is actually unused, so
            //this could be any string.  The contract specified here goes unused
            //because the Routing Service replaces this contract with one of the Router
            //contracts at runtime, depending on the contract that a message was received with.
            ContractDescription contract = new ContractDescription("IRequestReplyRouter");
            ServiceEndpoint fakeDestination = new ServiceEndpoint(contract, clientBinding, new EndpointAddress(deadAddress));
            ServiceEndpoint realDestination = new ServiceEndpoint(contract, clientBinding, new EndpointAddress(realAddress));
            
            //create the endpoint list that contains the service endpoints we want to route to
            List<ServiceEndpoint> backupList = new List<ServiceEndpoint>();

            //add the endpoints in the order that the Routing Service should contact them
            //first add the endpoint that we know will be down
            //clearly, normally you wouldn't know that this endpoint was down by default
            backupList.Add(fakeDestination);

            //then add the endpoint that will work
            //the Routing Service will attempt to send to this endpoint only if it 
            //encounters a TimeOutException or CommunicationException when sending
            //to the previous endpoint in the list.
            backupList.Add(realDestination);
            
            //create the default RoutingConfiguration option            
            RoutingConfiguration rc = new RoutingConfiguration();
            
            //add a MatchAll filter to the Routing Configuration's filter table
            //map it to the list of endpoints defined above
            //when a message matches this filter, it will be sent to the endpoints in the list in order
            //if an endpoint is down or doesn't respond (which the first client won't
            //since no service exists at that endpoint), the Routing Service will automatically move the message
            //to the next endpoint in the list and try again.
            rc.FilterTable.Add(new MatchAllMessageFilter(), backupList);
            
            //create the Routing Behavior with the Routing Configuration and add it to the 
            //serviceHost's Description.
            serviceHost.Description.Behaviors.Add(new RoutingBehavior(rc));
                        
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:60,代码来源:routing.cs

示例3: ApplyClientBehavior

 /// <summary>
 /// 
 /// </summary>
 /// <param name="contractDescription"></param>
 /// <param name="endpoint"></param>
 /// <param name="clientRuntime"></param>
 public void ApplyClientBehavior(
     ContractDescription contractDescription,
     ServiceEndpoint endpoint,
     ClientRuntime clientRuntime)
 {
     // empty
 }
开发者ID:enzo3m,项目名称:DistributedComputing-WCF,代码行数:13,代码来源:ProcessingInstanceProvider.cs

示例4: ApplyDispatchBehavior

        public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
        {
            var behavior =
                dispatchRuntime.ChannelDispatcher.Host.Description.FindBehavior
                        <WebAuthenticationConfigurationBehavior,
                         WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior);

            if (behavior == null)
                behavior = contractDescription.FindBehavior
                        <WebAuthenticationConfigurationBehavior,
                         WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior);

            if (behavior == null)
                throw new ServiceAuthenticationConfigurationMissingException();

            var authorizationBehavior =
                dispatchRuntime.ChannelDispatcher.Host.Description.FindBehavior
                        <WebAuthorizationConfigurationBehavior,
                        WebAuthorizationConfigurationAttribute>(b => b.BaseBehavior);

            Type authorizationPolicy = null;
            if (authorizationBehavior != null)
                authorizationPolicy = authorizationBehavior.AuthorizationPolicyType;

            foreach (var endpointDispatcher in dispatchRuntime.ChannelDispatcher.Endpoints)
                endpointDispatcher.DispatchRuntime.MessageInspectors.Add(
                    new ServiceAuthenticationInspector(
                        behavior.ThrowIfNull().AuthenticationHandler,
                        behavior.UsernamePasswordValidatorType,
                        behavior.RequireSecureTransport,
                        behavior.Source,
                        authorizationPolicy));
        }
开发者ID:wildart,项目名称:WcfRestContrib,代码行数:33,代码来源:ServiceAuthenticationBehavior.cs

示例5: MethodInfoOperationSelector

 void IContractBehavior.ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     if (dispatch.ClientRuntime != null)
     {
         dispatch.ClientRuntime.OperationSelector = new MethodInfoOperationSelector(description, MessageDirection.Output);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:OperationSelectorBehavior.cs

示例6: ApplyDispatchBehavior

 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
   if (dispatchRuntime == null)
     throw new ArgumentNullException("dispatchRuntime");
   dispatchRuntime.InstanceProvider = this.instanceProvider;
   dispatchRuntime.InstanceContextInitializers.Add((IInstanceContextInitializer) new UnityInstanceContextInitializer());
 }
开发者ID:gruan01,项目名称:Unity.WCF.4,代码行数:7,代码来源:UnityContractBehavior.cs

示例7: ApplyDispatchBehavior

        public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
        {
            // We iterate over the operation descriptions in the contract and
            // try to locate an DispatchBodyElementAttribute behaviors on each
            // operation. If found, we add the operation, keyed by QName of the body element
            // that selects which calls shall be dispatched to this operation to a
            // dictionary.
            Dictionary<XmlQualifiedName,string> dispatchDictionary = new Dictionary<XmlQualifiedName,string>();
            foreach( OperationDescription operationDescription in contractDescription.Operations )
            {
                DispatchBodyElementAttribute dispatchBodyElement =
                    operationDescription.Behaviors.Find<DispatchBodyElementAttribute>();
                if ( dispatchBodyElement != null )
                {
                    dispatchDictionary.Add(dispatchBodyElement.QName, operationDescription.Name);
                }
            }

            // Lastly, we create and assign and instance of our operation selector that
            // gets the dispatch dictionary we've just created.
            dispatchRuntime.OperationSelector =
                new DispatchByBodyElementOperationSelector(
                   dispatchDictionary,
                   dispatchRuntime.UnhandledDispatchOperation.Name);
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:25,代码来源:DispatchByBodyElementBehaviorAttribute.cs

示例8: MethodInfoOperationSelector

            internal MethodInfoOperationSelector(ContractDescription description, MessageDirection directionThatRequiresClientOpSelection)
            {
                operationMap = new Dictionary<object, string>();

                for (int i = 0; i < description.Operations.Count; i++)
                {
                    OperationDescription operation = description.Operations[i];
                    if (operation.Messages[0].Direction == directionThatRequiresClientOpSelection)
                    {
                        if (operation.SyncMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.SyncMethod.MethodHandle))
                                operationMap.Add(operation.SyncMethod.MethodHandle, operation.Name);
                        }
    
                        if (operation.BeginMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.BeginMethod.MethodHandle))
                            {
                                operationMap.Add(operation.BeginMethod.MethodHandle, operation.Name);
                                operationMap.Add(operation.EndMethod.MethodHandle, operation.Name);                    
                            }
                        }

                        if (operation.TaskMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.TaskMethod.MethodHandle))
                            {
                                operationMap.Add(operation.TaskMethod.MethodHandle, operation.Name);
                            }
                        }
                    }
                }
            }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:34,代码来源:OperationSelectorBehavior.cs

示例9: NotImplementedException

		void IContractBehavior.ApplyDispatchBehavior (
			ContractDescription description,
			ServiceEndpoint endpoint,
			DispatchRuntime dispatch)
		{
			throw new NotImplementedException ();
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:DeliveryRequirementsAttribute.cs

示例10: ServiceContractGenerationContext

		public ServiceContractGenerationContext (
			ServiceContractGenerator serviceContractGenerator,
			ContractDescription contract,
			CodeTypeDeclaration contractType)
			: this (serviceContractGenerator, contract, contractType, null)
		{
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ServiceContractGenerationContext.cs

示例11: ApplyDispatchBehavior

 public void ApplyDispatchBehavior(
   ContractDescription contractDescription,
   ServiceEndpoint endpoint,
   DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.InstanceProvider = this;
 }
开发者ID:tavisca-dhruvas,项目名称:Training,代码行数:7,代码来源:UnityServiceHostFactory.cs

示例12: ComPlusThreadInitializer

 public ComPlusThreadInitializer(ContractDescription contract, DispatchOperation operation, ServiceInfo info)
 {
     this.info = info;
     this.iid = contract.ContractType.GUID;
     if (info.CheckRoles)
     {
         string[] serviceRoleMembers = null;
         string[] contractRoleMembers = null;
         string[] operationRoleMembers = null;
         serviceRoleMembers = info.ComponentRoleMembers;
         foreach (ContractInfo info2 in this.info.Contracts)
         {
             if (!(info2.IID == this.iid))
             {
                 continue;
             }
             contractRoleMembers = info2.InterfaceRoleMembers;
             foreach (System.ServiceModel.ComIntegration.OperationInfo info3 in info2.Operations)
             {
                 if (info3.Name == operation.Name)
                 {
                     operationRoleMembers = info3.MethodRoleMembers;
                     break;
                 }
             }
             if (operationRoleMembers == null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ComOperationNotFound", new object[] { contract.Name, operation.Name })));
             }
             break;
         }
         this.comAuth = new ComPlusAuthorization(serviceRoleMembers, contractRoleMembers, operationRoleMembers);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:ComPlusThreadInitializer.cs

示例13: ApplyDispatchBehavior

 /// <summary>
 /// 注册 服务实例创建提供者,将基于PIAB的实例生成器注入WCF扩展
 /// </summary>
 /// <param name="contractDescription"></param>
 /// <param name="endpoint"></param>
 /// <param name="dispatchRuntime"></param>
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint,
                                   DispatchRuntime dispatchRuntime)
 {
     Type serviceContractType = contractDescription.ContractType;
     dispatchRuntime.InstanceProvider = new PolicyInjectionInstanceProvider(serviceContractType,
                                                                            this.PolicyInjectorName);
 }
开发者ID:zlphoenix,项目名称:MyDemos,代码行数:13,代码来源:PolicyInjectionBehaviorAttribute.cs

示例14: ApplyDispatchBehavior

 public void ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatch)
 {
     foreach (OperationDescription opDesc in description.Operations)
     {
         ApplyDataContractSurrogate(opDesc);
     }
 }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:AllowNonSerializableTypesAttribute.cs

示例15: AddPingToContractDescription

        /// <summary>
        /// Add the Ping method to the existing contract
        /// </summary>
        private void AddPingToContractDescription(ContractDescription contractDescription)
        {
            OperationDescription pingOperationDescription = new OperationDescription(PingOperationName, contractDescription);

            MessageDescription inputMessageDescription = new MessageDescription(
                GetAction(contractDescription, PingOperationName),
                MessageDirection.Input);

            MessageDescription outputMessageDescription = new MessageDescription(
                GetAction(contractDescription, PingResponse),
                MessageDirection.Output);

            MessagePartDescription returnValue = new MessagePartDescription("PingResult", contractDescription.Namespace);

            returnValue.Type = typeof(DateTime);
            outputMessageDescription.Body.ReturnValue = returnValue;

            inputMessageDescription.Body.WrapperName = PingOperationName;
            inputMessageDescription.Body.WrapperNamespace = contractDescription.Namespace;
            outputMessageDescription.Body.WrapperName = PingResponse;
            outputMessageDescription.Body.WrapperNamespace = contractDescription.Namespace;

            pingOperationDescription.Messages.Add(inputMessageDescription);
            pingOperationDescription.Messages.Add(outputMessageDescription);

            pingOperationDescription.Behaviors.Add(new DataContractSerializerOperationBehavior(pingOperationDescription));
            pingOperationDescription.Behaviors.Add(new PingOperationBehavior());

            contractDescription.Operations.Add(pingOperationDescription);
        }
开发者ID:serbrech,项目名称:WCFPing,代码行数:33,代码来源:PingEndpointBehavior.cs


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