本文整理汇总了C#中ServiceHostBase类的典型用法代码示例。如果您正苦于以下问题:C# ServiceHostBase类的具体用法?C# ServiceHostBase怎么用?C# ServiceHostBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceHostBase类属于命名空间,在下文中一共展示了ServiceHostBase类的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: DurableServiceAttribute
void IServiceBehavior.Validate(ServiceDescription description,ServiceHostBase host)
{
DurableServiceAttribute durable = new DurableServiceAttribute();
durable.SaveStateInOperationTransaction = true;
description.Behaviors.Add(durable);
PersistenceProviderFactory factory;
if(AutoCompleteInstance)
{
factory = new TransactionalInstanceProviderFactory();
}
else
{
factory = new TransactionalMemoryProviderFactory();
}
PersistenceProviderBehavior persistenceBehavior = new PersistenceProviderBehavior(factory);
description.Behaviors.Add(persistenceBehavior);
if(TransactionRequiredAllOperations)
{
foreach(ServiceEndpoint endpoint in description.Endpoints)
{
foreach(OperationDescription operation in endpoint.Contract.Operations)
{
operation.Behaviors.Find<OperationBehaviorAttribute>().TransactionScopeRequired = true;
}
}
}
}
示例3: AddBindingParameters
public void AddBindingParameters(
ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase,
Collection<ServiceEndpoint> endpoints,
BindingParameterCollection bindingParameters)
{
}
示例4: ArgumentException
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
{
IErrorHandler errorHandler;
try
{
errorHandler = (IErrorHandler)Activator.CreateInstance(m_errorHandlerType, m_tracer);
}
catch (MissingMethodException e)
{
throw new ArgumentException(string.Format(
"The errorHandlerType {0} must have a public constructor with single argument of type {1}",
m_errorHandlerType.AssemblyQualifiedName, typeof(ITracer).AssemblyQualifiedName)
, e);
}
catch (InvalidCastException e)
{
throw new ArgumentException(string.Format(
"The errorHandlerType {0} must implement System.ServiceModel.Dispatcher.IErrorHandler.",
m_errorHandlerType.AssemblyQualifiedName), e);
}
foreach (var channelDispatcherBase in serviceHostBase.ChannelDispatchers)
{
var channelDispatcher = channelDispatcherBase as ChannelDispatcher;
if (channelDispatcher != null)
{
channelDispatcher.ErrorHandlers.Add(errorHandler);
}
}
}
示例5: AddBindingParameters
/// <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));
}
}
示例6: 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.");
}
}
示例7: DefaultPerformanceCounters
internal DefaultPerformanceCounters(ServiceHostBase serviceHost)
{
this.instanceName = DefaultPerformanceCounters.CreateFriendlyInstanceName(serviceHost);
this.Counters = new PerformanceCounter[(int)PerfCounters.TotalCounters];
for (int i = 0; i < (int)PerfCounters.TotalCounters; i++)
{
try
{
PerformanceCounter counter = PerformanceCounters.GetDefaultPerformanceCounter(this.perfCounterNames[i], this.instanceName);
if (counter != null)
{
this.Counters[i] = counter;
}
else
{
break;
}
}
#pragma warning suppress 56500 // covered by FxCOP
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
if (DiagnosticUtility.ShouldTraceError)
{
TraceUtility.TraceEvent(TraceEventType.Error, TraceCode.PerformanceCountersFailedForService,
SR.GetString(SR.TraceCodePerformanceCountersFailedForService), null, e);
}
break;
}
}
}
示例8: 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());
}
}
示例9: ListenerHandler
internal ListenerHandler(IListenerBinder listenerBinder, System.ServiceModel.Dispatcher.ChannelDispatcher channelDispatcher, ServiceHostBase host, ServiceThrottle throttle, IDefaultCommunicationTimeouts timeouts)
{
this.listenerBinder = listenerBinder;
if (this.listenerBinder == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
}
this.channelDispatcher = channelDispatcher;
if (this.channelDispatcher == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
}
this.host = host;
if (this.host == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("host");
}
this.throttle = throttle;
if (this.throttle == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("throttle");
}
this.timeouts = timeouts;
this.endpoints = channelDispatcher.EndpointDispatcherTable;
this.acceptor = new ErrorHandlingAcceptor(listenerBinder, channelDispatcher);
}
示例10: RegisterErrorHandlerBehavior
private void RegisterErrorHandlerBehavior(ErrorHandlerBehavior errorHandlerBehavior, ServiceHostBase host)
{
if (host.Description.Behaviors.Find<ErrorHandlerBehavior>() == null)
{
host.Description.Behaviors.Add(errorHandlerBehavior);
}
}
示例11: CreateServiceCounters
internal static ServicePerformanceCountersBase CreateServiceCounters(ServiceHostBase serviceHost)
{
if (OSEnvironmentHelper.IsVistaOrGreater)
{
try
{
ServicePerformanceCountersV2 sv = new ServicePerformanceCountersV2(serviceHost);
EndpointPerformanceCountersV2.EnsureCounterSet();
OperationPerformanceCountersV2.EnsureCounterSet();
return sv;
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
PerformanceCounters.Scope = PerformanceCounterScope.Off;
if (DiagnosticUtility.ShouldTraceError)
{
TraceUtility.TraceEvent(TraceEventType.Error, 0x8003b, System.ServiceModel.SR.GetString("TraceCodePerformanceCountersFailedForService"), null, exception);
}
return null;
}
}
return new ServicePerformanceCounters(serviceHost);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:PerformanceCountersFactory.cs
示例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: ArgumentException
void IServiceBehavior.ApplyDispatchBehavior(
ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase)
{
IErrorHandler errorHandler;
try
{
errorHandler = (IErrorHandler)Activator.CreateInstance(errorHandlerType);
}
catch (MissingMethodException e)
{
throw new ArgumentException(
"The errorHandlerType specified in the ErrorBehaviorAttribute constructor must have a public empty constructor.",
e);
}
catch (InvalidCastException e)
{
throw new ArgumentException(
"The errorHandlerType specified in the ErrorBehaviorAttribute constructor must implement System.ServiceModel.Dispatcher.IErrorHandler.",
e);
}
foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers)
{
var channelDispatcher = channelDispatcherBase as ChannelDispatcher;
channelDispatcher.ErrorHandlers.Add(errorHandler);
}
}