Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Protocol / PluggableProtocol.cs / 1 / PluggableProtocol.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // This file implements the class activated by the TM bridge in representation // of the WS-AT protocol using System; using System.Diagnostics; using Microsoft.Transactions.Bridge; using Microsoft.Transactions.Wsat.InputOutput; using Microsoft.Transactions.Wsat.Messaging; namespace Microsoft.Transactions.Wsat.Protocol { [Flags] enum ProtocolVersion : ushort { Version10 = 0x01, Version11 = 0x02, } static class ProtocolVersionHelper { public static void AssertProtocolVersion(ProtocolVersion protocolVersion, Type type, string method) { if (!Enum.IsDefined(typeof(ProtocolVersion), protocolVersion)) { // We need to failfast if protocolVersion is not a defined ProtocolVersion // value because this indicate a serious incosistency DiagnosticUtility.FailFast("An invalid protocol version value was used in " + type + '.' + method); } } public static void AssertProtocolVersion10(ProtocolVersion protocolVersion, Type type, string method) { if (protocolVersion != ProtocolVersion.Version10) { // Somehow we execute 1.0 operations in the context of the // protocol version 1.1. This is a serious inconsistency. DiagnosticUtility.FailFast("Must use the protocol version 1.0 to execute " + type + '.' + method); } } public static void AssertProtocolVersion11(ProtocolVersion protocolVersion, Type type, string method) { if (protocolVersion != ProtocolVersion.Version11) { // Somehow we execute 1.1 operations in the context of the // protocol version 1.0. This is a serious inconsistency. DiagnosticUtility.FailFast("Must use the protocol version 1.1 to execute " + type + '.' + method); } } } abstract class PluggableProtocol : IProtocolProvider { ProtocolProviderState protocolProviderState; protected ProtocolState state; protected Guid protocolId; protected string name; protected ProtocolVersion protocolVersion; // // Construction // public PluggableProtocol(Guid protocolId, string name, ProtocolVersion protocolVersion) { protocolProviderState = ProtocolProviderState.Uninitialized; this.protocolId = protocolId; this.name = name; this.protocolVersion = protocolVersion; } // // IProtocolProvider implementation // public void Initialize(TransactionManager transactionManager) { DebugTrace.TraceEnter(this, "Initialize"); try { this.state = new ProtocolState(transactionManager, this.protocolVersion); this.protocolProviderState = ProtocolProviderState.Initialized; if (ProtocolInitializedRecord.ShouldTrace) { ProtocolInitializedRecord.Trace(this.protocolId, this.name); } } catch (Exception e) { DebugTrace.Trace(TraceLevel.Error, "Could not initialize protocol: {0}", e); ProtocolInitializationFailureRecord.TraceAndLog(this.protocolId, this.name, e); throw; } finally { DebugTrace.TraceLeave(this, "Initialize"); } } public void Start() { DebugTrace.TraceEnter(this, "Start"); try { this.protocolProviderState = ProtocolProviderState.Starting; this.state.Start(); this.protocolProviderState = ProtocolProviderState.Started; if (ProtocolStartedRecord.ShouldTrace) { ProtocolStartedRecord.Trace(this.protocolId, this.name); } } catch (Exception e) { DebugTrace.Trace(TraceLevel.Error, "Could not start protocol: {0}", e); ProtocolStartFailureRecord.TraceAndLog(this.protocolId, this.name, e); throw; } finally { DebugTrace.TraceLeave(this, "Start"); } } public void Stop() { DebugTrace.TraceEnter(this, "Stop"); try { this.protocolProviderState = ProtocolProviderState.Stopping; this.state.Stop(); this.protocolProviderState = ProtocolProviderState.Stopped; ProtocolStoppedRecord.TraceAndLog(this.protocolId, this.name); } catch (Exception e) { DebugTrace.Trace(TraceLevel.Error, "Could not stop protocol: {0}", e); ProtocolStopFailureRecord.TraceAndLog(this.protocolId, this.name, e); throw; } finally { DebugTrace.TraceLeave(this, "Stop"); } } public IProtocolProviderCoordinatorService CoordinatorService { get { return this.state.TransactionManagerReceive; } } public IProtocolProviderPropagationService PropagationService { get { return this.state.TransactionManagerReceive; } } public abstract Guid ProtocolId { get ; } public ProtocolProviderState State { get { return this.protocolProviderState; } } public uint MarshalCapabilities { get { return (uint) ProtocolMarshalCapabilities.UseStaticProtocolInformation; } } public abstract byte[] GetProtocolInformation(); public static Guid Id(ProtocolVersion protocolVersion) { ProtocolVersionHelper.AssertProtocolVersion(protocolVersion, typeof(PluggableProtocol), "ProtocolGuid"); //assert valid protocol version switch (protocolVersion) { case ProtocolVersion.Version10: return PluggableProtocol10.ProtocolGuid; case ProtocolVersion.Version11: return PluggableProtocol11.ProtocolGuid; default: return Guid.NewGuid(); // inaccessible path because we have asserted the protocol version } } public static string Name(ProtocolVersion protocolVersion) { ProtocolVersionHelper.AssertProtocolVersion(protocolVersion, typeof(PluggableProtocol), "Name"); //assert valid protocol version switch (protocolVersion) { case ProtocolVersion.Version10: return PluggableProtocol10.ProtocolName; case ProtocolVersion.Version11: return PluggableProtocol11.ProtocolName; default: return null; // inaccessible path because we have asserted the protocol version } } } //========================================================================================= // PluggableProtocol implementations //========================================================================================= class PluggableProtocol10 : PluggableProtocol { internal static readonly Guid ProtocolGuid = new Guid ("cc228cf4-a9c8-43fc-8281-8565eb5889f2"); internal const string ProtocolName = "WS-AtomicTransaction 1.0"; public PluggableProtocol10() : base(ProtocolGuid, ProtocolName, ProtocolVersion.Version10) {} public override Guid ProtocolId { get { return ProtocolGuid; } } public override byte[] GetProtocolInformation() { DebugTrace.TraceEnter(this, "GetProtocolInformation"); byte[] info = null; if (state.Config.NetworkEndpointsEnabled) { DebugTrace.Trace(TraceLevel.Verbose, "Generating protocol information"); ProtocolInformationWriter writer = new ProtocolInformationWriter(this.state); info = writer.GetProtocolInformation(); } else { DebugTrace.Trace(TraceLevel.Verbose, "Generating null protocol information"); } DebugTrace.TraceLeave (this, "GetProtocolInformation"); return info; } } class PluggableProtocol11 : PluggableProtocol { internal static readonly Guid ProtocolGuid = new Guid ("c05b9cad-ab24-4bb3-9440-3548fa7b4b1b"); internal const string ProtocolName = "WS-AtomicTransaction 1.1"; public PluggableProtocol11() : base(ProtocolGuid, ProtocolName, ProtocolVersion.Version11) {} public override Guid ProtocolId { get { return ProtocolGuid; } } public override byte[] GetProtocolInformation() { DebugTrace.TraceEnter(this, "GetProtocolInformation"); // no info needs to be returned as all v1.1 info can be derived from the v1.0 info DebugTrace.TraceLeave (this, "GetProtocolInformation"); return null; } } } // 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
- ComponentChangedEvent.cs
- CompilerError.cs
- DataGridViewComboBoxEditingControl.cs
- DefaultShape.cs
- ListenDesigner.cs
- Compilation.cs
- ThreadStaticAttribute.cs
- CodeDomConfigurationHandler.cs
- ListSortDescriptionCollection.cs
- TabPageDesigner.cs
- ResponseBodyWriter.cs
- SelectionItemPattern.cs
- SortDescriptionCollection.cs
- DesignerSelectionListAdapter.cs
- PriorityChain.cs
- InternalConfigHost.cs
- TextServicesCompartment.cs
- XmlNullResolver.cs
- HttpCookie.cs
- Point3DKeyFrameCollection.cs
- IDQuery.cs
- TableRow.cs
- Highlights.cs
- SpeakCompletedEventArgs.cs
- OutputCacheEntry.cs
- TextBoxBase.cs
- RewritingProcessor.cs
- BaseDataList.cs
- MenuItemAutomationPeer.cs
- SelfIssuedSamlTokenFactory.cs
- GeneralTransform3D.cs
- ConstructorArgumentAttribute.cs
- QueryAccessibilityHelpEvent.cs
- WindowsComboBox.cs
- XPathSingletonIterator.cs
- DynamicILGenerator.cs
- wpf-etw.cs
- SetStoryboardSpeedRatio.cs
- Not.cs
- SymbolType.cs
- DiscoveryViaBehavior.cs
- ObjectTag.cs
- XmlDownloadManager.cs
- Preprocessor.cs
- ObjectTypeMapping.cs
- AutomationPeer.cs
- AssertSection.cs
- AspCompat.cs
- ErrorStyle.cs
- EllipticalNodeOperations.cs
- DataGridHeaderBorder.cs
- ValueQuery.cs
- Frame.cs
- FilterQuery.cs
- CodeVariableDeclarationStatement.cs
- CodeTypeReferenceCollection.cs
- SmiEventStream.cs
- EventLogPermission.cs
- HistoryEventArgs.cs
- SelectorItemAutomationPeer.cs
- MouseActionValueSerializer.cs
- XmlQualifiedNameTest.cs
- TopClause.cs
- SurrogateEncoder.cs
- OutputScope.cs
- MasterPage.cs
- TextEditorCharacters.cs
- SingleAnimationUsingKeyFrames.cs
- PeekCompletedEventArgs.cs
- InstanceCreationEditor.cs
- GPStream.cs
- SafeNativeMethods.cs
- MetadataUtilsSmi.cs
- TypeCacheManager.cs
- BinaryOperationBinder.cs
- XmlQueryType.cs
- SchemaConstraints.cs
- CallContext.cs
- SqlDataSourceSelectingEventArgs.cs
- XmlValidatingReader.cs
- UnmanagedBitmapWrapper.cs
- OAVariantLib.cs
- ErasingStroke.cs
- TextElement.cs
- SAPICategories.cs
- PrefixHandle.cs
- GuidTagList.cs
- PersistenceTypeAttribute.cs
- TabControlToolboxItem.cs
- WebPartsPersonalizationAuthorization.cs
- Renderer.cs
- DbDataReader.cs
- Permission.cs
- AppliedDeviceFiltersDialog.cs
- PrimitiveRenderer.cs
- XmlSchemaSubstitutionGroup.cs
- ConcurrentStack.cs
- AdornerDecorator.cs
- PeerCollaboration.cs
- FilterQuery.cs