Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Messaging / Listener.cs / 1 / Listener.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // Define the representation of a ServiceModel service and its associated metadata using System; using System.ServiceModel.Dispatcher; using System.ServiceModel.Description; using System.Diagnostics; using System.Globalization; using System.Security.Principal; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; using System.Transactions; namespace Microsoft.Transactions.Wsat.Messaging { interface ICoordinationListener { void Start(); void Stop(); EndpointAddress CreateEndpointReference(AddressHeader refParam); } class CoordinationServiceHost : ServiceHost, ICoordinationListener { CoordinationService service; EndpointAddress baseEndpoint; public CoordinationServiceHost(CoordinationService service, object serviceInstance) { this.service = service; base.InitializeDescription(serviceInstance, new UriSchemeKeyedCollection()); } // This is called during Start() // The idea is to obtain a base endpoint before we're actually on the network // This prevents races between the initialization path and incoming messages protected override void InitializeRuntime() { DebugTrace.TraceEnter(this, "OnCreateListeners"); base.InitializeRuntime(); if (!(this.SingletonInstance is IWSActivationCoordinator)) { CreateBaseEndpointAddress(); } else if (DebugTrace.Info) { for (int i=0; i(); CoordinationStrings coordinationStrings = CoordinationStrings.Version(this.service.ProtocolVersion); if (sbe != null) { if (!sbe.OptionalOperationSupportingTokenParameters.ContainsKey(coordinationStrings.RegisterAction)) { sbe.OptionalOperationSupportingTokenParameters.Add(coordinationStrings.RegisterAction, new SupportingTokenParameters()); } sbe.OptionalOperationSupportingTokenParameters[coordinationStrings.RegisterAction].Endorsing.Add(CoordinationServiceSecurity.SecurityContextSecurityTokenParameters); endpoint.Binding = customBinding; } } } this.Open(); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Opened ServiceHost for {0}", this.SingletonInstance.GetType().Name); } } catch (CommunicationException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessagingInitializationException( SR.GetString(SR.ListenerCannotBeStarted, this.baseEndpoint.Uri, e.Message), e)); } } public void Stop() { try { this.Close(); } catch (CommunicationException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Error); } catch (TimeoutException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Error); } } public EndpointAddress CreateEndpointReference(AddressHeader refParam) { if (this.baseEndpoint == null) { // Validating assumption that the base endpoint will be set. // We assume that this function will only be called when we're // done initializing. If we call this function earlier, the caller // has a bug. DiagnosticUtility.FailFast("Uninitialized base endpoint reference"); } EndpointAddressBuilder builder = new EndpointAddressBuilder(this.baseEndpoint); builder.Headers.Clear(); builder.Headers.Add(refParam); return builder.ToEndpointAddress(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlCountingReader.cs
- Int64AnimationUsingKeyFrames.cs
- Code.cs
- DocumentViewerAutomationPeer.cs
- HideDisabledControlAdapter.cs
- ButtonBaseAutomationPeer.cs
- Boolean.cs
- Condition.cs
- DataGridViewImageCell.cs
- Column.cs
- EntityContainerEntitySetDefiningQuery.cs
- MediaElement.cs
- RuntimeComponentFilter.cs
- CLRBindingWorker.cs
- MetadataWorkspace.cs
- XmlProcessingInstruction.cs
- ListViewItem.cs
- InternalCache.cs
- XmlDataContract.cs
- BlockUIContainer.cs
- BitmapFrameEncode.cs
- Trace.cs
- ConfigsHelper.cs
- RuntimeCompatibilityAttribute.cs
- AnnotationService.cs
- CapabilitiesSection.cs
- DecimalKeyFrameCollection.cs
- AuthenticationModeHelper.cs
- CachedTypeface.cs
- SoapSchemaImporter.cs
- DataViewListener.cs
- CellCreator.cs
- DataGridSortingEventArgs.cs
- Menu.cs
- TrackingLocation.cs
- ListItemCollection.cs
- ProcessThread.cs
- XmlSchemaAppInfo.cs
- PlanCompiler.cs
- ListViewContainer.cs
- iisPickupDirectory.cs
- PtsContext.cs
- ScrollContentPresenter.cs
- HtmlFormAdapter.cs
- RenameRuleObjectDialog.cs
- HTTPNotFoundHandler.cs
- SqlInternalConnectionTds.cs
- Selection.cs
- IODescriptionAttribute.cs
- KnownIds.cs
- CommonObjectSecurity.cs
- OdbcPermission.cs
- MsmqTransportReceiveParameters.cs
- SmiXetterAccessMap.cs
- PropertyValueChangedEvent.cs
- TaiwanCalendar.cs
- EventManager.cs
- StoreAnnotationsMap.cs
- PolyQuadraticBezierSegment.cs
- Underline.cs
- Html32TextWriter.cs
- DesignerView.Commands.cs
- odbcmetadatacolumnnames.cs
- NameSpaceExtractor.cs
- StructuralCache.cs
- TripleDES.cs
- FigureParaClient.cs
- SByteConverter.cs
- WMIInterop.cs
- TransactionManager.cs
- XmlAttributeProperties.cs
- CollectionConverter.cs
- ListControl.cs
- HtmlMeta.cs
- DomNameTable.cs
- InputProviderSite.cs
- NavigationProgressEventArgs.cs
- RoleGroupCollection.cs
- DetailsViewPageEventArgs.cs
- ImpersonateTokenRef.cs
- LocalBuilder.cs
- safex509handles.cs
- ButtonFlatAdapter.cs
- Quaternion.cs
- RangeValueProviderWrapper.cs
- ToolBar.cs
- ProfileProvider.cs
- WizardForm.cs
- CreateParams.cs
- _WebProxyDataBuilder.cs
- Thread.cs
- Translator.cs
- DbProviderFactoriesConfigurationHandler.cs
- XmlCountingReader.cs
- RuntimeResourceSet.cs
- TraceListener.cs
- MdbDataFileEditor.cs
- FilterQueryOptionExpression.cs
- ValidationRule.cs
- PageAdapter.cs