本文整理汇总了C#中System.ServiceModel.Description.ServiceDescription类的典型用法代码示例。如果您正苦于以下问题:C# ServiceDescription类的具体用法?C# ServiceDescription怎么用?C# ServiceDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceDescription类属于System.ServiceModel.Description命名空间,在下文中一共展示了ServiceDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyDispatchBehavior
public virtual void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
string workflowDisplayName = "";
System.ServiceModel.Activities.WorkflowServiceHost workflowServiceHost = serviceHostBase as System.ServiceModel.Activities.WorkflowServiceHost;
if (null != workflowServiceHost)
{
workflowDisplayName = ((System.ServiceModel.Activities.WorkflowServiceHost)serviceHostBase).Activity.DisplayName;
}
System.ServiceModel.Activities.WorkflowServiceHost host = serviceHostBase as System.ServiceModel.Activities.WorkflowServiceHost;
if (this.TrackingComponentElements != null && host != null)
{
foreach (TrackingComponentElement trackingComponentElement in this.TrackingComponentElements)
{
TrackingParticipant trackingComponent = this.CreateTrackingComponent(trackingComponentElement);
if (trackingComponent != null)
{
if (!string.IsNullOrEmpty(trackingComponentElement.ProfileName))
{
trackingComponent.TrackingProfile = this.GetProfile(trackingComponentElement.ProfileName, workflowDisplayName);
}
host.WorkflowExtensions.Add(trackingComponent);
}
else
{
throw new Exception(string.Format("Tracking component is not a known type: {0}", trackingComponentElement.Name));
}
}
}
}
示例2: ApplyDispatchBehavior
/// <summary>
/// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects.
/// </summary>
/// <param name="serviceDescription">The service description.</param>
/// <param name="serviceHostBase">The host that is currently being built.</param>
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
var instanceProvider =
new ServiceInstanceProvider(this.ServiceType);
var implementors =
from end in serviceDescription.Endpoints
where end.Contract.ContractType.IsAssignableFrom(this.ServiceType)
select end.Contract.Name;
foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers)
{
ChannelDispatcher channelDispatcher =
channelDispatcherBase as ChannelDispatcher;
if (channelDispatcher != null)
{
foreach (EndpointDispatcher endPoint in channelDispatcher.Endpoints)
{
if (implementors.Contains(endPoint.ContractName))
endPoint.DispatchRuntime.InstanceProvider = instanceProvider;
}
}
}
}
示例3: AddBindingParameters
public void AddBindingParameters(
ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase,
Collection<ServiceEndpoint> endpoints,
BindingParameterCollection bindingParameters)
{
}
示例4: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers)
{
channelDispatcher.ErrorHandlers.Add(new ServiceErrorHandler(this.ExceptionPolicyName));
}
}
示例5: ApplyDispatchBehavior
/// <summary>
/// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects.
/// </summary>
/// <param name="serviceDescription">The service description.</param>
/// <param name="serviceHostBase">The host that is currently being built.</param>
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (var endpoint in serviceDescription.Endpoints)
{
RegisterContract(endpoint);
}
}
示例6: AddBindingParameters
public virtual void AddBindingParameters(ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase,
Collection<ServiceEndpoint> endpoints,
BindingParameterCollection bindingParameters)
{
throw new NotImplementedException();
}
示例7: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher chanDisp in serviceHostBase.ChannelDispatchers)
{
chanDisp.ErrorHandlers.Add(this);
}
}
示例8: AddBehaviors
void AddBehaviors(ServiceDescription service)
{
// The philosophy here is to respect settings from configuration
// At the moment, none of the settings we care about can be modified
// through configuration. That may change in the future.
// However, we never want to silently overwrite a user's configuration.
// So we should either accept overrides or reject them, but never
// silently update them.
//
ServiceBehaviorAttribute serviceBehavior = EnsureBehaviorAttribute(service);
serviceBehavior.InstanceProvider = new ComPlusInstanceProvider(this.info);
serviceBehavior.InstanceContextMode = InstanceContextMode.Single;
// SHOULD: There is no reason to not allow concurrency at this level
serviceBehavior.ConcurrencyMode = ConcurrencyMode.Multiple;
serviceBehavior.UseSynchronizationContext = false;
service.Behaviors.Add(new SecurityCookieModeValidator());
if (AspNetEnvironment.Enabled)
{
AspNetCompatibilityRequirementsAttribute aspNetCompatibilityRequirements = service.Behaviors.Find<AspNetCompatibilityRequirementsAttribute>();
if (aspNetCompatibilityRequirements == null)
{
aspNetCompatibilityRequirements = new AspNetCompatibilityRequirementsAttribute();
service.Behaviors.Add(aspNetCompatibilityRequirements);
}
}
}
示例9: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
/* IMPORTANT NOTE:
* This service behavior assumes that the said operation and endpoint behaviors are stateless.
* As a result it uses the same instance of the behaviors across all endpoints and operations.
* All changes to these behaviors need to ensure that the STATELESSNESS IS MAINTAINED.
*/
lock (_syncRoot)
{
// Get endpoint and operation behaviors.
// Install behaviors
for (int i = 0; i < serviceDescription.Endpoints.Count; i++)
{
var endpoint = serviceDescription.Endpoints[i];
// Add operation behavior
// Add the operation behavior to the endpoint
for (int j = 0; j < endpoint.Contract.Operations.Count; j++)
{
var operation = endpoint.Contract.Operations[j];
if (operation.Behaviors.Contains(typeof(AllowAsyncService)) == false)
operation.Behaviors.Add(this);
}
}
}
}
示例10: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
var errorhandlers = this.behaviorTypes.Where(t => t.GetInterfaces().Any(i=>i == typeof(IErrorHandler))).ToList();
var messageinspectors = this.behaviorTypes.Where(t => t.GetInterfaces().Any(i => i == typeof(IDispatchMessageInspector))).ToList();
foreach (ChannelDispatcher cd in serviceHostBase.ChannelDispatchers)
{
//add error handlers to all channel dispatchers
foreach (var errorhandler in errorhandlers)
{
var handler = (IErrorHandler)Activator.CreateInstance(errorhandler);
cd.ErrorHandlers.Add(handler);
}
//add message inspectors to all endpoints
foreach (EndpointDispatcher ed in cd.Endpoints)
{
foreach (var messageinspector in messageinspectors)
{
var inspector = (IDispatchMessageInspector)Activator.CreateInstance(messageinspector);
ed.DispatchRuntime.MessageInspectors.Add(inspector);
}
}
}
}
示例11: ApplyDispatchBehavior
/// <summary>
/// Provides the ability to change run-time property values or insert custom extension objects such as exception handlers, message or parameter interceptors, security extensions, and other custom extension objects.
/// </summary>
/// <param name = "serviceDescription">The service description.</param>
/// <param name = "serviceHostBase">The host that is currently being built.</param>
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher chanDisp in serviceHostBase.ChannelDispatchers)
{
chanDisp.ErrorHandlers.Add(new LastChanceErrorHandler());
}
}
示例12: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers)
{
channelDispatcher.ErrorHandlers.Add(errorHandler);
}
}
示例13: ApplyDispatchBehavior
//- @ApplyDispatchBehavior -//
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers)
{
dispatcher.ErrorHandlers.Add(new ErrorHandler(serviceDescription.ServiceType));
}
}
示例14: ApplyDispatchBehavior
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
if (serviceDescription == null)
{
throw new ArgumentNullException("serviceDescription");
}
if (serviceHostBase == null)
{
throw new ArgumentNullException("serviceHostBase");
}
for (var dispatcherIndex = 0;
dispatcherIndex < serviceHostBase.ChannelDispatchers.Count;
dispatcherIndex++)
{
var dispatcher = serviceHostBase.ChannelDispatchers[dispatcherIndex];
var channelDispatcher = (ChannelDispatcher)dispatcher;
for (var endpointIndex = 0; endpointIndex < channelDispatcher.Endpoints.Count; endpointIndex++)
{
var endpointDispatcher = channelDispatcher.Endpoints[endpointIndex];
endpointDispatcher.DispatchRuntime.InstanceProvider =
new UnityInstanceProvider(this.Container, serviceDescription.ServiceType);
}
}
}
示例15: Validate
// The validation process will scan each endpoint to see if it's bindings have binding elements
// that are secure. These elements consist of: Transport, Asymmetric, Symmetric,
// HttpsTransport, WindowsStream and SSLStream.
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
// Loop through each endpoint individually gathering their binding elements.
foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints)
{
secureElementFound = false;
// Retrieve the endpoint's binding element collection.
BindingElementCollection bindingElements = endpoint.Binding.CreateBindingElements();
// Look to see if the binding elements collection contains any secure binding
// elements. Transport, Asymmetric and Symmetric binding elements are all
// derived from SecurityBindingElement.
if ((bindingElements.Find<SecurityBindingElement>() != null) ||
(bindingElements.Find<HttpsTransportBindingElement>() != null) ||
(bindingElements.Find<WindowsStreamSecurityBindingElement>() != null) ||
(bindingElements.Find<SslStreamSecurityBindingElement>() != null))
{
secureElementFound = true;
}
// Send a message to the system event viewer whhen an endpoint is deemed insecure.
if (!secureElementFound)
throw new Exception(System.DateTime.Now.ToString() + ": The endpoint \"" + endpoint.Name + "\" has no secure bindings.");
}
}