Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / KeyedByTypeCollection.cs / 1 / KeyedByTypeCollection.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.Collections.Generic
{
using System.Xml;
using System.ServiceModel;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
public class KeyedByTypeCollection : KeyedCollection
{
public KeyedByTypeCollection()
: base(null, 4)
{
}
public KeyedByTypeCollection(IEnumerable items)
: base(null, 4)
{
if (items == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("items");
foreach (TItem item in items)
{
base.Add(item);
}
}
public T Find()
{
return this.Find(false);
}
public T Remove()
{
return this.Find(true);
}
T Find(bool remove)
{
for (int i = 0; i < this.Count; i++)
{
TItem settings = this[i];
if (settings is T)
{
if (remove)
{
Remove(settings);
}
return (T)(object)settings;
}
}
return default(T);
}
public Collection FindAll()
{
return this.FindAll(false);
}
public Collection RemoveAll()
{
return this.FindAll(true);
}
Collection FindAll(bool remove)
{
Collection result = new Collection();
foreach (TItem settings in this)
{
if (settings is T)
{
result.Add((T)(object)settings);
}
}
if (remove)
{
foreach (T settings in result)
{
this.Remove((TItem)(object)settings);
}
}
return result;
}
protected override Type GetKeyForItem(TItem item)
{
if (item == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item");
}
return item.GetType();
}
protected override void InsertItem(int index, TItem item)
{
if (item == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item");
}
if (this.Contains(item.GetType()))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("item", SR.GetString(SR.DuplicateBehavior1, item.GetType().FullName));
}
base.InsertItem(index, item);
}
protected override void SetItem(int index, TItem item)
{
if (item == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("item");
}
base.SetItem(index, item);
}
}
}
// 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
- RegexReplacement.cs
- SystemTcpConnection.cs
- FaultHandlingFilter.cs
- X509ThumbprintKeyIdentifierClause.cs
- controlskin.cs
- ExclusiveCanonicalizationTransform.cs
- EnumValidator.cs
- nulltextcontainer.cs
- Rights.cs
- AssemblySettingAttributes.cs
- ProvideValueServiceProvider.cs
- WhitespaceRule.cs
- WindowsGraphicsWrapper.cs
- EventMappingSettings.cs
- ProtocolsConfiguration.cs
- ConfigXmlText.cs
- figurelengthconverter.cs
- SingleStorage.cs
- BidOverLoads.cs
- FixedSOMGroup.cs
- SafeThreadHandle.cs
- IsolatedStorageSecurityState.cs
- UserNameSecurityTokenAuthenticator.cs
- WebPartDeleteVerb.cs
- TextEditorThreadLocalStore.cs
- SharedConnectionListener.cs
- ValidationPropertyAttribute.cs
- ValueType.cs
- WindowsRichEdit.cs
- CompoundFileStorageReference.cs
- BrowserCapabilitiesCompiler.cs
- ClipboardProcessor.cs
- CompoundFileStorageReference.cs
- SecurityUtils.cs
- ServiceCredentialsSecurityTokenManager.cs
- UnitySerializationHolder.cs
- DiscoveryOperationContextExtension.cs
- UnsafeNetInfoNativeMethods.cs
- ToolStripSeparator.cs
- IndependentAnimationStorage.cs
- XmlSchemaGroupRef.cs
- ObjectManager.cs
- SpeechRecognizer.cs
- PnrpPermission.cs
- HijriCalendar.cs
- SqlConnectionPoolProviderInfo.cs
- PerformanceCounterLib.cs
- TextBoxDesigner.cs
- TableAdapterManagerGenerator.cs
- WSSecurityOneDotZeroSendSecurityHeader.cs
- XPathItem.cs
- WebPartMinimizeVerb.cs
- SymbolEqualComparer.cs
- DataObjectEventArgs.cs
- ExtenderProviderService.cs
- DataGridSortingEventArgs.cs
- OraclePermission.cs
- ApplyHostConfigurationBehavior.cs
- RsaSecurityTokenParameters.cs
- SHA384.cs
- ServicePointManager.cs
- DesignBindingPropertyDescriptor.cs
- DataSourceControl.cs
- DataPager.cs
- UnsafeNativeMethodsCLR.cs
- ContextMenuService.cs
- webeventbuffer.cs
- ExeContext.cs
- BordersPage.cs
- PropertyGroupDescription.cs
- TextPointerBase.cs
- ViewStateException.cs
- DispatcherEventArgs.cs
- SetIterators.cs
- RoleBoolean.cs
- WinEventTracker.cs
- XsltOutput.cs
- MatrixCamera.cs
- ToolStripStatusLabel.cs
- OrderablePartitioner.cs
- RequestCacheManager.cs
- EntityModelBuildProvider.cs
- MinimizableAttributeTypeConverter.cs
- StringAnimationUsingKeyFrames.cs
- OleDbErrorCollection.cs
- ImageUrlEditor.cs
- MatrixTransform3D.cs
- DESCryptoServiceProvider.cs
- PeerNameRecordCollection.cs
- LayoutEditorPart.cs
- ByteAnimation.cs
- RootProfilePropertySettingsCollection.cs
- HebrewNumber.cs
- WindowsRichEditRange.cs
- ObjectHandle.cs
- ShapingEngine.cs
- HybridDictionary.cs
- UnsettableComboBox.cs
- __Error.cs
- RangeValuePattern.cs