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
- NameValueConfigurationElement.cs
- UntypedNullExpression.cs
- RectIndependentAnimationStorage.cs
- DetailsViewUpdatedEventArgs.cs
- DefaultValueMapping.cs
- AutoScrollHelper.cs
- TiffBitmapDecoder.cs
- PixelShader.cs
- GAC.cs
- smtppermission.cs
- SqlMethods.cs
- InvariantComparer.cs
- ObjRef.cs
- BinaryUtilClasses.cs
- SystemColors.cs
- UndoUnit.cs
- InternalBufferOverflowException.cs
- InternalCache.cs
- AnimationTimeline.cs
- QilCloneVisitor.cs
- ResourceManager.cs
- DataSourceConverter.cs
- UpdatePanel.cs
- PerformanceCounterManager.cs
- XmlFormatReaderGenerator.cs
- dataprotectionpermission.cs
- EFTableProvider.cs
- GenerateTemporaryTargetAssembly.cs
- CodePrimitiveExpression.cs
- Logging.cs
- AnimatedTypeHelpers.cs
- DataGridViewRowsRemovedEventArgs.cs
- Monitor.cs
- GeometryConverter.cs
- LedgerEntryCollection.cs
- Image.cs
- InvokeHandlers.cs
- PreviewPrintController.cs
- IDReferencePropertyAttribute.cs
- RegistryPermission.cs
- ObjectDataSourceView.cs
- SetMemberBinder.cs
- Point3D.cs
- ForEachAction.cs
- DataRelationCollection.cs
- CreateParams.cs
- DiscoveryClientReferences.cs
- CodeBinaryOperatorExpression.cs
- FilterableData.cs
- XmlSchemaComplexContent.cs
- Rectangle.cs
- RangeContentEnumerator.cs
- CacheOutputQuery.cs
- EntityException.cs
- SafeIUnknown.cs
- TemplateColumn.cs
- FrameworkTemplate.cs
- ChannelServices.cs
- DataBindingExpressionBuilder.cs
- CustomTypeDescriptor.cs
- SmtpNegotiateAuthenticationModule.cs
- XmlWrappingReader.cs
- EntityDataSourceDataSelectionPanel.cs
- FormsAuthenticationTicket.cs
- mactripleDES.cs
- UnionExpr.cs
- ClaimTypeElementCollection.cs
- RegexEditorDialog.cs
- Array.cs
- ApplicationFileParser.cs
- DataKeyArray.cs
- ServiceModelEnumValidator.cs
- StringArrayEditor.cs
- FilterUserControlBase.cs
- XmlConvert.cs
- PageCodeDomTreeGenerator.cs
- LocalBuilder.cs
- WebDescriptionAttribute.cs
- ClientType.cs
- configsystem.cs
- XmlEventCache.cs
- LostFocusEventManager.cs
- StatusBar.cs
- ProtocolsSection.cs
- IdnMapping.cs
- InvokeProviderWrapper.cs
- PerfCounters.cs
- SignatureDescription.cs
- namescope.cs
- PaginationProgressEventArgs.cs
- FormViewDeletedEventArgs.cs
- CodeExporter.cs
- WindowsSolidBrush.cs
- ProvideValueServiceProvider.cs
- Filter.cs
- BaseInfoTable.cs
- TabPage.cs
- TypedAsyncResult.cs
- MobilePage.cs
- TrackBar.cs