Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / ServiceModel / WorkflowServiceHost.cs / 1305376 / WorkflowServiceHost.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel { using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Runtime; using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.Workflow.ComponentModel.Compiler; using System.Workflow.Runtime; public class WorkflowServiceHost : ServiceHostBase { IListreflectedContracts; WorkflowDefinitionContext workflowDefinitionContext; public WorkflowServiceHost(Type workflowType, params Uri[] baseAddress) : this(new CompiledWorkflowDefinitionContext(workflowType), baseAddress) { } public WorkflowServiceHost(string workflowDefinitionPath, params Uri[] baseAddress) : this(new StreamedWorkflowDefinitionContext(workflowDefinitionPath, null, null), baseAddress) { } public WorkflowServiceHost(string workflowDefinitionPath, string ruleDefinitionPath, params Uri[] baseAddress) : this(new StreamedWorkflowDefinitionContext(workflowDefinitionPath, ruleDefinitionPath, null), baseAddress) { } public WorkflowServiceHost(string workflowDefinitionPath, string ruleDefinitionPath, ITypeProvider typeProvider, params Uri[] baseAddress) : this(new StreamedWorkflowDefinitionContext(workflowDefinitionPath, ruleDefinitionPath, typeProvider), baseAddress) { } public WorkflowServiceHost(Stream workflowDefinition, params Uri[] baseAddress) : this(new StreamedWorkflowDefinitionContext(workflowDefinition, null, null), baseAddress) { } public WorkflowServiceHost(Stream workflowDefinition, Stream ruleDefinition, params Uri[] baseAddress) : this(new StreamedWorkflowDefinitionContext(workflowDefinition, ruleDefinition, null), baseAddress) { } public WorkflowServiceHost(Stream workflowDefinition, Stream ruleDefinition, ITypeProvider typeProvider, params Uri[] baseAddress) : this(new StreamedWorkflowDefinitionContext(workflowDefinition, ruleDefinition, typeProvider), baseAddress) { } // Based on prior art from WCF: // ServiceModel.lst:System.ServiceModel.ServiceHost..ctor(System.Object,System.Uri[]) // |DoNotCallOverridableMethodsInConstructors // |[....]|By design, don't want to complicate ServiceHost state model [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] internal WorkflowServiceHost(WorkflowDefinitionContext workflowDefinitionContext, params Uri[] baseAddress) : base() { InitializeDescription(workflowDefinitionContext, new UriSchemeKeyedCollection(baseAddress)); } protected WorkflowServiceHost() { } public ServiceEndpoint AddServiceEndpoint(Type implementedContract, Binding binding, string address) { if (address == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("address")); } return this.AddServiceEndpoint(implementedContract, binding, new Uri(address, UriKind.RelativeOrAbsolute)); } public ServiceEndpoint AddServiceEndpoint(Type implementedContract, Binding binding, Uri address) { return this.AddServiceEndpoint(implementedContract, binding, address, null); } public ServiceEndpoint AddServiceEndpoint(Type implementedContract, Binding binding, string address, Uri listenUri) { if (address == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("address")); } return this.AddServiceEndpoint(implementedContract, binding, new Uri(address, UriKind.RelativeOrAbsolute), listenUri); } public ServiceEndpoint AddServiceEndpoint(Type implementedContract, Binding binding, Uri address, Uri listenUri) { if (implementedContract == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("implementedContract")); } if (!implementedContract.IsDefined(typeof(ServiceContractAttribute), false)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.ServiceContractAttributeNotFound, new object[] { implementedContract.FullName }))); } if (this.reflectedContracts == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.ReflectedContractsNotInitialized, new object[] { implementedContract.FullName }))); } if (!reflectedContracts.Contains(implementedContract)) { if (ServiceMetadataBehavior.IsMetadataImplementedType(implementedContract)) { if (!this.Description.Behaviors.Contains( typeof(ServiceMetadataBehavior))) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.MetadataEndpointCannotBeAdded, new object[] { implementedContract.FullName }))); } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.ReflectedContractKeyNotFound, new object[] { implementedContract.FullName, this.workflowDefinitionContext.WorkflowName }))); } } ServiceEndpoint endpoint = base.AddServiceEndpoint(ContractDescription.GetContract(implementedContract).ConfigurationName, binding, address); if (listenUri != null) { listenUri = base.MakeAbsoluteUri(listenUri, binding); endpoint.ListenUri = listenUri; } return endpoint; } [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#", Justification = "This is defined by the ServiceHost base class")] protected override ServiceDescription CreateDescription(out IDictionary implementedContracts) { Fx.Assert(this.workflowDefinitionContext != null, "Null Workflow Definition"); return new DescriptionCreator(this.workflowDefinitionContext).BuildServiceDescription(out implementedContracts, out this.reflectedContracts); } protected override void OnClosing() { WorkflowRuntimeBehavior workflowRuntimeBehavior = this.Description.Behaviors.Find (); if (workflowRuntimeBehavior != null) { workflowRuntimeBehavior.WorkflowRuntime.StopRuntime(); } base.OnClosing(); } void InitializeDescription(WorkflowDefinitionContext workflowDefinitionContext, UriSchemeKeyedCollection baseAddresses) { this.workflowDefinitionContext = workflowDefinitionContext; this.InitializeDescription(baseAddresses); if (!this.Description.Behaviors.Contains(typeof(WorkflowRuntimeBehavior))) { this.Description.Behaviors.Add(new WorkflowRuntimeBehavior()); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ECDiffieHellmanPublicKey.cs
- XmlComment.cs
- UIInitializationException.cs
- Clock.cs
- DecimalConverter.cs
- Trace.cs
- FileDialogCustomPlaces.cs
- WebBrowserNavigatedEventHandler.cs
- TextEffect.cs
- WindowsStartMenu.cs
- DataGridViewComboBoxColumn.cs
- AuthenticationManager.cs
- SafeSecurityHelper.cs
- BasicDesignerLoader.cs
- EmptyElement.cs
- CalendarTable.cs
- RefreshPropertiesAttribute.cs
- VersionedStreamOwner.cs
- BaseAppDomainProtocolHandler.cs
- TargetParameterCountException.cs
- _SpnDictionary.cs
- AttributeCollection.cs
- Form.cs
- UnsafeNativeMethods.cs
- IdentityVerifier.cs
- LifetimeMonitor.cs
- SourceFileBuildProvider.cs
- DataControlPagerLinkButton.cs
- OutputBuffer.cs
- GeneralTransform2DTo3DTo2D.cs
- DataListGeneralPage.cs
- XmlEncoding.cs
- GenericRootAutomationPeer.cs
- FieldMetadata.cs
- GridViewColumn.cs
- XsltException.cs
- CodeTryCatchFinallyStatement.cs
- AuthorizationRuleCollection.cs
- LoginNameDesigner.cs
- ApplicationCommands.cs
- TrackingDataItemValue.cs
- CodeVariableReferenceExpression.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- XPathBuilder.cs
- GeometryModel3D.cs
- QueueProcessor.cs
- ValidationHelper.cs
- InputScopeNameConverter.cs
- ApplyImportsAction.cs
- Clause.cs
- GridViewItemAutomationPeer.cs
- AccessDataSourceView.cs
- SendMessageRecord.cs
- SHA1CryptoServiceProvider.cs
- DiagnosticStrings.cs
- FileSystemInfo.cs
- ConfigurationSectionGroupCollection.cs
- StateMachineHistory.cs
- ParserOptions.cs
- DecoderNLS.cs
- Stacktrace.cs
- DynamicILGenerator.cs
- HttpModuleAction.cs
- UniqueIdentifierService.cs
- SingleTagSectionHandler.cs
- ScaleTransform3D.cs
- DataSet.cs
- URIFormatException.cs
- TrackingProfileDeserializationException.cs
- SessionEndingEventArgs.cs
- LowerCaseStringConverter.cs
- TableRowCollection.cs
- MappedMetaModel.cs
- InvalidOleVariantTypeException.cs
- TypeGeneratedEventArgs.cs
- ServicesUtilities.cs
- DialogResultConverter.cs
- VirtualPathProvider.cs
- ObjectSet.cs
- MouseButtonEventArgs.cs
- CapabilitiesUse.cs
- FixedDocumentPaginator.cs
- ComPlusDiagnosticTraceRecords.cs
- TabItemWrapperAutomationPeer.cs
- TypeSystemHelpers.cs
- BufferBuilder.cs
- HighlightVisual.cs
- HtmlMeta.cs
- GCHandleCookieTable.cs
- TemplateBaseAction.cs
- WebBrowserContainer.cs
- DocumentGridContextMenu.cs
- WorkflowQueue.cs
- ButtonBaseAdapter.cs
- CuspData.cs
- LessThan.cs
- SettingsPropertyCollection.cs
- TransactionScope.cs
- TypeSource.cs
- _LocalDataStoreMgr.cs