Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Discovery / DiscoveryMessageSequence.cs / 1305376 / DiscoveryMessageSequence.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.ServiceModel.Discovery { using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime; using System.Xml; using SR2 = System.ServiceModel.Discovery.SR; [Fx.Tag.XamlVisible(false)] [SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes")] public class DiscoveryMessageSequence : IComparable, IEquatable { internal DiscoveryMessageSequence() { } internal DiscoveryMessageSequence(long instanceId, Uri sequenceId, long messageNumber) { Fx.Assert((instanceId >= 0) && (instanceId <= UInt32.MaxValue), "The instanceId must be within UInt32 range"); Fx.Assert((messageNumber >= 0) && (messageNumber <= UInt32.MaxValue), "The messageNumber must be within UInt32 range"); this.InstanceId = instanceId; this.SequenceId = sequenceId; this.MessageNumber = messageNumber; } public long InstanceId { get; private set; } public Uri SequenceId { get; private set; } public long MessageNumber { get; private set; } public static bool operator ==(DiscoveryMessageSequence messageSequence1, DiscoveryMessageSequence messageSequence2) { if (object.ReferenceEquals(messageSequence1, null) && object.ReferenceEquals(messageSequence2, null)) { return true; } if (object.ReferenceEquals(messageSequence1, null) || object.ReferenceEquals(messageSequence2, null)) { return false; } return messageSequence1.Equals(messageSequence2); } public static bool operator !=(DiscoveryMessageSequence messageSequence1, DiscoveryMessageSequence messageSequence2) { return !(messageSequence1 == messageSequence2); } public override bool Equals(object obj) { DiscoveryMessageSequence other = obj as DiscoveryMessageSequence; return this.Equals(other); } public bool Equals(DiscoveryMessageSequence other) { if (object.ReferenceEquals(other, null)) { return false; } if (object.ReferenceEquals(this, other)) { return true; } return (long.Equals(this.InstanceId, other.InstanceId) && Uri.Equals(this.SequenceId, other.SequenceId) && long.Equals(this.MessageNumber, other.MessageNumber)); } public override string ToString() { return SR.DiscoveryMessageSequenceToString(this.InstanceId, this.SequenceId, this.MessageNumber); } public bool CanCompareTo(DiscoveryMessageSequence other) { if (object.ReferenceEquals(other, null)) { return false; } else { return ((this.InstanceId != other.InstanceId) || (Uri.Equals(this.SequenceId, other.SequenceId))); } } public override int GetHashCode() { return string.Format( CultureInfo.InvariantCulture, "{0}:{1}:{2}", this.InstanceId, this.SequenceId, this.MessageNumber).GetHashCode(); } public int CompareTo(DiscoveryMessageSequence other) { if (object.ReferenceEquals(other, null)) { throw FxTrace.Exception.ArgumentNull("other"); } int result = this.InstanceId.CompareTo(other.InstanceId); if (result == 0) { if (!Uri.Equals(this.SequenceId, other.SequenceId)) { throw FxTrace.Exception.Argument("other", SR2.DiscoveryIncompatibleMessageSequence); } result = this.MessageNumber.CompareTo(other.MessageNumber); } return result; } [Fx.Tag.Throws(typeof(XmlException), "throws on incorrect xml data")] internal void ReadFrom(XmlReader reader) { if (reader == null) { throw FxTrace.Exception.ArgumentNull("reader"); } string instanceIdString = reader.GetAttribute(ProtocolStrings.SchemaNames.AppSequenceInstanceId); this.InstanceId = SerializationUtility.ReadUInt( instanceIdString, SR2.DiscoveryXmlMissingAppSequenceInstanceId, SR2.DiscoveryXmlInvalidAppSequenceInstanceId); string sequenceIdString = reader.GetAttribute(ProtocolStrings.SchemaNames.AppSequenceSequenceId); if (sequenceIdString != null) { try { this.SequenceId = new Uri(sequenceIdString, UriKind.RelativeOrAbsolute); } catch (FormatException fe) { throw FxTrace.Exception.AsError(new XmlException(SR2.DiscoveryXmlUriFormatError(sequenceIdString), fe)); } } string messageNumberString = reader.GetAttribute(ProtocolStrings.SchemaNames.AppSequenceMessageNumber); this.MessageNumber = SerializationUtility.ReadUInt( messageNumberString, SR2.DiscoveryXmlMissingAppSequenceMessageNumber, SR2.DiscoveryXmlInvalidAppSequenceMessageNumber); } internal void WriteTo(XmlWriter writer) { if (writer == null) { throw FxTrace.Exception.ArgumentNull("writer"); } writer.WriteAttributeString( ProtocolStrings.SchemaNames.AppSequenceInstanceId, this.InstanceId.ToString(CultureInfo.InvariantCulture)); if (this.SequenceId != null) { writer.WriteAttributeString( ProtocolStrings.SchemaNames.AppSequenceSequenceId, this.SequenceId.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped)); } writer.WriteAttributeString( ProtocolStrings.SchemaNames.AppSequenceMessageNumber, this.MessageNumber.ToString(CultureInfo.InvariantCulture)); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ServiceModelActivity.cs
- ECDiffieHellmanCngPublicKey.cs
- IPEndPointCollection.cs
- wmiprovider.cs
- ThrowHelper.cs
- FontSource.cs
- GatewayIPAddressInformationCollection.cs
- SponsorHelper.cs
- ExpandSegment.cs
- DataGridViewCellValidatingEventArgs.cs
- SelectionListComponentEditor.cs
- InheritanceUI.cs
- MethodRental.cs
- ChangeBlockUndoRecord.cs
- WindowsPrincipal.cs
- QilTargetType.cs
- SecurityTimestamp.cs
- SmiTypedGetterSetter.cs
- ToggleButton.cs
- FileLevelControlBuilderAttribute.cs
- ADRoleFactory.cs
- PaintValueEventArgs.cs
- ValidatingPropertiesEventArgs.cs
- CommandID.cs
- DataTable.cs
- CompressStream.cs
- CompilerTypeWithParams.cs
- NamespaceInfo.cs
- ClientConfigurationHost.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- HttpDictionary.cs
- TextRangeEditTables.cs
- SortedSetDebugView.cs
- ApplicationManager.cs
- ConnectionManagementElement.cs
- ToolStripItemClickedEventArgs.cs
- DataGridColumnCollection.cs
- ElementsClipboardData.cs
- AutomationPropertyInfo.cs
- SuppressIldasmAttribute.cs
- DataSourceHelper.cs
- NameValuePermission.cs
- CodePageEncoding.cs
- PeerName.cs
- ProcessHostServerConfig.cs
- SkewTransform.cs
- GeometryHitTestResult.cs
- StreamWithDictionary.cs
- WpfMemberInvoker.cs
- Html32TextWriter.cs
- AliasGenerator.cs
- Compilation.cs
- DiscoveryClientDuplexChannel.cs
- Win32Exception.cs
- Command.cs
- ProvidePropertyAttribute.cs
- IChannel.cs
- _NativeSSPI.cs
- EntityDesignerBuildProvider.cs
- DataSetSchema.cs
- DiagnosticEventProvider.cs
- HScrollBar.cs
- GeometryConverter.cs
- WebPartRestoreVerb.cs
- UnionExpr.cs
- HttpModuleActionCollection.cs
- LexicalChunk.cs
- CqlErrorHelper.cs
- ProcessActivityTreeOptions.cs
- OptimisticConcurrencyException.cs
- DataGridViewCellStyleConverter.cs
- NumberSubstitution.cs
- CodeFieldReferenceExpression.cs
- versioninfo.cs
- HierarchicalDataSourceIDConverter.cs
- UnsafeNativeMethods.cs
- Asn1Utilities.cs
- SpeakProgressEventArgs.cs
- MailAddressCollection.cs
- MaskDescriptor.cs
- PageThemeBuildProvider.cs
- SizeFConverter.cs
- Attachment.cs
- remotingproxy.cs
- NumberSubstitution.cs
- XmlSchemaAttributeGroupRef.cs
- ValueSerializer.cs
- BackStopAuthenticationModule.cs
- _Connection.cs
- SafeSecurityHandles.cs
- Object.cs
- QilXmlWriter.cs
- SqlDataSourceConfigureSelectPanel.cs
- GestureRecognizer.cs
- DataGridViewCell.cs
- FieldNameLookup.cs
- mediaeventargs.cs
- XmlWriterTraceListener.cs
- HitTestWithPointDrawingContextWalker.cs
- BasePattern.cs