Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Discovery / ResolveRequestResponseAsyncResult.cs / 1305376 / ResolveRequestResponseAsyncResult.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.ServiceModel.Discovery { using System.Diagnostics.CodeAnalysis; using System.Runtime; abstract class ResolveRequestResponseAsyncResult: AsyncResult { readonly ResolveCriteria resolveCriteria; readonly IDiscoveryServiceImplementation discoveryServiceImpl; readonly DiscoveryOperationContext context; static AsyncCompletion onOnResolveCompletedCallback = new AsyncCompletion(OnOnResolveCompleted); EndpointDiscoveryMetadata matchingEndpoint; [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] protected ResolveRequestResponseAsyncResult( TResolveMessage resolveMessage, IDiscoveryServiceImplementation discoveryServiceImpl, AsyncCallback callback, object state) : base(callback, state) { Fx.Assert(resolveMessage != null, "The resolveMessage must be non null."); Fx.Assert(discoveryServiceImpl != null, "The discoveryServiceImpl must be non null."); this.discoveryServiceImpl = discoveryServiceImpl; if (!this.Validate(resolveMessage)) { this.Complete(true); return; } else { this.context = new DiscoveryOperationContext(OperationContext.Current); this.resolveCriteria = this.GetResolveCriteria(resolveMessage); if (this.ProcessResolveRequest()) { this.Complete(true); return; } } } protected virtual bool Validate(TResolveMessage resolveMessage) { return (DiscoveryService.EnsureMessageId() && this.ValidateContent(resolveMessage) && this.EnsureNotDuplicate()); } protected abstract bool ValidateContent(TResolveMessage resolveMessage); protected abstract ResolveCriteria GetResolveCriteria(TResolveMessage resolveMessage); protected abstract TResponseMessage GetResolveResponse( DiscoveryMessageSequence discoveryMessageSequence, EndpointDiscoveryMetadata matchingEndpoints); protected TResponseMessage End() { this.context.AddressRequestResponseMessage(OperationContext.Current); return this.GetResolveResponse( this.discoveryServiceImpl.GetNextMessageSequence(), this.matchingEndpoint); } static bool OnOnResolveCompleted(IAsyncResult result) { ResolveRequestResponseAsyncResult thisPtr = (ResolveRequestResponseAsyncResult )result.AsyncState; thisPtr.matchingEndpoint = thisPtr.discoveryServiceImpl.EndResolve(result); return true; } bool ProcessResolveRequest() { IAsyncResult result = this.discoveryServiceImpl.BeginResolve( this.resolveCriteria, this.PrepareAsyncCompletion(onOnResolveCompletedCallback), this); return (result.CompletedSynchronously && OnOnResolveCompleted(result)); } bool EnsureNotDuplicate() { bool isDuplicate = this.discoveryServiceImpl.IsDuplicate(OperationContext.Current.IncomingMessageHeaders.MessageId); if (isDuplicate && TD.DuplicateDiscoveryMessageIsEnabled()) { TD.DuplicateDiscoveryMessage( ProtocolStrings.TracingStrings.Resolve, OperationContext.Current.IncomingMessageHeaders.MessageId.ToString()); } return !isDuplicate; } } } // 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
- XmlMemberMapping.cs
- MenuItemStyleCollection.cs
- PaperSize.cs
- InfoCardTrace.cs
- BuiltInExpr.cs
- BinarySerializer.cs
- ImmutableCollection.cs
- EqualityComparer.cs
- TreeView.cs
- TemplateColumn.cs
- Int32Rect.cs
- Storyboard.cs
- Style.cs
- ConsoleEntryPoint.cs
- TextHidden.cs
- HtmlContainerControl.cs
- MergeFilterQuery.cs
- FamilyMap.cs
- FixUpCollection.cs
- XmlCharacterData.cs
- WebPartExportVerb.cs
- MachinePropertyVariants.cs
- TraceUtility.cs
- HMACSHA256.cs
- TypeExtensions.cs
- Padding.cs
- DecimalMinMaxAggregationOperator.cs
- CodeDomConfigurationHandler.cs
- ProgressBar.cs
- DeviceContext2.cs
- ResourceDescriptionAttribute.cs
- Errors.cs
- NamedElement.cs
- DefaultExpressionVisitor.cs
- FontUnitConverter.cs
- DecimalKeyFrameCollection.cs
- SystemParameters.cs
- ManagementClass.cs
- AnnotationResource.cs
- TextServicesDisplayAttributePropertyRanges.cs
- DbgCompiler.cs
- ViewUtilities.cs
- PrimitiveSchema.cs
- RecordConverter.cs
- HostProtectionException.cs
- IntSumAggregationOperator.cs
- Vector3DKeyFrameCollection.cs
- ClientScriptManager.cs
- PathNode.cs
- PathNode.cs
- ErrorInfoXmlDocument.cs
- AvTraceFormat.cs
- CodeParameterDeclarationExpression.cs
- PointHitTestParameters.cs
- DeflateStream.cs
- HttpStaticObjectsCollectionWrapper.cs
- Select.cs
- ConstructorBuilder.cs
- Message.cs
- DES.cs
- ReadContentAsBinaryHelper.cs
- ConsumerConnectionPointCollection.cs
- BuilderElements.cs
- ListViewDataItem.cs
- ImageDrawing.cs
- ProjectionPruner.cs
- WebBrowserUriTypeConverter.cs
- SelectedGridItemChangedEvent.cs
- Visual3D.cs
- QueryStoreStatusRequest.cs
- XmlQueryStaticData.cs
- Qualifier.cs
- KnowledgeBase.cs
- SafeArrayRankMismatchException.cs
- ListChangedEventArgs.cs
- DrawingGroupDrawingContext.cs
- iisPickupDirectory.cs
- SchemaName.cs
- JpegBitmapDecoder.cs
- WebPartCancelEventArgs.cs
- SmiEventSink_DeferedProcessing.cs
- WhileDesigner.xaml.cs
- WebPartAuthorizationEventArgs.cs
- CodeTypeDelegate.cs
- DispatchChannelSink.cs
- FormViewUpdateEventArgs.cs
- SerializationFieldInfo.cs
- XmlValidatingReaderImpl.cs
- BitmapEffectInputData.cs
- XmlWhitespace.cs
- NamedPermissionSet.cs
- DocumentReferenceCollection.cs
- AutoResizedEvent.cs
- EntityDataSourceWrapper.cs
- HebrewCalendar.cs
- TemplateControlCodeDomTreeGenerator.cs
- EventLog.cs
- StrongNameUtility.cs
- BasicKeyConstraint.cs
- EdmSchemaError.cs