Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Discovery / ResolveCriteria.cs / 1305376 / ResolveCriteria.cs
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------
namespace System.ServiceModel.Discovery
{
using System;
using System.Collections.ObjectModel;
using System.Runtime;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using SR2 = System.ServiceModel.Discovery.SR;
[Fx.Tag.XamlVisible(false)]
public class ResolveCriteria
{
static TimeSpan defaultDuration = TimeSpan.FromSeconds(20);
EndpointAddress endpointAddress;
TimeSpan duration;
NonNullItemCollection extensions;
public ResolveCriteria()
: this(new EndpointAddress(EndpointAddress.AnonymousUri))
{
}
public ResolveCriteria(EndpointAddress address)
{
if (address == null)
{
throw FxTrace.Exception.ArgumentNull("address");
}
this.endpointAddress = address;
this.duration = ResolveCriteria.defaultDuration;
}
public EndpointAddress Address
{
get
{
return this.endpointAddress;
}
set
{
if (value == null)
{
throw FxTrace.Exception.ArgumentNull("value");
}
this.endpointAddress = value;
}
}
public TimeSpan Duration
{
get
{
return this.duration;
}
set
{
if (value.CompareTo(TimeSpan.Zero) <= 0)
{
throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR2.DiscoveryResolveDurationLessThanZero);
}
this.duration = value;
}
}
public Collection Extensions
{
get
{
if (this.extensions == null)
{
this.extensions = new NonNullItemCollection();
}
return this.extensions;
}
}
[Fx.Tag.Throws(typeof(XmlException), "throws on incorrect xml data")]
internal void ReadFrom(DiscoveryVersion discoveryVersion, XmlReader reader)
{
if (discoveryVersion == null)
{
throw FxTrace.Exception.ArgumentNull("discoveryVersion");
}
if (reader == null)
{
throw FxTrace.Exception.ArgumentNull("reader");
}
reader.MoveToContent();
if (reader.IsEmptyElement)
{
reader.Read();
return;
}
int startDepth = reader.Depth;
reader.ReadStartElement();
this.endpointAddress = SerializationUtility.ReadEndpointAddress(discoveryVersion, reader);
this.extensions = null;
this.duration = TimeSpan.MaxValue;
while (true)
{
reader.MoveToContent();
if ((reader.NodeType == XmlNodeType.EndElement) && (reader.Depth == startDepth))
{
break;
}
else if (reader.IsStartElement(ProtocolStrings.SchemaNames.DurationElement, ProtocolStrings.VersionInternal.Namespace))
{
this.duration = SerializationUtility.ReadDuration(reader);
}
else if (reader.IsStartElement())
{
XElement xElement = XElement.ReadFrom(reader) as XElement;
Extensions.Add(xElement);
}
else
{
reader.Read();
}
}
}
internal void WriteTo(DiscoveryVersion discoveryVersion, XmlWriter writer)
{
if (discoveryVersion == null)
{
throw FxTrace.Exception.ArgumentNull("discoveryVersion");
}
if (writer == null)
{
throw FxTrace.Exception.ArgumentNull("writer");
}
SerializationUtility.WriteEndPointAddress(discoveryVersion, this.endpointAddress, writer);
if (this.duration != TimeSpan.MaxValue)
{
writer.WriteElementString(
ProtocolStrings.SchemaNames.DurationElement,
ProtocolStrings.VersionInternal.Namespace,
XmlConvert.ToString(this.duration));
}
if (this.extensions != null)
{
foreach (XElement xElement in Extensions)
{
xElement.WriteTo(writer);
}
}
}
}
}
// 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
- SystemIPInterfaceStatistics.cs
- CornerRadiusConverter.cs
- ControlPaint.cs
- Encoder.cs
- SecurityRuntime.cs
- WebContext.cs
- DescendantOverDescendantQuery.cs
- ViewBox.cs
- ObjectConverter.cs
- AdapterUtil.cs
- BindingNavigator.cs
- MatchSingleFxEngineOpcode.cs
- EditorZoneBase.cs
- PlatformCulture.cs
- PageParser.cs
- MessageEncodingBindingElementImporter.cs
- RuleSettings.cs
- WindowsRegion.cs
- PropertyRef.cs
- TextComposition.cs
- ObjectQuery.cs
- HttpGetProtocolImporter.cs
- EntityClientCacheEntry.cs
- OutputCacheSection.cs
- Drawing.cs
- SpellerError.cs
- WindowsListViewGroup.cs
- StorageConditionPropertyMapping.cs
- SqlDataSourceCache.cs
- StrongNameUtility.cs
- OdbcDataReader.cs
- Misc.cs
- IResourceProvider.cs
- DeliveryStrategy.cs
- ParseNumbers.cs
- hwndwrapper.cs
- _UriTypeConverter.cs
- BatchWriter.cs
- FontStyleConverter.cs
- EastAsianLunisolarCalendar.cs
- StateChangeEvent.cs
- HttpWebResponse.cs
- EntityWrapperFactory.cs
- SelectorAutomationPeer.cs
- UriTemplateTrieNode.cs
- OlePropertyStructs.cs
- DataBinding.cs
- ResourcesChangeInfo.cs
- DesignerActionMethodItem.cs
- RegistrationServices.cs
- AdapterUtil.cs
- Decimal.cs
- DataBoundControl.cs
- HtmlImageAdapter.cs
- MultiBindingExpression.cs
- ListControlConvertEventArgs.cs
- ProjectionPath.cs
- XmlNavigatorFilter.cs
- PersonalizationAdministration.cs
- QuaternionAnimation.cs
- Rectangle.cs
- ChainOfDependencies.cs
- ReferenceSchema.cs
- TerminatorSinks.cs
- DecoderNLS.cs
- StringAnimationUsingKeyFrames.cs
- InstanceKeyView.cs
- ClientTargetSection.cs
- TableColumn.cs
- DataGridViewDataErrorEventArgs.cs
- UshortList2.cs
- M3DUtil.cs
- HostedElements.cs
- Properties.cs
- MemberPathMap.cs
- SelectionProviderWrapper.cs
- WSDualHttpBindingElement.cs
- DataGridViewBindingCompleteEventArgs.cs
- CodeDOMUtility.cs
- DynamicScriptObject.cs
- XXXOnTypeBuilderInstantiation.cs
- MembershipSection.cs
- SecurityTokenTypes.cs
- ConfigurationStrings.cs
- RoutedEvent.cs
- RuntimeConfigurationRecord.cs
- EntityClientCacheKey.cs
- ViewCellRelation.cs
- EntityProviderServices.cs
- MSAANativeProvider.cs
- CaseStatement.cs
- CellNormalizer.cs
- FontFamily.cs
- EntityConnectionStringBuilder.cs
- ObjectListItem.cs
- SafeEventLogReadHandle.cs
- XmlTypeAttribute.cs
- CatalogPartCollection.cs
- DataFormats.cs
- SizeConverter.cs