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
- ProxyGenerator.cs
- HtmlTernaryTree.cs
- Trace.cs
- SqlClientMetaDataCollectionNames.cs
- XamlGridLengthSerializer.cs
- DeferrableContentConverter.cs
- ChangesetResponse.cs
- LinearQuaternionKeyFrame.cs
- FileReader.cs
- SymbolEqualComparer.cs
- GridViewCellAutomationPeer.cs
- BeginEvent.cs
- BaseComponentEditor.cs
- ChannelBinding.cs
- ValueProviderWrapper.cs
- FreezableDefaultValueFactory.cs
- ColorTransformHelper.cs
- CompressStream.cs
- SqlProviderManifest.cs
- DispatcherObject.cs
- CodeRemoveEventStatement.cs
- DefinitionUpdate.cs
- DataFieldConverter.cs
- Function.cs
- DataSourceHelper.cs
- RefType.cs
- ToolStripComboBox.cs
- RichTextBoxAutomationPeer.cs
- Oid.cs
- DataGridToolTip.cs
- MdiWindowListItemConverter.cs
- XmlUTF8TextWriter.cs
- Quad.cs
- CodeComment.cs
- XmlCompatibilityReader.cs
- SerializationStore.cs
- EncoderParameter.cs
- HttpCacheParams.cs
- SqlRowUpdatedEvent.cs
- EventRoute.cs
- RequestQueryProcessor.cs
- OdbcConnectionFactory.cs
- MetadataAssemblyHelper.cs
- webbrowsersite.cs
- MultiAsyncResult.cs
- diagnosticsswitches.cs
- propertytag.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- MonthCalendarDesigner.cs
- IsolatedStorageFileStream.cs
- HuffModule.cs
- DiscardableAttribute.cs
- LocationSectionRecord.cs
- HttpCookie.cs
- TextBox.cs
- SynchronizationLockException.cs
- ContextTokenTypeConverter.cs
- Metafile.cs
- StorageMappingItemLoader.cs
- CredentialCache.cs
- isolationinterop.cs
- ActiveXContainer.cs
- Helper.cs
- SafePEFileHandle.cs
- XmlException.cs
- BinaryParser.cs
- CalendarTable.cs
- TableRowCollection.cs
- XamlFxTrace.cs
- SequenceDesigner.xaml.cs
- DataKey.cs
- ItemsControlAutomationPeer.cs
- ItemCheckedEvent.cs
- LinkedResource.cs
- ProtectedConfiguration.cs
- IisTraceWebEventProvider.cs
- DescendantQuery.cs
- BamlRecordReader.cs
- SqlNotificationRequest.cs
- ResourceDisplayNameAttribute.cs
- XmlAnyAttributeAttribute.cs
- InputLangChangeRequestEvent.cs
- WebBrowserNavigatingEventHandler.cs
- SynchronizedCollection.cs
- TransformerTypeCollection.cs
- SplayTreeNode.cs
- AttachInfo.cs
- MediaContext.cs
- SR.cs
- HttpFileCollection.cs
- ViewStateModeByIdAttribute.cs
- TextParaLineResult.cs
- VersionedStreamOwner.cs
- ConfigXmlComment.cs
- TypeCodeDomSerializer.cs
- MetadataPropertyvalue.cs
- OperationValidationEventArgs.cs
- RoleService.cs
- SqlServices.cs
- MatchingStyle.cs