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
- cache.cs
- MexNamedPipeBindingElement.cs
- XmlSchemaProviderAttribute.cs
- ToolboxItemAttribute.cs
- BoolExpr.cs
- VirtualizedItemProviderWrapper.cs
- RNGCryptoServiceProvider.cs
- DataControlField.cs
- FormViewUpdateEventArgs.cs
- FunctionCommandText.cs
- Html32TextWriter.cs
- TrustSection.cs
- FrameDimension.cs
- DataGridViewRowEventArgs.cs
- DataGridViewColumn.cs
- EntityAdapter.cs
- XhtmlConformanceSection.cs
- RuleRefElement.cs
- RecognizerBase.cs
- DecimalConstantAttribute.cs
- DocumentGridPage.cs
- ProjectionCamera.cs
- TextShapeableCharacters.cs
- DrawingAttributes.cs
- SimpleApplicationHost.cs
- SqlClientWrapperSmiStream.cs
- HandlerBase.cs
- SmtpClient.cs
- SystemIcons.cs
- CallbackException.cs
- Stacktrace.cs
- DiscoveryReference.cs
- PageContentAsyncResult.cs
- WSSecurityOneDotOneSendSecurityHeader.cs
- OracleMonthSpan.cs
- Panel.cs
- WSSecureConversation.cs
- _AuthenticationState.cs
- XmlAnyAttributeAttribute.cs
- XmlSchemaIdentityConstraint.cs
- CommandManager.cs
- TaskbarItemInfo.cs
- ReadWriteControlDesigner.cs
- SymLanguageVendor.cs
- TextElement.cs
- SecurityElement.cs
- TypeUtil.cs
- LogConverter.cs
- HttpProfileGroupBase.cs
- ContractInstanceProvider.cs
- DataGridViewCheckBoxCell.cs
- MessageQueuePermission.cs
- TimeoutHelper.cs
- SqlCacheDependencySection.cs
- ListViewAutomationPeer.cs
- GroupJoinQueryOperator.cs
- WindowsImpersonationContext.cs
- MemberInfoSerializationHolder.cs
- TextWriterTraceListener.cs
- WorkflowNamespace.cs
- MethodBody.cs
- StrongBox.cs
- StringFreezingAttribute.cs
- MD5HashHelper.cs
- PropertyDescriptor.cs
- RegisteredExpandoAttribute.cs
- TypeUtils.cs
- CompilationLock.cs
- HwndSourceParameters.cs
- SplitContainer.cs
- ToolStripRenderEventArgs.cs
- XmlValidatingReaderImpl.cs
- Exceptions.cs
- ImageField.cs
- DesignerSerializerAttribute.cs
- CompiledQuery.cs
- UnSafeCharBuffer.cs
- ArrayEditor.cs
- WebPermission.cs
- WebPartZone.cs
- InstallerTypeAttribute.cs
- Permission.cs
- TCEAdapterGenerator.cs
- DateTimeParse.cs
- MutableAssemblyCacheEntry.cs
- EntityCommandCompilationException.cs
- LambdaCompiler.Statements.cs
- StringToken.cs
- BitmapFrameEncode.cs
- ToolboxItemCollection.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- ScrollItemProviderWrapper.cs
- DependencyPropertyAttribute.cs
- UniqueIdentifierService.cs
- FixedSOMSemanticBox.cs
- DeleteBookmarkScope.cs
- PackageStore.cs
- EditingCommands.cs
- WindowsScroll.cs
- SoapEnumAttribute.cs