Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Channels / UdpRetransmissionSettings.cs / 1305376 / UdpRetransmissionSettings.cs
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System;
using System.Runtime;
using System.ServiceModel.Discovery;
sealed class UdpRetransmissionSettings
{
int maxUnicastRetransmitCount;
int maxMulticastRetransmitCount;
TimeSpan delayLowerBound;
TimeSpan delayUpperBound;
TimeSpan maxDelayPerRetransmission;
int delayLowerBoundMilliseconds;
int delayUpperBoundMilliseconds;
int maxDelayMilliseconds;
public UdpRetransmissionSettings(int maxUnicastRetransmitCount, int maxMulticastRetransmitCount)
: this(maxUnicastRetransmitCount, maxMulticastRetransmitCount, TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(250), TimeSpan.FromMilliseconds(500))
{
}
public UdpRetransmissionSettings(int maxUnicastRetransmitCount, int maxMulticastRetransmitCount, TimeSpan delayLowerBound, TimeSpan delayUpperBound, TimeSpan maxDelayPerRetransmission)
{
if (maxUnicastRetransmitCount < 0)
{
throw FxTrace.Exception.ArgumentOutOfRange("maxUnicastRetransmitCount", maxUnicastRetransmitCount,
SR.ArgumentOutOfMinRange(0));
}
if (maxMulticastRetransmitCount < 0)
{
throw FxTrace.Exception.ArgumentOutOfRange("maxMulticastRetransmitCount", maxMulticastRetransmitCount,
SR.ArgumentOutOfMinRange(0));
}
if (delayLowerBound < TimeSpan.Zero)
{
throw FxTrace.Exception.ArgumentOutOfRange("delayLowerBound", delayLowerBound, SR.ArgumentOutOfMinRange(TimeSpan.Zero));
}
if (delayUpperBound < TimeSpan.Zero)
{
throw FxTrace.Exception.ArgumentOutOfRange("delayUpperBound", delayUpperBound, SR.ArgumentOutOfMinRange(TimeSpan.Zero));
}
if (maxDelayPerRetransmission < TimeSpan.Zero)
{
throw FxTrace.Exception.ArgumentOutOfRange("maxDelayPerRetransmission", maxDelayPerRetransmission,
SR.ArgumentOutOfMinRange(TimeSpan.Zero));
}
this.maxUnicastRetransmitCount = maxUnicastRetransmitCount;
this.maxMulticastRetransmitCount = maxMulticastRetransmitCount;
this.delayLowerBound = delayLowerBound;
this.delayUpperBound = delayUpperBound;
this.maxDelayPerRetransmission = maxDelayPerRetransmission;
this.delayLowerBoundMilliseconds = -1;
this.delayUpperBoundMilliseconds = -1;
this.maxDelayMilliseconds = -1;
ValidateSettings();
}
//this constructor disables retransmission
internal UdpRetransmissionSettings()
: this(0, 0)
{
}
UdpRetransmissionSettings(UdpRetransmissionSettings other)
: this(other.maxUnicastRetransmitCount, other.maxMulticastRetransmitCount, other.delayLowerBound, other.delayUpperBound, other.maxDelayPerRetransmission)
{
}
public int MaxUnicastRetransmitCount
{
get
{
return this.maxUnicastRetransmitCount;
}
set
{
const int min = 0;
if (value < min)
{
throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinRange(min));
}
this.maxUnicastRetransmitCount = value;
}
}
public int MaxMulticastRetransmitCount
{
get
{
return this.maxMulticastRetransmitCount;
}
set
{
const int min = 0;
if (value < min)
{
throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinRange(min));
}
this.maxMulticastRetransmitCount = value;
}
}
public TimeSpan DelayLowerBound
{
get
{
return this.delayLowerBound;
}
set
{
if (value < TimeSpan.Zero)
{
throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinRange(TimeSpan.Zero));
}
this.delayLowerBound = value;
}
}
public TimeSpan DelayUpperBound
{
get
{
return this.delayUpperBound;
}
set
{
if (value < TimeSpan.Zero)
{
throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinRange(TimeSpan.Zero));
}
this.delayUpperBound = value;
}
}
public TimeSpan MaxDelayPerRetransmission
{
get
{
return this.maxDelayPerRetransmission;
}
set
{
if (value < TimeSpan.Zero)
{
throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ArgumentOutOfMinRange(TimeSpan.Zero));
}
this.maxDelayPerRetransmission = value;
}
}
//called at send time to avoid repeated rounding and casting
internal int GetDelayLowerBound()
{
if (this.delayLowerBoundMilliseconds < 0)
{
this.delayLowerBoundMilliseconds = TimeoutHelper.ToMilliseconds(this.delayLowerBound);
}
return this.delayLowerBoundMilliseconds;
}
//called at send time to avoid repeated rounding and casting
internal int GetDelayUpperBound()
{
if (this.delayUpperBoundMilliseconds < 0)
{
this.delayUpperBoundMilliseconds = TimeoutHelper.ToMilliseconds(this.delayUpperBound);
}
return this.delayUpperBoundMilliseconds;
}
//called at send time to avoid repeated rounding and casting
internal int GetMaxDelayPerRetransmission()
{
if (this.maxDelayMilliseconds < 0)
{
this.maxDelayMilliseconds = TimeoutHelper.ToMilliseconds(this.maxDelayPerRetransmission);
}
return this.maxDelayMilliseconds;
}
internal bool Enabled
{
get
{
return this.maxUnicastRetransmitCount > 0 || this.maxMulticastRetransmitCount > 0;
}
}
internal void ValidateSettings()
{
if (this.delayLowerBound > this.delayUpperBound)
{
throw FxTrace.Exception.ArgumentOutOfRange("DelayLowerBound", this.delayLowerBound, SR.Property1LessThanOrEqualToProperty2("DelayLowerBound", this.delayLowerBound, "DelayUpperBound", this.delayUpperBound));
}
if (this.delayUpperBound > this.maxDelayPerRetransmission)
{
throw FxTrace.Exception.ArgumentOutOfRange("DelayUpperBound", this.delayUpperBound, SR.Property1LessThanOrEqualToProperty2("DelayUpperBound", this.delayUpperBound, "MaxDelayPerRetransmission", this.maxDelayPerRetransmission));
}
}
internal UdpRetransmissionSettings Clone()
{
return new UdpRetransmissionSettings(this);
}
}
}
// 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
- VBCodeProvider.cs
- SmiEventSink.cs
- KnownTypes.cs
- WindowsSpinner.cs
- DataShape.cs
- MouseButton.cs
- _UriTypeConverter.cs
- DataServiceQueryProvider.cs
- TimerElapsedEvenArgs.cs
- UntrustedRecipientException.cs
- StateRuntime.cs
- WebPartMinimizeVerb.cs
- ElementMarkupObject.cs
- CodeSnippetExpression.cs
- DbException.cs
- PassportPrincipal.cs
- TreeViewCancelEvent.cs
- EditorAttribute.cs
- ConnectivityStatus.cs
- MdImport.cs
- LookupBindingPropertiesAttribute.cs
- SignedPkcs7.cs
- _HeaderInfoTable.cs
- LocalizationComments.cs
- EmbeddedMailObject.cs
- ValueOfAction.cs
- JsonUriDataContract.cs
- CodeMethodReturnStatement.cs
- EntityCommandCompilationException.cs
- BitmapSource.cs
- ArrayTypeMismatchException.cs
- BamlBinaryReader.cs
- WindowsGraphicsWrapper.cs
- LinkUtilities.cs
- WebPartRestoreVerb.cs
- LoadedEvent.cs
- CssTextWriter.cs
- UiaCoreProviderApi.cs
- ToolbarAUtomationPeer.cs
- InternalConfigSettingsFactory.cs
- RealizedColumnsBlock.cs
- DataGridItemAutomationPeer.cs
- SystemTcpConnection.cs
- WindowsGraphics.cs
- AnchoredBlock.cs
- ErrorRuntimeConfig.cs
- CorrelationHandle.cs
- TreeNode.cs
- CatalogZone.cs
- KeyTime.cs
- XmlWriterDelegator.cs
- COM2EnumConverter.cs
- ToolBarButtonDesigner.cs
- EncoderBestFitFallback.cs
- DataColumn.cs
- EntityCommandExecutionException.cs
- KeyTimeConverter.cs
- ActionMismatchAddressingException.cs
- HwndStylusInputProvider.cs
- DoubleAnimationBase.cs
- precedingquery.cs
- HttpFileCollectionBase.cs
- Image.cs
- InstanceValue.cs
- RoleManagerEventArgs.cs
- ThrowHelper.cs
- CodeCompileUnit.cs
- WpfWebRequestHelper.cs
- LeftCellWrapper.cs
- _WebProxyDataBuilder.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- SinglePhaseEnlistment.cs
- TargetFrameworkUtil.cs
- ResourceManager.cs
- TagElement.cs
- SettingsSavedEventArgs.cs
- XhtmlBasicPageAdapter.cs
- TemplateManager.cs
- HandlerBase.cs
- KeyGestureValueSerializer.cs
- SmiMetaDataProperty.cs
- OperationPickerDialog.designer.cs
- InvalidEnumArgumentException.cs
- RootBrowserWindowAutomationPeer.cs
- GlyphShapingProperties.cs
- _Win32.cs
- UnsafeNativeMethods.cs
- StorageMappingItemLoader.cs
- CodeNamespaceCollection.cs
- DataServiceConfiguration.cs
- PhonemeEventArgs.cs
- SchemaDeclBase.cs
- AutoGeneratedField.cs
- SQLInt64.cs
- ConvertEvent.cs
- TaskDesigner.cs
- RequestUriProcessor.cs
- Underline.cs
- HandoffBehavior.cs
- MediaSystem.cs