Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Protocol / ProtocolInformationReader.cs / 1 / ProtocolInformationReader.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // Define the class that knows how to deserialize WS-AT protocol information using System; using System.IO; using System.Net; using Microsoft.Transactions.Wsat.Recovery; using DiagnosticUtility = Microsoft.Transactions.Bridge.DiagnosticUtility; namespace Microsoft.Transactions.Wsat.Protocol { class ProtocolInformationReader { int httpsPort; string hostName; string nodeName; string basePath; TimeSpan maxTimeout; ProtocolInformationFlags flags; public ProtocolInformationReader(MemoryStream mem) { ReadProtocolInformation(mem); } public int HttpsPort { get { return this.httpsPort; } } public string HostName { get { return this.hostName; } } public string NodeName { get { return this.nodeName; } } public string BasePath { get { return this.basePath; } } public TimeSpan MaxTimeout { get { return this.maxTimeout; } } public bool IssuedTokensEnabled { get { return (flags & ProtocolInformationFlags.IssuedTokensEnabled) != 0; } } public bool NetworkInboundAccess { get { return (flags & ProtocolInformationFlags.NetworkInboundAccess) != 0; } } public bool NetworkOutboundAccess { get { return (flags & ProtocolInformationFlags.NetworkOutboundAccess) != 0; } } public bool NetworkClientAccess { get { return (flags & ProtocolInformationFlags.NetworkClientAccess) != 0; } } public bool IsClustered { get { return (flags & ProtocolInformationFlags.IsClustered) != 0; } } bool isV10Enabled = false; public bool IsV10Enabled { get { return this.isV10Enabled; } } bool isV11Enabled = false; public bool IsV11Enabled { get { return this.isV11Enabled; } } void ReadProtocolInformation(MemoryStream mem) { // We assume that all extended whereabouts emitted under the PluggableProtocol guids for versions // 1.0 or 1.1 start with the following set of data (version 1.1) // { version(major,minor), flags, httpsPort, maxTimeout, hostName, basePath, nodeName } // Read major version ProtocolInformationMajorVersion version = (ProtocolInformationMajorVersion)mem.ReadByte(); if (version != ProtocolInformationMajorVersion.v1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SerializationException(SR.GetString(SR.ProtocolInfoUnsupportedVersion, version))); } // Read minor version // We don't assert the minor version. In the future, by incrementing the minor version, we will be able // to maintain compatibility while adding new information onto the end of the stream ProtocolInformationMinorVersion minorVersion = (ProtocolInformationMinorVersion)mem.ReadByte(); // Begin reading protocol info version 1.1 // Flags this.flags = (ProtocolInformationFlags)mem.ReadByte(); CheckFlags(this.flags); // Https port this.httpsPort = SerializationUtils.ReadInt(mem); if (this.httpsPort < IPEndPoint.MinPort || this.httpsPort > IPEndPoint.MaxPort) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SerializationException(SR.GetString(SR.ProtocolInfoInvalidHttpsPort, this.httpsPort))); } // Max timeout this.maxTimeout = SerializationUtils.ReadTimeout(mem); if (this.maxTimeout < TimeSpan.Zero) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SerializationException(SR.GetString(SR.ProtocolInfoInvalidMaxTimeout, this.maxTimeout))); } // HostName this.hostName = SerializationUtils.ReadString(mem); if (string.IsNullOrEmpty(this.hostName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SerializationException(SR.GetString(SR.ProtocolInfoInvalidHostName))); } // BasePath this.basePath = SerializationUtils.ReadString(mem); if (string.IsNullOrEmpty(this.basePath)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SerializationException(SR.GetString(SR.ProtocolInfoInvalidBasePath))); } // NodeName this.nodeName = SerializationUtils.ReadString(mem); if (string.IsNullOrEmpty(this.nodeName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SerializationException(SR.GetString(SR.ProtocolInfoInvalidNodeName))); } // End of version 1.1 // We assume that all minor versions >= than 2 whereabouts have a short field describing the // supported protocol versions byte minMinorVersion = 2; if((byte)minorVersion >= minMinorVersion) { ProtocolVersion supportedProtocols = (ProtocolVersion)SerializationUtils.ReadUShort(mem); // check if coordinator supports WSAT 1.0 if ((supportedProtocols & ProtocolVersion.Version10) != 0) { this.isV10Enabled = true; } // check if coordinator supports WSAT 1.1 if ((supportedProtocols & ProtocolVersion.Version11) != 0) { this.isV11Enabled = true; } } else { this.isV10Enabled = true; } } void CheckFlags(ProtocolInformationFlags flags) { const ProtocolInformationFlags allFlags = ProtocolInformationFlags.IssuedTokensEnabled | ProtocolInformationFlags.NetworkClientAccess | ProtocolInformationFlags.NetworkInboundAccess | ProtocolInformationFlags.NetworkOutboundAccess | ProtocolInformationFlags.IsClustered; if ((flags | allFlags) != allFlags) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SerializationException(SR.GetString(SR.ProtocolInfoInvalidFlags, flags))); } // Either NetworkInboundAccess or NetworkOutboundAccess must be set const ProtocolInformationFlags inOutFlags = ProtocolInformationFlags.NetworkInboundAccess | ProtocolInformationFlags.NetworkOutboundAccess; if ((flags & inOutFlags) == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SerializationException(SR.GetString(SR.ProtocolInfoInvalidFlags, flags))); } } } } // 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
- XPathMultyIterator.cs
- BrowserTree.cs
- XPathPatternParser.cs
- ParseElementCollection.cs
- ApplicationFileCodeDomTreeGenerator.cs
- ResourceReferenceExpressionConverter.cs
- SyndicationSerializer.cs
- AttributeUsageAttribute.cs
- ResourceDescriptionAttribute.cs
- SoapAttributeAttribute.cs
- Properties.cs
- System.Data_BID.cs
- RegistryKey.cs
- DefaultAuthorizationContext.cs
- LabelLiteral.cs
- D3DImage.cs
- ContextStack.cs
- DrawItemEvent.cs
- Size3D.cs
- IsolatedStorageFileStream.cs
- UnsafeNativeMethodsMilCoreApi.cs
- PageFunction.cs
- ComplexTypeEmitter.cs
- IPipelineRuntime.cs
- RawStylusSystemGestureInputReport.cs
- UpdatePanelTrigger.cs
- MetadataCache.cs
- UshortList2.cs
- XamlValidatingReader.cs
- ClientRoleProvider.cs
- Inline.cs
- DbExpressionRules.cs
- HtmlTextArea.cs
- ContextBase.cs
- MatrixTransform3D.cs
- MultiTouchSystemGestureLogic.cs
- PersonalizationEntry.cs
- RadioButtonDesigner.cs
- NumericUpDownAccelerationCollection.cs
- ConnectionManagementElement.cs
- CustomErrorCollection.cs
- PartialList.cs
- BitStack.cs
- ParamArrayAttribute.cs
- OLEDB_Enum.cs
- PerfService.cs
- PropertyGridCommands.cs
- ScriptHandlerFactory.cs
- TransactionCache.cs
- Filter.cs
- Container.cs
- InputScopeAttribute.cs
- IfJoinedCondition.cs
- EdmSchemaError.cs
- CallbackValidatorAttribute.cs
- DesignTimeSiteMapProvider.cs
- WindowsStatic.cs
- TagPrefixAttribute.cs
- MessageBox.cs
- DeviceFiltersSection.cs
- TablePatternIdentifiers.cs
- GeometryModel3D.cs
- DesignerSerializationOptionsAttribute.cs
- ViewCellRelation.cs
- ExtensionFile.cs
- PasswordTextContainer.cs
- MulticastOption.cs
- BatchStream.cs
- BrowserDefinition.cs
- TextMarkerSource.cs
- MasterPage.cs
- ManipulationDelta.cs
- GeneralTransform3D.cs
- MdImport.cs
- XmlSchemaAnyAttribute.cs
- BridgeDataReader.cs
- MetadataCacheItem.cs
- Schema.cs
- HtmlInputFile.cs
- ParenthesizePropertyNameAttribute.cs
- AsmxEndpointPickerExtension.cs
- ToolStripPanelCell.cs
- RtfNavigator.cs
- DataGridViewTextBoxEditingControl.cs
- ItemList.cs
- IsolationInterop.cs
- XmlPropertyBag.cs
- GradientStop.cs
- DesigntimeLicenseContextSerializer.cs
- EditorAttribute.cs
- PathHelper.cs
- FolderBrowserDialog.cs
- StubHelpers.cs
- PersonalizationState.cs
- CompilerCollection.cs
- Effect.cs
- XmlSchemaProviderAttribute.cs
- UserControl.cs
- COM2PropertyDescriptor.cs
- OpenTypeLayout.cs