Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / LocalService / MessageQueueKey.cs / 1305376 / MessageQueueKey.cs
#pragma warning disable 1634, 1691 //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- using System; using System.Text; using System.Workflow.ComponentModel; using System.Collections; using System.Collections.Generic; using System.Workflow.Runtime; namespace System.Workflow.Activities { [Serializable] public sealed class EventQueueName : IComparable { Type interfaceType; string operation; CorrelationProperty[] correlationValues; string activityId; [NonSerialized] string assemblyQualifiedName; [NonSerialized] String stringifiedKey; private string AssemblyQualifiedName { get { if (assemblyQualifiedName == null) { assemblyQualifiedName = this.interfaceType.AssemblyQualifiedName; } return assemblyQualifiedName; } } public EventQueueName(Type interfaceType, string operation) { if (interfaceType == null) throw new ArgumentNullException("interfaceType"); if (operation == null) throw new ArgumentNullException("operation"); this.interfaceType = interfaceType; this.operation = operation; } public EventQueueName(Type interfaceType, string operation, ICollectionpropertyValues) : this(interfaceType, operation) { if (propertyValues != null) { this.correlationValues = new CorrelationProperty[propertyValues.Count]; propertyValues.CopyTo(this.correlationValues,0); } } internal EventQueueName(Type interfaceType, string operation, string activityId) : this(interfaceType, operation) { this.activityId = activityId; } // properties public Type InterfaceType { get { return this.interfaceType; } } public string MethodName { get { return this.operation; } } public CorrelationProperty[] GetCorrelationValues() { return this.correlationValues; } public int CompareTo(Object toCompare) { if (toCompare is EventQueueName) return this.CompareTo(toCompare as EventQueueName); else return -1; } // IComparable implementation public int CompareTo(EventQueueName eventQueueName) { if (eventQueueName == null) return -1; // compare operation int compared = StringComparer.Ordinal.Compare(this.MethodName, eventQueueName.MethodName); if (compared == 0) { // compare type names #pragma warning disable 56506 compared = StringComparer.Ordinal.Compare(AssemblyQualifiedName, eventQueueName.AssemblyQualifiedName); ; #pragma warning restore 56506 if (compared == 0) { if (this.correlationValues != null) { compared = (eventQueueName.correlationValues != null) ? (this.correlationValues.Length - eventQueueName.correlationValues.Length) : -1; if (compared == 0) { // compare correlation values for (int i = 0; i < this.correlationValues.Length; i++) { if (this.correlationValues[i] == null || eventQueueName.correlationValues[i] == null) { compared = -1; break; // match failed } object leftValue = this.correlationValues[i].Value; object rightValue = FindCorrelationValue(this.correlationValues[i].Name, eventQueueName.correlationValues); #pragma warning suppress 56506 if (leftValue == null && rightValue == null) { continue; } // do the explicit equals check if (leftValue != null) { IComparable comparable = leftValue as IComparable; if (comparable != null) { compared = comparable.CompareTo(rightValue); if (compared != 0) { break; // match failed } } else if ((!leftValue.Equals(rightValue))) { compared = -1; break; // match failed } } else { compared = -1; break; // match failed } } } } } } return compared; } public override bool Equals(object obj) { EventQueueName k = obj as EventQueueName; //Without the cast we end up in op_Equality below if ((object) k == null) return false; return 0 == CompareTo(k); } public static bool operator ==(EventQueueName queueKey1, EventQueueName queueKey2) { bool equality = false; if ((object)queueKey1 != null) { if ((object)queueKey2 != null) { equality = (0 == queueKey1.CompareTo(queueKey2)); } } else if ((object)queueKey2 == null) { equality = true; } return equality; } public static bool operator !=(EventQueueName queueKey1, EventQueueName queueKey2) { return !(queueKey1 == queueKey2); } public static bool operator <(EventQueueName queueKey1, EventQueueName queueKey2) { if (queueKey1 == null) throw new ArgumentNullException("queueKey1"); if (queueKey2 == null) throw new ArgumentNullException("queueKey2"); return (queueKey1.CompareTo(queueKey2) < 0); } public static bool operator >(EventQueueName queueKey1, EventQueueName queueKey2) { if (queueKey1 == null) throw new ArgumentNullException("queueKey1"); if (queueKey2 == null) throw new ArgumentNullException("queueKey2"); return (queueKey1.CompareTo(queueKey2) > 0); } public override int GetHashCode() { if (String.IsNullOrEmpty(this.activityId)) return (AssemblyQualifiedName.GetHashCode() ^ this.operation.GetHashCode()); return (AssemblyQualifiedName.GetHashCode() ^ this.operation.GetHashCode() ^ this.activityId.GetHashCode()) ; } public override string ToString() { if (stringifiedKey == null) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Message Properties"); stringBuilder.AppendLine("Interface Type:" + this.interfaceType.ToString()); stringBuilder.AppendLine("Method Name:" + this.operation.ToString()); stringBuilder.AppendLine("CorrelationValues:"); if (correlationValues != null) { foreach (CorrelationProperty pred in correlationValues) { if (pred != null && pred.Value != null) stringBuilder.AppendLine(pred.Value.ToString()); } } stringifiedKey = stringBuilder.ToString(); } return stringifiedKey; } object FindCorrelationValue(string name, CorrelationProperty[] correlationValues) { object value = null; foreach (CorrelationProperty property in correlationValues) { if (property != null && property.Name == name) { value = property.Value; break; } } return value; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. #pragma warning disable 1634, 1691 //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- using System; using System.Text; using System.Workflow.ComponentModel; using System.Collections; using System.Collections.Generic; using System.Workflow.Runtime; namespace System.Workflow.Activities { [Serializable] public sealed class EventQueueName : IComparable { Type interfaceType; string operation; CorrelationProperty[] correlationValues; string activityId; [NonSerialized] string assemblyQualifiedName; [NonSerialized] String stringifiedKey; private string AssemblyQualifiedName { get { if (assemblyQualifiedName == null) { assemblyQualifiedName = this.interfaceType.AssemblyQualifiedName; } return assemblyQualifiedName; } } public EventQueueName(Type interfaceType, string operation) { if (interfaceType == null) throw new ArgumentNullException("interfaceType"); if (operation == null) throw new ArgumentNullException("operation"); this.interfaceType = interfaceType; this.operation = operation; } public EventQueueName(Type interfaceType, string operation, ICollection propertyValues) : this(interfaceType, operation) { if (propertyValues != null) { this.correlationValues = new CorrelationProperty[propertyValues.Count]; propertyValues.CopyTo(this.correlationValues,0); } } internal EventQueueName(Type interfaceType, string operation, string activityId) : this(interfaceType, operation) { this.activityId = activityId; } // properties public Type InterfaceType { get { return this.interfaceType; } } public string MethodName { get { return this.operation; } } public CorrelationProperty[] GetCorrelationValues() { return this.correlationValues; } public int CompareTo(Object toCompare) { if (toCompare is EventQueueName) return this.CompareTo(toCompare as EventQueueName); else return -1; } // IComparable implementation public int CompareTo(EventQueueName eventQueueName) { if (eventQueueName == null) return -1; // compare operation int compared = StringComparer.Ordinal.Compare(this.MethodName, eventQueueName.MethodName); if (compared == 0) { // compare type names #pragma warning disable 56506 compared = StringComparer.Ordinal.Compare(AssemblyQualifiedName, eventQueueName.AssemblyQualifiedName); ; #pragma warning restore 56506 if (compared == 0) { if (this.correlationValues != null) { compared = (eventQueueName.correlationValues != null) ? (this.correlationValues.Length - eventQueueName.correlationValues.Length) : -1; if (compared == 0) { // compare correlation values for (int i = 0; i < this.correlationValues.Length; i++) { if (this.correlationValues[i] == null || eventQueueName.correlationValues[i] == null) { compared = -1; break; // match failed } object leftValue = this.correlationValues[i].Value; object rightValue = FindCorrelationValue(this.correlationValues[i].Name, eventQueueName.correlationValues); #pragma warning suppress 56506 if (leftValue == null && rightValue == null) { continue; } // do the explicit equals check if (leftValue != null) { IComparable comparable = leftValue as IComparable; if (comparable != null) { compared = comparable.CompareTo(rightValue); if (compared != 0) { break; // match failed } } else if ((!leftValue.Equals(rightValue))) { compared = -1; break; // match failed } } else { compared = -1; break; // match failed } } } } } } return compared; } public override bool Equals(object obj) { EventQueueName k = obj as EventQueueName; //Without the cast we end up in op_Equality below if ((object) k == null) return false; return 0 == CompareTo(k); } public static bool operator ==(EventQueueName queueKey1, EventQueueName queueKey2) { bool equality = false; if ((object)queueKey1 != null) { if ((object)queueKey2 != null) { equality = (0 == queueKey1.CompareTo(queueKey2)); } } else if ((object)queueKey2 == null) { equality = true; } return equality; } public static bool operator !=(EventQueueName queueKey1, EventQueueName queueKey2) { return !(queueKey1 == queueKey2); } public static bool operator <(EventQueueName queueKey1, EventQueueName queueKey2) { if (queueKey1 == null) throw new ArgumentNullException("queueKey1"); if (queueKey2 == null) throw new ArgumentNullException("queueKey2"); return (queueKey1.CompareTo(queueKey2) < 0); } public static bool operator >(EventQueueName queueKey1, EventQueueName queueKey2) { if (queueKey1 == null) throw new ArgumentNullException("queueKey1"); if (queueKey2 == null) throw new ArgumentNullException("queueKey2"); return (queueKey1.CompareTo(queueKey2) > 0); } public override int GetHashCode() { if (String.IsNullOrEmpty(this.activityId)) return (AssemblyQualifiedName.GetHashCode() ^ this.operation.GetHashCode()); return (AssemblyQualifiedName.GetHashCode() ^ this.operation.GetHashCode() ^ this.activityId.GetHashCode()) ; } public override string ToString() { if (stringifiedKey == null) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Message Properties"); stringBuilder.AppendLine("Interface Type:" + this.interfaceType.ToString()); stringBuilder.AppendLine("Method Name:" + this.operation.ToString()); stringBuilder.AppendLine("CorrelationValues:"); if (correlationValues != null) { foreach (CorrelationProperty pred in correlationValues) { if (pred != null && pred.Value != null) stringBuilder.AppendLine(pred.Value.ToString()); } } stringifiedKey = stringBuilder.ToString(); } return stringifiedKey; } object FindCorrelationValue(string name, CorrelationProperty[] correlationValues) { object value = null; foreach (CorrelationProperty property in correlationValues) { if (property != null && property.Name == name) { value = property.Value; break; } } return value; } } } // 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
- SessionPageStateSection.cs
- ConstrainedDataObject.cs
- DataRowView.cs
- ConnectionManagementSection.cs
- TemplateBindingExpression.cs
- ControlBuilder.cs
- SyndicationSerializer.cs
- CreateUserWizardDesigner.cs
- CountdownEvent.cs
- ColorConvertedBitmap.cs
- GridViewRow.cs
- BindingMemberInfo.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- DataColumnChangeEvent.cs
- CharEntityEncoderFallback.cs
- Converter.cs
- ListItemParagraph.cs
- AbandonedMutexException.cs
- UnknownWrapper.cs
- DataTemplate.cs
- WebReferencesBuildProvider.cs
- SQLByte.cs
- SqlRowUpdatedEvent.cs
- FtpCachePolicyElement.cs
- StylusSystemGestureEventArgs.cs
- MonthCalendar.cs
- httpapplicationstate.cs
- OdbcDataReader.cs
- IntSecurity.cs
- ForeignConstraint.cs
- PeerName.cs
- RankException.cs
- EncoderExceptionFallback.cs
- RangeExpression.cs
- EtwTrace.cs
- WebPartConnectionsCancelEventArgs.cs
- StreamSecurityUpgradeInitiator.cs
- SystemInformation.cs
- FieldDescriptor.cs
- UIElement.cs
- DataTransferEventArgs.cs
- XmlChildEnumerator.cs
- DataSourceXmlSerializer.cs
- SqlConnectionStringBuilder.cs
- CompilationUnit.cs
- ScriptMethodAttribute.cs
- SqlBooleanizer.cs
- MetadataItemEmitter.cs
- PromptStyle.cs
- XmlNodeComparer.cs
- AxHost.cs
- ClickablePoint.cs
- ObjectAnimationBase.cs
- PerformanceCounterPermissionAttribute.cs
- SecurityToken.cs
- CollectionMarkupSerializer.cs
- ArgumentReference.cs
- BaseTemplateCodeDomTreeGenerator.cs
- Bitmap.cs
- InternalResources.cs
- GreenMethods.cs
- AutomationIdentifierGuids.cs
- NameNode.cs
- AsyncContentLoadedEventArgs.cs
- RightNameExpirationInfoPair.cs
- DataRelation.cs
- TagMapInfo.cs
- DbConnectionPoolCounters.cs
- TemplateContentLoader.cs
- Util.cs
- ThreadExceptionEvent.cs
- PenLineCapValidation.cs
- IgnoreSectionHandler.cs
- TextElementCollection.cs
- InkCollectionBehavior.cs
- LogWriteRestartAreaState.cs
- EditorPart.cs
- StylusOverProperty.cs
- WCFModelStrings.Designer.cs
- SBCSCodePageEncoding.cs
- WebPartMovingEventArgs.cs
- EntityDataSourceState.cs
- QueryResults.cs
- GridViewAutoFormat.cs
- OleDbSchemaGuid.cs
- SchemaContext.cs
- DbException.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- DataBoundControlParameterTarget.cs
- ObjectStateManager.cs
- ConnectionStringSettingsCollection.cs
- ExceptionUtility.cs
- VariableExpressionConverter.cs
- ElementsClipboardData.cs
- DynamicPropertyHolder.cs
- EventDescriptor.cs
- HtmlFormWrapper.cs
- LogPolicy.cs
- XmlCharCheckingWriter.cs
- SignedXml.cs