Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Channels / UdpTransportBindingElement.cs / 1305376 / UdpTransportBindingElement.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.ServiceModel.Channels { using System; using System.Runtime; using System.ServiceModel.Discovery; sealed class UdpTransportBindingElement : TransportBindingElement, IUdpTransportSettings { int duplicateMessageHistoryLength; int maxPendingMessageCount; UdpRetransmissionSettings retransmissionSettings; int socketReceiveBufferSize; int timeToLive; public UdpTransportBindingElement() : base() { this.duplicateMessageHistoryLength = UdpConstants.Defaults.DuplicateMessageHistoryLength; this.maxPendingMessageCount = UdpConstants.Defaults.MaxPendingMessageCount; this.ManualAddressing = true; this.retransmissionSettings = new UdpRetransmissionSettings(); this.socketReceiveBufferSize = UdpConstants.Defaults.SocketReceiveBufferSize; this.timeToLive = UdpConstants.Defaults.TimeToLive; this.MaxReceivedMessageSize = UdpConstants.Defaults.MaxReceivedMessageSize; } internal UdpTransportBindingElement(UdpTransportBindingElement other) : base(other) { this.duplicateMessageHistoryLength = other.duplicateMessageHistoryLength; this.maxPendingMessageCount = other.maxPendingMessageCount; this.retransmissionSettings = other.retransmissionSettings.Clone(); this.socketReceiveBufferSize = other.socketReceiveBufferSize; this.timeToLive = other.timeToLive; this.EnableMulticast = other.EnableMulticast; this.MulticastInterfaceId = other.MulticastInterfaceId; } public int DuplicateMessageHistoryLength { get { return this.duplicateMessageHistoryLength; } set { const int min = 0; if (value < min) { throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinRange(min)); } this.duplicateMessageHistoryLength = value; } } public bool EnableMulticast { get; set; } public int MaxPendingMessageCount { get { return this.maxPendingMessageCount; } set { const int min = 1; if (value < min) { throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinRange(min)); } this.maxPendingMessageCount = value; } } public override long MaxReceivedMessageSize { get { return base.MaxReceivedMessageSize; } set { const long min = 1L; const long max = (long)UdpConstants.MaxMessageSizeOverIPv4; if (value < min || value > max) { throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinMaxRange(min, max)); } base.MaxReceivedMessageSize = value; } } public string MulticastInterfaceId { get; set; } public UdpRetransmissionSettings RetransmissionSettings { get { return this.retransmissionSettings; } set { if (value == null) { throw FxTrace.Exception.ArgumentNull("value"); } this.retransmissionSettings = value; } } public override string Scheme { get { return UdpConstants.Scheme; } } public int SocketReceiveBufferSize { get { return this.socketReceiveBufferSize; } set { if (value < UdpConstants.MinReceiveBufferSize) { throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinRange(UdpConstants.MinReceiveBufferSize)); } this.socketReceiveBufferSize = value; } } public int TimeToLive { get { return this.timeToLive; } set { if (value < UdpConstants.MinTimeToLive || value > UdpConstants.MaxTimeToLive) { throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinMaxRange(UdpConstants.MinTimeToLive, UdpConstants.MaxTimeToLive)); } this.timeToLive = value; } } public override IChannelFactoryBuildChannelFactory (BindingContext context) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } if (!this.CanBuildChannelFactory (context)) { throw FxTrace.Exception.Argument("TChannel", SR.ChannelTypeNotSupported(typeof(TChannel))); } return (IChannelFactory )(object)new UdpChannelFactory(new UdpTransportBindingElement(this), context); } public override IChannelListener BuildChannelListener (BindingContext context) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } if (this.ManualAddressing == false) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.ManualAddressingRequiredOnServer)); } if (!this.CanBuildChannelListener (context)) { throw FxTrace.Exception.Argument("TChannel", SR.ChannelTypeNotSupported(typeof(TChannel))); } return (IChannelListener )(object)new UdpChannelListener(new UdpTransportBindingElement(this), context); } public override bool CanBuildChannelFactory (BindingContext context) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } return (typeof(TChannel) == typeof(IDuplexChannel)); } public override bool CanBuildChannelListener (BindingContext context) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } if (this.ManualAddressing == false) { return false; } return (typeof(TChannel) == typeof(IDuplexChannel)); } public override T GetProperty (BindingContext context) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } if (typeof(T) == typeof(IBindingMulticastCapabilities)) { return (T)(object)new BindingMulticastCapabilities(this.EnableMulticast); } return base.GetProperty (context); } public override BindingElement Clone() { return new UdpTransportBindingElement(this); } class BindingMulticastCapabilities : IBindingMulticastCapabilities { public BindingMulticastCapabilities(bool isMulticast) { this.IsMulticast = isMulticast; } public bool IsMulticast { get; private set; } } } } // 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
- ModulesEntry.cs
- DeviceSpecificChoiceCollection.cs
- BindingValueChangedEventArgs.cs
- IdentityNotMappedException.cs
- SoapSchemaImporter.cs
- RegexRunner.cs
- FilterException.cs
- PersonalizableAttribute.cs
- ManagementInstaller.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- TextEditorSpelling.cs
- _NtlmClient.cs
- DesignOnlyAttribute.cs
- SimpleHandlerFactory.cs
- Attribute.cs
- Fonts.cs
- initElementDictionary.cs
- HttpServerUtilityBase.cs
- WizardForm.cs
- InplaceBitmapMetadataWriter.cs
- DictionaryBase.cs
- NamedElement.cs
- BitmapEffectDrawingContextState.cs
- Timer.cs
- DBParameter.cs
- AnnotationAdorner.cs
- WhitespaceRuleReader.cs
- CodeAttachEventStatement.cs
- ComPlusAuthorization.cs
- Metafile.cs
- FastPropertyAccessor.cs
- SiteMapDesignerDataSourceView.cs
- Visual3D.cs
- PerformanceCounterPermissionEntry.cs
- ComplusEndpointConfigContainer.cs
- HttpListenerPrefixCollection.cs
- DataPagerField.cs
- ListBox.cs
- ChildTable.cs
- TemplatedWizardStep.cs
- HttpRequestBase.cs
- HMACSHA256.cs
- WebScriptServiceHostFactory.cs
- MessageEncoder.cs
- ExecutedRoutedEventArgs.cs
- XmlChildEnumerator.cs
- WebWorkflowRole.cs
- TextPointerBase.cs
- IsolatedStoragePermission.cs
- CreateUserErrorEventArgs.cs
- ConfigsHelper.cs
- EncoderExceptionFallback.cs
- Tablet.cs
- DataSet.cs
- XmlChoiceIdentifierAttribute.cs
- BuildManagerHost.cs
- PageThemeParser.cs
- DecimalConverter.cs
- SortQuery.cs
- TransformerInfo.cs
- ObjectListFieldsPage.cs
- QueryAsyncResult.cs
- XPathNavigator.cs
- SaveFileDialog.cs
- UriTemplateMatch.cs
- SmiEventSink.cs
- DataControlFieldTypeEditor.cs
- ControlsConfig.cs
- CodeIterationStatement.cs
- CodeExpressionCollection.cs
- AbstractExpressions.cs
- TableSectionStyle.cs
- ArglessEventHandlerProxy.cs
- DisableDpiAwarenessAttribute.cs
- OdbcRowUpdatingEvent.cs
- ArglessEventHandlerProxy.cs
- WmlSelectionListAdapter.cs
- AttachInfo.cs
- RSAPKCS1KeyExchangeFormatter.cs
- StateMachineSubscriptionManager.cs
- XmlSchemaExporter.cs
- DataGridViewSelectedRowCollection.cs
- TreeViewCancelEvent.cs
- AssemblyAssociatedContentFileAttribute.cs
- DirectionalLight.cs
- SystemIPv6InterfaceProperties.cs
- Compilation.cs
- DBConnectionString.cs
- OrthographicCamera.cs
- SettingsBase.cs
- hresults.cs
- SqlWebEventProvider.cs
- CodeAccessPermission.cs
- HashCoreRequest.cs
- CheckedPointers.cs
- CodeSubDirectoriesCollection.cs
- CollectionEditVerbManager.cs
- ObjectListGeneralPage.cs
- ManagementExtension.cs
- DataSvcMapFileSerializer.cs