Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Collections / Generic / IDictionary.cs / 1305376 / IDictionary.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Interface: IDictionary
**
** [....]
**
**
** Purpose: Base interface for all generic dictionaries.
**
**
===========================================================*/
namespace System.Collections.Generic {
using System;
using System.Diagnostics.Contracts;
// An IDictionary is a possibly unordered set of key-value pairs.
// Keys can be any non-null object. Values can be any object.
// You can look up a value in an IDictionary via the default indexed
// property, Items.
[ContractClass(typeof(IDictionaryContract<,>))]
public interface IDictionary : ICollection>
{
// Interfaces are not serializable
// The Item property provides methods to read and edit entries
// in the Dictionary.
TValue this[TKey key] {
get;
set;
}
// Returns a collections of the keys in this dictionary.
ICollection Keys {
get;
}
// Returns a collections of the values in this dictionary.
ICollection Values {
get;
}
// Returns whether this dictionary contains a particular key.
//
bool ContainsKey(TKey key);
// Adds a key-value pair to the dictionary.
//
void Add(TKey key, TValue value);
// Removes a particular key from the dictionary.
//
bool Remove(TKey key);
bool TryGetValue(TKey key, out TValue value);
}
[ContractClassFor(typeof(IDictionary<,>))]
internal class IDictionaryContract : IDictionary
{
TValue IDictionary.this[TKey key] {
get { return default(TValue); }
set { }
}
ICollection IDictionary.Keys {
get {
Contract.Ensures(Contract.Result>() != null);
return default(ICollection);
}
}
// Returns a collections of the values in this dictionary.
ICollection IDictionary.Values {
get {
Contract.Ensures(Contract.Result>() != null);
return default(ICollection);
}
}
bool IDictionary.ContainsKey(TKey key)
{
return default(bool);
}
void IDictionary.Add(TKey key, TValue value)
{
}
bool IDictionary.Remove(TKey key)
{
//Contract.Ensures(Contract.Result() == false || ((ICollection>)this).Count == Contract.OldValue(((ICollection>)this).Count) - 1); // not threadsafe
return default(bool);
}
bool IDictionary.TryGetValue(TKey key, out TValue value)
{
value = default(TValue);
return default(bool);
}
#region ICollection> Members
void ICollection>.Add(KeyValuePair value)
{
//Contract.Ensures(((ICollection>)this).Count == Contract.OldValue(((ICollection>)this).Count) + 1); // not threadsafe
}
bool ICollection>.IsReadOnly
{
get { return default(bool); }
}
int ICollection>.Count
{
get {
Contract.Ensures(Contract.Result() >= 0);
return default(int);
}
}
void ICollection>.Clear()
{
}
bool ICollection>.Contains(KeyValuePair value)
{
// Contract.Ensures(((ICollection>)this).Count > 0 || Contract.Result() == false); // not threadsafe
return default(bool);
}
void ICollection>.CopyTo(KeyValuePair[] array, int startIndex)
{
//Contract.Requires(array != null);
//Contract.Requires(startIndex >= 0);
//Contract.Requires(startIndex + ((ICollection>)this).Count <= array.Length);
}
bool ICollection>.Remove(KeyValuePair value)
{
// No information if removal fails.
return default(bool);
}
IEnumerator> IEnumerable>.GetEnumerator()
{
Contract.Ensures(Contract.Result>>() != null);
return default(IEnumerator>);
}
IEnumerator IEnumerable.GetEnumerator()
{
Contract.Ensures(Contract.Result() != null);
return default(IEnumerator);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Interface: IDictionary
**
** [....]
**
**
** Purpose: Base interface for all generic dictionaries.
**
**
===========================================================*/
namespace System.Collections.Generic {
using System;
using System.Diagnostics.Contracts;
// An IDictionary is a possibly unordered set of key-value pairs.
// Keys can be any non-null object. Values can be any object.
// You can look up a value in an IDictionary via the default indexed
// property, Items.
[ContractClass(typeof(IDictionaryContract<,>))]
public interface IDictionary : ICollection>
{
// Interfaces are not serializable
// The Item property provides methods to read and edit entries
// in the Dictionary.
TValue this[TKey key] {
get;
set;
}
// Returns a collections of the keys in this dictionary.
ICollection Keys {
get;
}
// Returns a collections of the values in this dictionary.
ICollection Values {
get;
}
// Returns whether this dictionary contains a particular key.
//
bool ContainsKey(TKey key);
// Adds a key-value pair to the dictionary.
//
void Add(TKey key, TValue value);
// Removes a particular key from the dictionary.
//
bool Remove(TKey key);
bool TryGetValue(TKey key, out TValue value);
}
[ContractClassFor(typeof(IDictionary<,>))]
internal class IDictionaryContract : IDictionary
{
TValue IDictionary.this[TKey key] {
get { return default(TValue); }
set { }
}
ICollection IDictionary.Keys {
get {
Contract.Ensures(Contract.Result>() != null);
return default(ICollection);
}
}
// Returns a collections of the values in this dictionary.
ICollection IDictionary.Values {
get {
Contract.Ensures(Contract.Result>() != null);
return default(ICollection);
}
}
bool IDictionary.ContainsKey(TKey key)
{
return default(bool);
}
void IDictionary.Add(TKey key, TValue value)
{
}
bool IDictionary.Remove(TKey key)
{
//Contract.Ensures(Contract.Result() == false || ((ICollection>)this).Count == Contract.OldValue(((ICollection>)this).Count) - 1); // not threadsafe
return default(bool);
}
bool IDictionary.TryGetValue(TKey key, out TValue value)
{
value = default(TValue);
return default(bool);
}
#region ICollection> Members
void ICollection>.Add(KeyValuePair value)
{
//Contract.Ensures(((ICollection>)this).Count == Contract.OldValue(((ICollection>)this).Count) + 1); // not threadsafe
}
bool ICollection>.IsReadOnly
{
get { return default(bool); }
}
int ICollection>.Count
{
get {
Contract.Ensures(Contract.Result() >= 0);
return default(int);
}
}
void ICollection>.Clear()
{
}
bool ICollection>.Contains(KeyValuePair value)
{
// Contract.Ensures(((ICollection>)this).Count > 0 || Contract.Result() == false); // not threadsafe
return default(bool);
}
void ICollection>.CopyTo(KeyValuePair[] array, int startIndex)
{
//Contract.Requires(array != null);
//Contract.Requires(startIndex >= 0);
//Contract.Requires(startIndex + ((ICollection>)this).Count <= array.Length);
}
bool ICollection>.Remove(KeyValuePair value)
{
// No information if removal fails.
return default(bool);
}
IEnumerator> IEnumerable>.GetEnumerator()
{
Contract.Ensures(Contract.Result>>() != null);
return default(IEnumerator>);
}
IEnumerator IEnumerable.GetEnumerator()
{
Contract.Ensures(Contract.Result() != null);
return default(IEnumerator);
}
#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
- DataGridViewCellParsingEventArgs.cs
- XsltConvert.cs
- DeviceContext2.cs
- DropShadowBitmapEffect.cs
- GridViewRowEventArgs.cs
- ObjectParameterCollection.cs
- MsmqIntegrationMessageProperty.cs
- TextParaLineResult.cs
- DetailsViewInsertEventArgs.cs
- ShapeTypeface.cs
- Matrix3D.cs
- SocketException.cs
- ListSourceHelper.cs
- DesignerSerializationOptionsAttribute.cs
- Utils.cs
- SqlEnums.cs
- AssemblyBuilderData.cs
- Triplet.cs
- ResourcePermissionBase.cs
- AttachedProperty.cs
- DataSourceHelper.cs
- HitTestResult.cs
- DocumentSchemaValidator.cs
- Table.cs
- MatrixKeyFrameCollection.cs
- RijndaelManaged.cs
- UnsafeNativeMethods.cs
- propertyentry.cs
- ResourceExpression.cs
- Operators.cs
- TextProperties.cs
- DateTimeFormatInfoScanner.cs
- SafeViewOfFileHandle.cs
- DateTimeValueSerializerContext.cs
- PageTheme.cs
- DisplayMemberTemplateSelector.cs
- RawStylusInput.cs
- MsiStyleLogWriter.cs
- DockAndAnchorLayout.cs
- TransactionsSectionGroup.cs
- VisualStateGroup.cs
- SecurityKeyType.cs
- wmiprovider.cs
- ClientApiGenerator.cs
- Vertex.cs
- SemanticValue.cs
- FilteredDataSetHelper.cs
- TaiwanCalendar.cs
- ClientBuildManager.cs
- WorkflowDesignerColors.cs
- TypeUsageBuilder.cs
- XmlFileEditor.cs
- IgnoreSection.cs
- HttpConfigurationContext.cs
- ZoneMembershipCondition.cs
- ToolStripDropDown.cs
- ImportFileRequest.cs
- DecoderFallbackWithFailureFlag.cs
- EntityContainer.cs
- ExceptionUtil.cs
- IncrementalCompileAnalyzer.cs
- _Events.cs
- OdbcCommand.cs
- SqlGatherConsumedAliases.cs
- UnsafeNativeMethods.cs
- FlowDocumentReaderAutomationPeer.cs
- RectangleHotSpot.cs
- UndoEngine.cs
- NativeMethods.cs
- GridViewCancelEditEventArgs.cs
- QueuePathEditor.cs
- ScrollableControl.cs
- PenThreadPool.cs
- ByteAnimationBase.cs
- loginstatus.cs
- BatchServiceHost.cs
- ConstructorBuilder.cs
- RefExpr.cs
- DataBindingCollection.cs
- SslSecurityTokenParameters.cs
- ContravarianceAdapter.cs
- WebPartMenu.cs
- BooleanStorage.cs
- SecurityPermission.cs
- RemotingServices.cs
- AddInAttribute.cs
- QilUnary.cs
- EntityDataSourceContextCreatingEventArgs.cs
- SmiEventSink_DeferedProcessing.cs
- ClientTargetSection.cs
- CroppedBitmap.cs
- DockAndAnchorLayout.cs
- MenuRenderer.cs
- FloatUtil.cs
- DataTableMappingCollection.cs
- InvalidProgramException.cs
- QilValidationVisitor.cs
- BuildResult.cs
- DataTableExtensions.cs
- PointAnimationUsingPath.cs