Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Discovery / DiscoveryOperationContext.cs / 1305376 / DiscoveryOperationContext.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.ServiceModel.Discovery { using System; using System.Runtime; using System.ServiceModel.Channels; using System.Xml; class DiscoveryOperationContext { [Fx.Tag.SynchronizationObject] readonly object thisLock; readonly OperationContext operationContext; readonly DiscoveryOperationContextExtension operationContextExtension; readonly DiscoveryMessageProperty messageProperty; MessageHeaders outgoingMessageHeaders; public DiscoveryOperationContext(OperationContext operationContext) { Fx.Assert(operationContext != null, "The operationContext must be non null."); this.operationContext = operationContext; this.operationContextExtension = DiscoveryOperationContext.GetDiscoveryOperationContextExtension(this.operationContext); this.messageProperty = DiscoveryOperationContext.GetDiscoveryMessageProperty(this.operationContext); this.thisLock = new object(); } public ServiceDiscoveryMode DiscoveryMode { get { return this.operationContextExtension.DiscoveryMode; } } public TimeSpan MaxResponseDelay { get { return this.operationContextExtension.MaxResponseDelay; } } public TResponseChannel GetCallbackChannel() { return this.operationContext.GetCallbackChannel (); } public void AddressDuplexResponseMessage(OperationContext responseOperationContext) { EnsureOutgoingMessageHeaders(); responseOperationContext.OutgoingMessageHeaders.CopyHeadersFrom(this.outgoingMessageHeaders); responseOperationContext.OutgoingMessageHeaders.MessageId = new UniqueId(); this.AddDiscoveryMessageProperty(responseOperationContext); } public void AddressRequestResponseMessage(OperationContext responseOperationContext) { responseOperationContext.OutgoingMessageHeaders.MessageId = new UniqueId(); this.AddDiscoveryMessageProperty(responseOperationContext); } static DiscoveryOperationContextExtension GetDiscoveryOperationContextExtension(OperationContext operationContext) { DiscoveryOperationContextExtension operationContextExtension = operationContext.Extensions.Find (); if (operationContextExtension == null) { operationContextExtension = new DiscoveryOperationContextExtension(); } return operationContextExtension; } static DiscoveryMessageProperty GetDiscoveryMessageProperty(OperationContext operationContext) { object messageProperty; if (operationContext.IncomingMessageProperties.TryGetValue(DiscoveryMessageProperty.Name, out messageProperty)) { return messageProperty as DiscoveryMessageProperty; } else { return null; } } static MessageHeaders GetOutgoingMessageHeaders(OperationContext operationContext) { MessageHeaders outgoingMessageHeaders = new MessageHeaders(operationContext.IncomingMessageVersion); EndpointAddress replyTo = operationContext.IncomingMessageHeaders.ReplyTo; if (replyTo != null) { outgoingMessageHeaders.To = replyTo.Uri; foreach (AddressHeader addrHeader in replyTo.Headers) { outgoingMessageHeaders.Add(addrHeader.ToMessageHeader()); } } outgoingMessageHeaders.RelatesTo = operationContext.IncomingMessageHeaders.MessageId; return outgoingMessageHeaders; } void AddDiscoveryMessageProperty(OperationContext responseOperationContext) { if (this.messageProperty != null) { responseOperationContext.OutgoingMessageProperties.Add( DiscoveryMessageProperty.Name, this.messageProperty); } } void EnsureOutgoingMessageHeaders() { if (this.outgoingMessageHeaders == null) { lock (this.thisLock) { if (this.outgoingMessageHeaders == null) { this.outgoingMessageHeaders = DiscoveryOperationContext.GetOutgoingMessageHeaders(this.operationContext); } } } } } } // 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
- PointUtil.cs
- OpCodes.cs
- DBConnectionString.cs
- NullReferenceException.cs
- AppDomainShutdownMonitor.cs
- StorageSetMapping.cs
- StackSpiller.Temps.cs
- PageWrapper.cs
- UtilityExtension.cs
- ZipIOLocalFileDataDescriptor.cs
- KernelTypeValidation.cs
- SimpleType.cs
- MulticastNotSupportedException.cs
- CompiledAction.cs
- Operator.cs
- _LoggingObject.cs
- SQLUtility.cs
- ControlPaint.cs
- EventRoute.cs
- initElementDictionary.cs
- WindowsRichEdit.cs
- PinnedBufferMemoryStream.cs
- SpellerStatusTable.cs
- DelegatingConfigHost.cs
- WindowsSysHeader.cs
- StrongName.cs
- ContextMenu.cs
- SizeLimitedCache.cs
- httpserverutility.cs
- TableDetailsCollection.cs
- wgx_commands.cs
- DeleteHelper.cs
- PersonalizationStateInfoCollection.cs
- WebRequestModulesSection.cs
- CompilerScope.cs
- PerformanceCounterPermission.cs
- DesignerTextViewAdapter.cs
- ThrowHelper.cs
- SettingsContext.cs
- Grant.cs
- ExtendedPropertyDescriptor.cs
- MappingItemCollection.cs
- TypeElement.cs
- WindowsIPAddress.cs
- MulticastDelegate.cs
- KeyedQueue.cs
- UIPermission.cs
- AsyncResult.cs
- ControlCollection.cs
- TypeToken.cs
- TypedTableBaseExtensions.cs
- Atom10FormatterFactory.cs
- ValueUtilsSmi.cs
- ECDiffieHellman.cs
- MultiSelectRootGridEntry.cs
- ReferenceAssemblyAttribute.cs
- SegmentTree.cs
- Cloud.cs
- ControlTemplate.cs
- ServiceProviders.cs
- StringTraceRecord.cs
- ConstructorArgumentAttribute.cs
- RawStylusInputCustomDataList.cs
- AnnotationService.cs
- PatternMatcher.cs
- Size.cs
- ImageField.cs
- StrokeIntersection.cs
- FormCollection.cs
- StatusBar.cs
- XmlSerializer.cs
- UserPersonalizationStateInfo.cs
- Helper.cs
- FailedToStartupUIException.cs
- AssemblyResolver.cs
- RegularExpressionValidator.cs
- NonBatchDirectoryCompiler.cs
- XPathDescendantIterator.cs
- ConversionHelper.cs
- WebHeaderCollection.cs
- HttpStreamXmlDictionaryWriter.cs
- Point3DKeyFrameCollection.cs
- DrawTreeNodeEventArgs.cs
- AllowedAudienceUriElement.cs
- CatchDesigner.xaml.cs
- SurrogateEncoder.cs
- MergeEnumerator.cs
- IFlowDocumentViewer.cs
- CompiledAction.cs
- ServicesSection.cs
- ListView.cs
- _HeaderInfoTable.cs
- wgx_render.cs
- TreeIterators.cs
- UnsafeNativeMethods.cs
- ActivationWorker.cs
- XmlSchemaAnnotation.cs
- OracleBFile.cs
- XamlInt32CollectionSerializer.cs
- Registry.cs