Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / CodeDOM / CodeNamespaceImportCollection.cs / 1305376 / CodeNamespaceImportCollection.cs
//------------------------------------------------------------------------------
//
//
// [....]
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.CodeDom {
using System.Diagnostics;
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Globalization;
///
///
/// Manages a collection of objects.
///
///
[
ClassInterface(ClassInterfaceType.AutoDispatch),
ComVisible(true),
Serializable,
]
public class CodeNamespaceImportCollection : IList {
private ArrayList data = new ArrayList();
private Hashtable keys = new Hashtable(StringComparer.OrdinalIgnoreCase);
///
///
/// Indexer method that provides collection access.
///
///
public CodeNamespaceImport this[int index] {
get {
return ((CodeNamespaceImport)data[index]);
}
set {
data[index] = value;
SyncKeys();
}
}
///
///
/// Gets or sets the number of namespaces in the collection.
///
///
public int Count {
get {
return data.Count;
}
}
///
bool IList.IsReadOnly
{
get
{
return false;
}
}
///
bool IList.IsFixedSize
{
get
{
return false;
}
}
///
///
/// Adds a namespace import to the collection.
///
///
public void Add(CodeNamespaceImport value) {
if (!keys.ContainsKey(value.Namespace)) {
keys[value.Namespace] = value;
data.Add(value);
}
}
///
///
/// Adds a set of objects to the collection.
///
///
public void AddRange(CodeNamespaceImport[] value) {
if (value == null) {
throw new ArgumentNullException("value");
}
foreach (CodeNamespaceImport c in value) {
Add(c);
}
}
///
///
/// Clears the collection of members.
///
///
public void Clear() {
data.Clear();
keys.Clear();
}
///
///
/// Makes the collection of keys synchronised with the data.
///
///
private void SyncKeys() {
keys = new Hashtable(StringComparer.OrdinalIgnoreCase);
foreach(CodeNamespaceImport c in this) {
keys[c.Namespace] = c;
}
}
///
///
/// Gets an enumerator that enumerates the collection members.
///
///
public IEnumerator GetEnumerator() {
return data.GetEnumerator();
}
///
object IList.this[int index] {
get {
return this[index];
}
set {
this[index] = (CodeNamespaceImport)value;
SyncKeys();
}
}
///
int ICollection.Count {
get {
return Count;
}
}
///
bool ICollection.IsSynchronized {
get {
return false;
}
}
///
object ICollection.SyncRoot {
get {
return null;
}
}
///
void ICollection.CopyTo(Array array, int index) {
data.CopyTo(array, index);
}
///
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
///
int IList.Add(object value) {
return data.Add((CodeNamespaceImport)value);
}
///
void IList.Clear() {
Clear();
}
///
bool IList.Contains(object value) {
return data.Contains(value);
}
///
int IList.IndexOf(object value) {
return data.IndexOf((CodeNamespaceImport)value);
}
///
void IList.Insert(int index, object value) {
data.Insert(index, (CodeNamespaceImport)value);
SyncKeys();
}
///
void IList.Remove(object value) {
data.Remove((CodeNamespaceImport)value);
SyncKeys();
}
///
void IList.RemoveAt(int index) {
data.RemoveAt(index);
SyncKeys();
}
}
}
// 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
- PreservationFileWriter.cs
- Atom10FormatterFactory.cs
- VectorConverter.cs
- DataKey.cs
- DragDrop.cs
- MenuBase.cs
- PagedDataSource.cs
- URLMembershipCondition.cs
- DesignerAttributeInfo.cs
- ExceptionWrapper.cs
- ColumnTypeConverter.cs
- DataGridViewRowPrePaintEventArgs.cs
- XPathSingletonIterator.cs
- DataGridViewUtilities.cs
- NamespaceDecl.cs
- CellTreeNode.cs
- LinqMaximalSubtreeNominator.cs
- X509CertificateCollection.cs
- CompositeDispatchFormatter.cs
- JsonServiceDocumentSerializer.cs
- BrowserCapabilitiesFactoryBase.cs
- TcpStreams.cs
- DataRecordInfo.cs
- HwndSubclass.cs
- ClientCredentials.cs
- TableRowGroup.cs
- ProbeMatchesMessage11.cs
- IResourceProvider.cs
- ConstraintManager.cs
- WebServiceHost.cs
- SrgsGrammarCompiler.cs
- SiteMapSection.cs
- XmlSchemaImport.cs
- TextSegment.cs
- ClientRolePrincipal.cs
- SmtpNetworkElement.cs
- ToolStripItem.cs
- GridViewRowEventArgs.cs
- SaveWorkflowCommand.cs
- PartialTrustVisibleAssembly.cs
- NavigateEvent.cs
- ConfigXmlSignificantWhitespace.cs
- CardSpacePolicyElement.cs
- _AcceptOverlappedAsyncResult.cs
- FtpWebRequest.cs
- UseLicense.cs
- InstallerTypeAttribute.cs
- SoapSchemaImporter.cs
- StorageEntitySetMapping.cs
- Rights.cs
- AutoResizedEvent.cs
- SafeSecurityHelper.cs
- DataBinding.cs
- SafeBitVector32.cs
- SystemUdpStatistics.cs
- ClientTarget.cs
- CodeGenHelper.cs
- DiscoveryClientOutputChannel.cs
- SchemaImporter.cs
- DocumentXPathNavigator.cs
- ProviderBase.cs
- CommandPlan.cs
- ActivationArguments.cs
- WorkflowCommandExtensionItem.cs
- BitmapCodecInfoInternal.cs
- SchemaNotation.cs
- Variable.cs
- DataGridTableCollection.cs
- OracleConnection.cs
- SecurityVerifiedMessage.cs
- Hash.cs
- GridViewItemAutomationPeer.cs
- ITreeGenerator.cs
- Validator.cs
- ContextMarshalException.cs
- ColorConvertedBitmap.cs
- NetNamedPipeBinding.cs
- InternalCache.cs
- SerialErrors.cs
- DocumentOrderQuery.cs
- CollectionEditor.cs
- FullTextLine.cs
- CodeParameterDeclarationExpression.cs
- DropSource.cs
- SupportsEventValidationAttribute.cs
- ButtonFieldBase.cs
- ReadOnlyDataSourceView.cs
- QilFactory.cs
- GeneratedCodeAttribute.cs
- MaskedTextProvider.cs
- SimpleWorkerRequest.cs
- PocoEntityKeyStrategy.cs
- JsonQueryStringConverter.cs
- StateMachineSubscriptionManager.cs
- RectangleHotSpot.cs
- RoleManagerModule.cs
- PagePropertiesChangingEventArgs.cs
- RadioButtonAutomationPeer.cs
- DataKey.cs
- FormViewPageEventArgs.cs