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
- VectorCollectionConverter.cs
- PersonalizableAttribute.cs
- ImageSourceConverter.cs
- SafeCryptoHandles.cs
- IProvider.cs
- WindowsMenu.cs
- DbConnectionPool.cs
- CqlLexerHelpers.cs
- TextTreeRootNode.cs
- TextDecorationLocationValidation.cs
- ScrollChrome.cs
- QueryableDataSource.cs
- SelectedGridItemChangedEvent.cs
- LockedAssemblyCache.cs
- NamespaceEmitter.cs
- GridViewRowEventArgs.cs
- PenLineCapValidation.cs
- COM2EnumConverter.cs
- ObjectPersistData.cs
- SettingsBase.cs
- CodeDirectiveCollection.cs
- EventSetter.cs
- QueryRewriter.cs
- ComAwareEventInfo.cs
- BufferedMessageWriter.cs
- HScrollBar.cs
- TableCell.cs
- AbstractSvcMapFileLoader.cs
- DateTimeParse.cs
- ConfigXmlReader.cs
- ReadOnlyAttribute.cs
- EntityProviderFactory.cs
- JsonSerializer.cs
- CalendarDay.cs
- UInt64Storage.cs
- Function.cs
- DmlSqlGenerator.cs
- InternalBufferOverflowException.cs
- SemaphoreFullException.cs
- CommonDialog.cs
- TextChange.cs
- AxisAngleRotation3D.cs
- NonClientArea.cs
- SliderAutomationPeer.cs
- basenumberconverter.cs
- SHA384Cng.cs
- CollectionMarkupSerializer.cs
- BufferAllocator.cs
- HtmlMobileTextWriter.cs
- UnhandledExceptionEventArgs.cs
- TextDataBindingHandler.cs
- KeyInterop.cs
- IteratorDescriptor.cs
- Timer.cs
- IndentedWriter.cs
- ResourceBinder.cs
- FixedTextContainer.cs
- StoragePropertyMapping.cs
- TextServicesLoader.cs
- NullReferenceException.cs
- RenderCapability.cs
- MessageBodyMemberAttribute.cs
- HierarchicalDataBoundControl.cs
- ListViewGroup.cs
- TextRangeProviderWrapper.cs
- DeviceSpecificChoice.cs
- BuildResult.cs
- TemplateBaseAction.cs
- BatchServiceHost.cs
- BinHexEncoding.cs
- SmiGettersStream.cs
- DbConnectionOptions.cs
- MapPathBasedVirtualPathProvider.cs
- TransferMode.cs
- UserMapPath.cs
- HashCodeCombiner.cs
- OpCopier.cs
- BitmapEffectDrawing.cs
- NamespaceInfo.cs
- messageonlyhwndwrapper.cs
- ZipArchive.cs
- UrlMapping.cs
- MethodCallTranslator.cs
- MouseBinding.cs
- FixedElement.cs
- SpecialNameAttribute.cs
- QilTargetType.cs
- StatusBar.cs
- ReferenceList.cs
- SerialStream.cs
- DataGridViewTopLeftHeaderCell.cs
- RadioButtonDesigner.cs
- DCSafeHandle.cs
- ReflectPropertyDescriptor.cs
- DiscoveryEndpointElement.cs
- TypeConverterHelper.cs
- CodeExpressionCollection.cs
- SQLChars.cs
- ChineseLunisolarCalendar.cs
- PreservationFileWriter.cs