Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Discovery / ByeOperationAsyncResult.cs / 1305376 / ByeOperationAsyncResult.cs
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------
namespace System.ServiceModel.Discovery
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.Xml;
abstract class ByeOperationAsyncResult : AsyncResult
where TMessage : class
{
static AsyncCompletion onOnOfflineAnnoucementCompletedCallback =
new AsyncCompletion(OnOnOfflineAnnouncementCompleted);
IAnnouncementServiceImplementation announcementServiceImpl;
[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
internal ByeOperationAsyncResult(
IAnnouncementServiceImplementation announcementServiceImpl,
TMessage message,
AsyncCallback callback,
object state)
: base(callback, state)
{
this.announcementServiceImpl = announcementServiceImpl;
if (this.IsInvalid(message))
{
this.Complete(true);
return;
}
IAsyncResult innerAsyncResult =
this.announcementServiceImpl.OnBeginOfflineAnnouncement(
this.GetMessageSequence(message),
this.GetEndpointDiscoveryMetadata(message),
this.PrepareAsyncCompletion(onOnOfflineAnnoucementCompletedCallback),
this);
if (innerAsyncResult.CompletedSynchronously && OnOnOfflineAnnouncementCompleted(innerAsyncResult))
{
this.Complete(true);
return;
}
}
protected abstract bool ValidateContent(TMessage message);
protected abstract DiscoveryMessageSequence GetMessageSequence(TMessage message);
protected abstract EndpointDiscoveryMetadata GetEndpointDiscoveryMetadata(TMessage message);
static bool OnOnOfflineAnnouncementCompleted(IAsyncResult result)
{
ByeOperationAsyncResult thisPtr = (ByeOperationAsyncResult)result.AsyncState;
thisPtr.announcementServiceImpl.OnEndOfflineAnnouncement(result);
return true;
}
bool IsInvalid(TMessage message)
{
UniqueId messageId = OperationContext.Current.IncomingMessageHeaders.MessageId;
if (messageId == null)
{
if (TD.DiscoveryMessageWithNullMessageIdIsEnabled())
{
TD.DiscoveryMessageWithNullMessageId(ProtocolStrings.TracingStrings.Bye);
}
return true;
}
else if (this.announcementServiceImpl.IsDuplicate(messageId))
{
if (TD.DuplicateDiscoveryMessageIsEnabled())
{
TD.DuplicateDiscoveryMessage(ProtocolStrings.TracingStrings.Bye, messageId.ToString());
}
return true;
}
else if (this.ValidateContent(message))
{
return false;
}
else
{
if (TD.DiscoveryMessageWithInvalidContentIsEnabled())
{
TD.DiscoveryMessageWithInvalidContent(ProtocolStrings.TracingStrings.Bye, messageId.ToString());
}
return true;
}
}
}
}
// 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
- UpDownBase.cs
- LabelInfo.cs
- XPathException.cs
- OleDbPropertySetGuid.cs
- PackageRelationshipSelector.cs
- ConfigurationCollectionAttribute.cs
- ProofTokenCryptoHandle.cs
- SchemaInfo.cs
- ToolboxItemWrapper.cs
- OracleConnection.cs
- PropertyInformation.cs
- RbTree.cs
- CodeMemberProperty.cs
- ImageFormatConverter.cs
- GenerateTemporaryTargetAssembly.cs
- SystemIPAddressInformation.cs
- PageBreakRecord.cs
- DesignerRegionCollection.cs
- DataGridCheckBoxColumn.cs
- OperandQuery.cs
- RenderingEventArgs.cs
- ClickablePoint.cs
- InstanceCreationEditor.cs
- CompiledAction.cs
- RotateTransform.cs
- HandoffBehavior.cs
- RegexGroupCollection.cs
- StylusLogic.cs
- SiteMapPathDesigner.cs
- XmlILOptimizerVisitor.cs
- ServiceHostFactory.cs
- ComEventsSink.cs
- InstanceData.cs
- ResourcePart.cs
- SuppressIldasmAttribute.cs
- DetailsViewRowCollection.cs
- TextModifier.cs
- DataServiceQueryOfT.cs
- SchemaObjectWriter.cs
- Delay.cs
- WindowsUpDown.cs
- XmlSecureResolver.cs
- ListViewUpdatedEventArgs.cs
- KeyMatchBuilder.cs
- PersistChildrenAttribute.cs
- ComAdminWrapper.cs
- HeaderElement.cs
- ExceptionUtil.cs
- UnionQueryOperator.cs
- AnnotationMap.cs
- StylusCaptureWithinProperty.cs
- HttpFileCollection.cs
- BitmapPalette.cs
- LowerCaseStringConverter.cs
- Splitter.cs
- ModuleElement.cs
- CommunicationException.cs
- ControlCollection.cs
- Identifier.cs
- PingReply.cs
- ObjectView.cs
- TreeNodeStyle.cs
- ContentValidator.cs
- CmsUtils.cs
- DescriptionAttribute.cs
- ChannelEndpointElementCollection.cs
- versioninfo.cs
- sqlinternaltransaction.cs
- Part.cs
- InvalidWMPVersionException.cs
- ModuleConfigurationInfo.cs
- ConfigXmlComment.cs
- ThousandthOfEmRealPoints.cs
- NativeStructs.cs
- Block.cs
- TagMapInfo.cs
- ResourcesGenerator.cs
- CommandHelper.cs
- ErrorFormatterPage.cs
- IISMapPath.cs
- DefaultObjectSerializer.cs
- AggregateNode.cs
- AstNode.cs
- WebPartConnectionsCloseVerb.cs
- AudioLevelUpdatedEventArgs.cs
- Matrix3D.cs
- Tokenizer.cs
- ElementMarkupObject.cs
- SimpleMailWebEventProvider.cs
- CharConverter.cs
- ModuleConfigurationInfo.cs
- AttachInfo.cs
- FileSystemWatcher.cs
- MetadataResolver.cs
- BasePattern.cs
- SqlCacheDependencyDatabase.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- ExpandedProjectionNode.cs
- DataSysAttribute.cs
- ToolStripItem.cs