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
- CodeDomLocalizationProvider.cs
- ExtenderProvidedPropertyAttribute.cs
- CompressEmulationStream.cs
- followingsibling.cs
- ResXDataNode.cs
- WindowsButton.cs
- HwndSource.cs
- ProxyManager.cs
- XmlSchemaInfo.cs
- AmbientLight.cs
- EncodingStreamWrapper.cs
- KeyInstance.cs
- FontFamilyIdentifier.cs
- GlobalizationAssembly.cs
- Keywords.cs
- QueryContinueDragEvent.cs
- FixUpCollection.cs
- TopClause.cs
- ListViewItem.cs
- ImportCatalogPart.cs
- BaseValidator.cs
- MaterialGroup.cs
- DiscoveryClient.cs
- NonParentingControl.cs
- ViewgenContext.cs
- X509Certificate2Collection.cs
- RectangleGeometry.cs
- Internal.cs
- XmlCountingReader.cs
- CacheAxisQuery.cs
- ProfessionalColorTable.cs
- WorkflowServiceAttributes.cs
- OracleEncoding.cs
- VoiceObjectToken.cs
- Error.cs
- WebPartCancelEventArgs.cs
- GAC.cs
- X509Extension.cs
- MetafileHeaderWmf.cs
- SecurityTokenProvider.cs
- PeerResolverBindingElement.cs
- WebConvert.cs
- DataContractJsonSerializer.cs
- JavaScriptSerializer.cs
- VirtualPathProvider.cs
- HttpProfileBase.cs
- CodeEntryPointMethod.cs
- TableItemPattern.cs
- LongAverageAggregationOperator.cs
- XmlQueryTypeFactory.cs
- TemplateControlCodeDomTreeGenerator.cs
- NavigationEventArgs.cs
- ObjectConverter.cs
- ProviderCommandInfoUtils.cs
- RuntimeResourceSet.cs
- ToolStripProgressBar.cs
- DisplayMemberTemplateSelector.cs
- Component.cs
- PassportAuthenticationEventArgs.cs
- ExpressionPrinter.cs
- CellLabel.cs
- Intellisense.cs
- WebPartUtil.cs
- WebBrowsableAttribute.cs
- ServiceParser.cs
- WS2007FederationHttpBindingElement.cs
- WaitHandleCannotBeOpenedException.cs
- MasterPageCodeDomTreeGenerator.cs
- storepermissionattribute.cs
- AuthorizationRule.cs
- HttpModuleAction.cs
- ItemList.cs
- GcHandle.cs
- SubclassTypeValidator.cs
- DescendantOverDescendantQuery.cs
- SQLByteStorage.cs
- QilTernary.cs
- ProfileServiceManager.cs
- EnumMemberAttribute.cs
- DesignerActionHeaderItem.cs
- TextOptions.cs
- BeginStoryboard.cs
- NativeStructs.cs
- CheckableControlBaseAdapter.cs
- VisualStateChangedEventArgs.cs
- SpeechUI.cs
- WorkflowExecutor.cs
- Message.cs
- Material.cs
- AttributeXamlType.cs
- AppDomain.cs
- ClockGroup.cs
- BadImageFormatException.cs
- Operand.cs
- WebRequestModuleElementCollection.cs
- ConfigXmlComment.cs
- MethodAccessException.cs
- HttpsHostedTransportConfiguration.cs
- AdditionalEntityFunctions.cs
- ButtonPopupAdapter.cs