Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / RemoteEndpointMessageProperty.cs / 1 / RemoteEndpointMessageProperty.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System; using System.Net; using System.Collections.Specialized; using System.ServiceModel.Activation; public sealed class RemoteEndpointMessageProperty { string address; int port; IPEndPoint remoteEndPoint; HostedRequestContainer hostedRequestContainer; InitializationState state; object thisLock = new object(); public RemoteEndpointMessageProperty(string address, int port) { if (string.IsNullOrEmpty(address)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("address"); } if (port < IPEndPoint.MinPort || port > IPEndPoint.MaxPort) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("port", SR.GetString(SR.ValueMustBeInRange, IPEndPoint.MinPort, IPEndPoint.MaxPort)); } this.port = port; this.address = address; this.state = InitializationState.All; } internal RemoteEndpointMessageProperty(HostedRequestContainer hostedRequestContainer) { this.hostedRequestContainer = hostedRequestContainer; } internal RemoteEndpointMessageProperty(IPEndPoint remoteEndPoint) { this.remoteEndPoint = remoteEndPoint; } public static string Name { get { return "System.ServiceModel.Channels.RemoteEndpointMessageProperty"; } } public string Address { get { if ((this.state & InitializationState.Address) != InitializationState.Address) { lock (ThisLock) { if ((this.state & InitializationState.Address) != InitializationState.Address) { Initialize(false); } } } return this.address; } } public int Port { get { if ((this.state & InitializationState.Port) != InitializationState.Port) { lock (ThisLock) { if ((this.state & InitializationState.Port) != InitializationState.Port) { Initialize(true); } } } return this.port; } } object ThisLock { get { return thisLock; } } void Initialize(bool getHostedPort) { if (remoteEndPoint != null) { this.address = remoteEndPoint.Address.ToString(); this.port = remoteEndPoint.Port; this.state = InitializationState.All; this.remoteEndPoint = null; } else { if ((this.state & InitializationState.Address) != InitializationState.Address) { this.address = hostedRequestContainer.GetRemoteAddress(); this.state |= InitializationState.Address; } if (getHostedPort) { this.port = hostedRequestContainer.GetRemotePort(); this.state |= InitializationState.Port; this.hostedRequestContainer = null; } } } [Flags] enum InitializationState { None = 0, Address = 1, Port = 2, All = 3 } } } // 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
- XmlSchemaExporter.cs
- IERequestCache.cs
- _IPv4Address.cs
- CrossContextChannel.cs
- LocatorManager.cs
- PerformanceCounterManager.cs
- TriggerCollection.cs
- ObservableCollectionDefaultValueFactory.cs
- LayoutManager.cs
- DispatcherOperation.cs
- BridgeDataReader.cs
- InputLanguageManager.cs
- ButtonBaseAutomationPeer.cs
- UserMapPath.cs
- ExceptionHelpers.cs
- DataMemberFieldConverter.cs
- SafeRegistryKey.cs
- NodeLabelEditEvent.cs
- shaper.cs
- CannotUnloadAppDomainException.cs
- RequestQueryProcessor.cs
- Attributes.cs
- NestedContainer.cs
- DeadCharTextComposition.cs
- SortedSetDebugView.cs
- DetailsViewCommandEventArgs.cs
- Utils.cs
- DelegateArgument.cs
- XmlUtf8RawTextWriter.cs
- AccessControlList.cs
- TreeNodeConverter.cs
- MemoryMappedViewAccessor.cs
- MenuAutoFormat.cs
- X509ChainPolicy.cs
- CultureInfoConverter.cs
- SelectedGridItemChangedEvent.cs
- EndpointNotFoundException.cs
- ColorPalette.cs
- TimeoutValidationAttribute.cs
- ToolStripDropTargetManager.cs
- Mapping.cs
- IMembershipProvider.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- ToolBarButton.cs
- SettingsProperty.cs
- XamlPointCollectionSerializer.cs
- GridViewColumnHeaderAutomationPeer.cs
- DelegateBodyWriter.cs
- KnownBoxes.cs
- SectionRecord.cs
- BaseTemplateCodeDomTreeGenerator.cs
- AuthenticatedStream.cs
- AuthorizationPolicyTypeElement.cs
- XmlDownloadManager.cs
- SqlTypesSchemaImporter.cs
- ListView.cs
- TextSerializer.cs
- panel.cs
- XsdValidatingReader.cs
- SwitchAttribute.cs
- DataQuery.cs
- GeneralTransformCollection.cs
- LinkClickEvent.cs
- WorkerRequest.cs
- DesignerPerfEventProvider.cs
- DataGridViewRowConverter.cs
- SafeFileHandle.cs
- PasswordTextNavigator.cs
- Transform.cs
- Trigger.cs
- SHA384.cs
- TimeSpanStorage.cs
- MonitoringDescriptionAttribute.cs
- AutomationPeer.cs
- HttpWrapper.cs
- DataTableReader.cs
- PixelShader.cs
- HuffModule.cs
- MimeTypePropertyAttribute.cs
- __Error.cs
- TabItemAutomationPeer.cs
- PublisherIdentityPermission.cs
- WsdlContractConversionContext.cs
- DiffuseMaterial.cs
- diagnosticsswitches.cs
- ErasingStroke.cs
- UIPermission.cs
- LinkDescriptor.cs
- FormViewPagerRow.cs
- RouteItem.cs
- ContainerParaClient.cs
- ButtonFieldBase.cs
- PagerSettings.cs
- SecurityIdentifierElementCollection.cs
- CalendarDesigner.cs
- ExtendedProperty.cs
- DataControlExtensions.cs
- ExclusiveTcpTransportManager.cs
- RemotingAttributes.cs
- TreeNodeStyle.cs