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
- ADMembershipUser.cs
- StylusDownEventArgs.cs
- PageCatalogPart.cs
- SystemColorTracker.cs
- DesignTimeXamlWriter.cs
- ThreadExceptionDialog.cs
- SystemWebCachingSectionGroup.cs
- UInt32.cs
- VisualSerializer.cs
- SiteMapDataSourceView.cs
- PolyLineSegment.cs
- ChtmlTextWriter.cs
- UnsafeNativeMethodsTablet.cs
- UpdatePanelTrigger.cs
- XmlEncoding.cs
- XmlEventCache.cs
- DesignerTextViewAdapter.cs
- Timeline.cs
- DeviceContexts.cs
- XPathEmptyIterator.cs
- QilLoop.cs
- PlaceHolder.cs
- DataSourceExpression.cs
- TemplateControlBuildProvider.cs
- Triplet.cs
- GenericXmlSecurityToken.cs
- CodeDirectiveCollection.cs
- DeploymentExceptionMapper.cs
- DataServiceExpressionVisitor.cs
- AtomMaterializer.cs
- RSAProtectedConfigurationProvider.cs
- XmlBinaryWriterSession.cs
- IdentityManager.cs
- NullableDecimalSumAggregationOperator.cs
- ElementAction.cs
- EntityDataSource.cs
- WsatAdminException.cs
- TimeZoneNotFoundException.cs
- NativeMethods.cs
- GlobalAllocSafeHandle.cs
- TableItemProviderWrapper.cs
- BitmapSourceSafeMILHandle.cs
- NotConverter.cs
- SqlRowUpdatedEvent.cs
- TextTreeDeleteContentUndoUnit.cs
- log.cs
- FileInfo.cs
- tibetanshape.cs
- XmlWellformedWriter.cs
- LinqDataSourceSelectEventArgs.cs
- BinaryFormatterWriter.cs
- RowToParametersTransformer.cs
- CompModHelpers.cs
- ReflectionUtil.cs
- HtmlImage.cs
- DataControlCommands.cs
- MachineKey.cs
- DataGridViewCellCollection.cs
- PageParser.cs
- TextRunCache.cs
- RuntimeComponentFilter.cs
- UseLicense.cs
- AppModelKnownContentFactory.cs
- ErrorActivity.cs
- hebrewshape.cs
- LexicalChunk.cs
- KeyValueConfigurationCollection.cs
- OleDbRowUpdatedEvent.cs
- RenderCapability.cs
- ThicknessAnimation.cs
- ExpressionParser.cs
- FileReservationCollection.cs
- DbMetaDataColumnNames.cs
- RotationValidation.cs
- ObjectItemCollection.cs
- ISAPIApplicationHost.cs
- DataObjectPastingEventArgs.cs
- DateTime.cs
- SizeChangedInfo.cs
- GAC.cs
- PropertyManager.cs
- ActivitiesCollection.cs
- FormsAuthenticationUser.cs
- SqlDataSourceCache.cs
- DefaultAuthorizationContext.cs
- EdmSchemaError.cs
- GlobalDataBindingHandler.cs
- SelectionProviderWrapper.cs
- DoWhileDesigner.xaml.cs
- FormsAuthenticationModule.cs
- DocumentApplicationJournalEntry.cs
- NonVisualControlAttribute.cs
- ProfileManager.cs
- Image.cs
- WebReferencesBuildProvider.cs
- TableTextElementCollectionInternal.cs
- SizeKeyFrameCollection.cs
- WebScriptMetadataMessage.cs
- PasswordTextContainer.cs
- XmlNodeChangedEventManager.cs