Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / ReadOnlyMetadataCollection.cs / 1 / ReadOnlyMetadataCollection.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Common;
using System.Diagnostics;
using System.Reflection;
using System.Text;
namespace System.Data.Metadata.Edm
{
///
/// Class representing a read-only wrapper around MetadataCollection
///
/// The type of items in this collection
public class ReadOnlyMetadataCollection : System.Collections.ObjectModel.ReadOnlyCollection where T : MetadataItem
{
#region Constructors
///
/// The constructor for constructing a read-only metadata collection to wrap another MetadataCollection.
///
/// The metadata collection to wrap
/// Thrown if collection argument is null
internal ReadOnlyMetadataCollection(IList collection) : base(collection)
{
}
#endregion
#region InnerClasses
// On the surface, this Enumerator doesn't do anything but delegating to the underlying enumerator
///
/// The enumerator for MetadataCollection
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")]
public struct Enumerator : IEnumerator
{
///
/// Constructor for the enumerator
///
/// The collection that this enumerator should enumerate on
internal Enumerator(IList collection)
{
_parent = collection;
_nextIndex = 0;
_current = null;
}
private int _nextIndex;
private IList _parent;
private T _current;
///
/// Gets the member at the current position
///
public T Current
{
get
{
return _current;
}
}
///
/// Gets the member at the current position
///
object IEnumerator.Current
{
get
{
return this.Current;
}
}
///
/// Dispose this enumerator
///
public void Dispose()
{
}
///
/// Move to the next member in the collection
///
/// True if the enumerator is moved
public bool MoveNext()
{
if ((uint)_nextIndex < (uint)_parent.Count)
{
_current = _parent[_nextIndex];
_nextIndex++;
return true;
}
_current = null;
return false;
}
///
/// Sets the enumerator to the initial position before the first member
///
public void Reset()
{
_current = null;
_nextIndex = 0;
}
}
#endregion
#region Properties
///
/// Gets whether the collection is a readonly collection
///
public bool IsReadOnly
{
get
{
return true;
}
}
///
/// Gets an item from the collection with the given identity
///
/// The identity of the item to search for
/// An item from the collection
/// Thrown if identity argument passed in is null
/// Thrown if setter is called
public virtual T this[string identity]
{
get
{
return (((MetadataCollection)this.Items)[identity]);
}
}
///
/// Returns the metadata collection over which this collection is the view
///
internal MetadataCollection Source
{
get
{
return (MetadataCollection)this.Items;
}
}
#endregion
#region Methods
///
/// Gets an item from the collection with the given identity
///
/// The identity of the item to search for
/// Whether case is ignore in the search
/// An item from the collection
/// Thrown if identity argument passed in is null
/// Thrown if the Collection does not have an item with the given identity
public virtual T GetValue(string identity, bool ignoreCase)
{
return ((MetadataCollection)this.Items).GetValue(identity, ignoreCase);
}
///
/// Determines if this collection contains an item of the given identity
///
/// The identity of the item to check for
/// True if the collection contains the item with the given identity
/// Thrown if identity argument passed in is null
/// Thrown if identity argument passed in is empty string
public virtual bool Contains(string identity)
{
return ((MetadataCollection)this.Items).ContainsIdentity(identity);
}
///
/// Gets an item from the collection with the given identity
///
/// The identity of the item to search for
/// Whether case is ignore in the search
/// An item from the collection, null if the item is not found
/// True an item is retrieved
/// if identity argument is null
public virtual bool TryGetValue(string identity, bool ignoreCase, out T item)
{
return ((MetadataCollection)this.Items).TryGetValue(identity, ignoreCase, out item);
}
///
/// Gets the enumerator over this collection
///
///
public new Enumerator GetEnumerator()
{
return new Enumerator(this.Items);
}
///
/// Workaround for bug
///
///
///
public new virtual int IndexOf(T value)
{
return base.IndexOf(value);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Common;
using System.Diagnostics;
using System.Reflection;
using System.Text;
namespace System.Data.Metadata.Edm
{
///
/// Class representing a read-only wrapper around MetadataCollection
///
/// The type of items in this collection
public class ReadOnlyMetadataCollection : System.Collections.ObjectModel.ReadOnlyCollection where T : MetadataItem
{
#region Constructors
///
/// The constructor for constructing a read-only metadata collection to wrap another MetadataCollection.
///
/// The metadata collection to wrap
/// Thrown if collection argument is null
internal ReadOnlyMetadataCollection(IList collection) : base(collection)
{
}
#endregion
#region InnerClasses
// On the surface, this Enumerator doesn't do anything but delegating to the underlying enumerator
///
/// The enumerator for MetadataCollection
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")]
public struct Enumerator : IEnumerator
{
///
/// Constructor for the enumerator
///
/// The collection that this enumerator should enumerate on
internal Enumerator(IList collection)
{
_parent = collection;
_nextIndex = 0;
_current = null;
}
private int _nextIndex;
private IList _parent;
private T _current;
///
/// Gets the member at the current position
///
public T Current
{
get
{
return _current;
}
}
///
/// Gets the member at the current position
///
object IEnumerator.Current
{
get
{
return this.Current;
}
}
///
/// Dispose this enumerator
///
public void Dispose()
{
}
///
/// Move to the next member in the collection
///
/// True if the enumerator is moved
public bool MoveNext()
{
if ((uint)_nextIndex < (uint)_parent.Count)
{
_current = _parent[_nextIndex];
_nextIndex++;
return true;
}
_current = null;
return false;
}
///
/// Sets the enumerator to the initial position before the first member
///
public void Reset()
{
_current = null;
_nextIndex = 0;
}
}
#endregion
#region Properties
///
/// Gets whether the collection is a readonly collection
///
public bool IsReadOnly
{
get
{
return true;
}
}
///
/// Gets an item from the collection with the given identity
///
/// The identity of the item to search for
/// An item from the collection
/// Thrown if identity argument passed in is null
/// Thrown if setter is called
public virtual T this[string identity]
{
get
{
return (((MetadataCollection)this.Items)[identity]);
}
}
///
/// Returns the metadata collection over which this collection is the view
///
internal MetadataCollection Source
{
get
{
return (MetadataCollection)this.Items;
}
}
#endregion
#region Methods
///
/// Gets an item from the collection with the given identity
///
/// The identity of the item to search for
/// Whether case is ignore in the search
/// An item from the collection
/// Thrown if identity argument passed in is null
/// Thrown if the Collection does not have an item with the given identity
public virtual T GetValue(string identity, bool ignoreCase)
{
return ((MetadataCollection)this.Items).GetValue(identity, ignoreCase);
}
///
/// Determines if this collection contains an item of the given identity
///
/// The identity of the item to check for
/// True if the collection contains the item with the given identity
/// Thrown if identity argument passed in is null
/// Thrown if identity argument passed in is empty string
public virtual bool Contains(string identity)
{
return ((MetadataCollection)this.Items).ContainsIdentity(identity);
}
///
/// Gets an item from the collection with the given identity
///
/// The identity of the item to search for
/// Whether case is ignore in the search
/// An item from the collection, null if the item is not found
/// True an item is retrieved
/// if identity argument is null
public virtual bool TryGetValue(string identity, bool ignoreCase, out T item)
{
return ((MetadataCollection)this.Items).TryGetValue(identity, ignoreCase, out item);
}
///
/// Gets the enumerator over this collection
///
///
public new Enumerator GetEnumerator()
{
return new Enumerator(this.Items);
}
///
/// Workaround for bug
///
///
///
public new virtual int IndexOf(T value)
{
return base.IndexOf(value);
}
#endregion
}
}
// 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
- QuadraticEase.cs
- ListViewHitTestInfo.cs
- OleDbCommandBuilder.cs
- WebPartConnectVerb.cs
- MemberHolder.cs
- MultipartContentParser.cs
- Margins.cs
- ErrorTableItemStyle.cs
- CalendarModeChangedEventArgs.cs
- InputBindingCollection.cs
- DesignTimeTemplateParser.cs
- StringArrayConverter.cs
- Clipboard.cs
- ShaderRenderModeValidation.cs
- CompoundFileDeflateTransform.cs
- Table.cs
- CommandLibraryHelper.cs
- SqlDataSourceQueryEditorForm.cs
- OutputCacheProfile.cs
- MissingSatelliteAssemblyException.cs
- COM2AboutBoxPropertyDescriptor.cs
- OracleException.cs
- ValueUtilsSmi.cs
- Error.cs
- DynamicValueConverter.cs
- PeerApplication.cs
- PageAction.cs
- CallbackValidator.cs
- DesignerSerializationVisibilityAttribute.cs
- UIElementCollection.cs
- AttributeTable.cs
- Math.cs
- HostedNamedPipeTransportManager.cs
- NoPersistProperty.cs
- __Error.cs
- MobileUserControl.cs
- ApplicationFileParser.cs
- ColorAnimationBase.cs
- Context.cs
- SecurityTokenProvider.cs
- AdapterUtil.cs
- XsdDuration.cs
- EventData.cs
- OperationAbortedException.cs
- XmlDataContract.cs
- NotFiniteNumberException.cs
- RTTypeWrapper.cs
- FormParameter.cs
- WebServiceMethodData.cs
- SizeAnimation.cs
- ApplicationTrust.cs
- GeometryCombineModeValidation.cs
- HtmlTextArea.cs
- StateMachineDesignerPaint.cs
- ZipArchive.cs
- SqlExpander.cs
- LabelAutomationPeer.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- HandleExceptionArgs.cs
- CheckBoxFlatAdapter.cs
- NaturalLanguageHyphenator.cs
- EmbeddedMailObject.cs
- ReadOnlyState.cs
- OdbcEnvironment.cs
- XmlEnumAttribute.cs
- EdmProperty.cs
- Single.cs
- XDeferredAxisSource.cs
- EmptyControlCollection.cs
- BitmapEffectGroup.cs
- FilterElement.cs
- ThreadStateException.cs
- EntityDataSourceWizardForm.cs
- XhtmlBasicTextBoxAdapter.cs
- EntityDataSourceDesignerHelper.cs
- XmlSchemaSimpleType.cs
- PeerNearMe.cs
- SplineKeyFrames.cs
- MetadataItem.cs
- OptimalBreakSession.cs
- CodeTypeMember.cs
- MatcherBuilder.cs
- TextRangeBase.cs
- WebControl.cs
- XmlArrayItemAttribute.cs
- MultiPartWriter.cs
- FontUnit.cs
- Material.cs
- CreateUserWizard.cs
- ObjectDataProvider.cs
- AccessDataSourceView.cs
- IssuedSecurityTokenParameters.cs
- HttpChannelHelper.cs
- OleDbSchemaGuid.cs
- InkPresenterAutomationPeer.cs
- LongValidator.cs
- ObjectStateManager.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- RootDesignerSerializerAttribute.cs
- BamlResourceDeserializer.cs