Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / ConsoleKeyInfo.cs / 1305376 / ConsoleKeyInfo.cs
using System.Diagnostics.Contracts;
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*==============================================================================
**
** Class: ConsoleKeyInfo
**
**
** Purpose: This value type represents a single key press, with modifier keys
** like Alt, Control, and Shift.
**
**
=============================================================================*/
namespace System {
[Serializable]
public struct ConsoleKeyInfo {
private char _keyChar;
private ConsoleKey _key;
private ConsoleModifiers _mods;
public ConsoleKeyInfo(char keyChar, ConsoleKey key, bool shift, bool alt, bool control) {
// Limit ConsoleKey values to 0 to 255, but don't check whether the
// key is a valid value in our ConsoleKey enum. There are a few
// values in that enum that we didn't define, and reserved keys
// that might start showing up on keyboards in a few years.
if (((int)key) < 0 || ((int)key) > 255)
throw new ArgumentOutOfRangeException("key", Environment.GetResourceString("ArgumentOutOfRange_ConsoleKey"));
Contract.EndContractBlock();
_keyChar = keyChar;
_key = key;
_mods = 0;
if (shift)
_mods |= ConsoleModifiers.Shift;
if (alt)
_mods |= ConsoleModifiers.Alt;
if (control)
_mods |= ConsoleModifiers.Control;
}
public char KeyChar {
get { return _keyChar; }
}
public ConsoleKey Key {
get { return _key; }
}
public ConsoleModifiers Modifiers {
get { return _mods; }
}
public override bool Equals(Object value)
{
if (value is ConsoleKeyInfo)
return Equals((ConsoleKeyInfo)value);
else
return false;
}
public bool Equals(ConsoleKeyInfo obj)
{
return obj._keyChar == _keyChar && obj._key == _key && obj._mods == _mods;
}
public static bool operator ==(ConsoleKeyInfo a, ConsoleKeyInfo b)
{
return a.Equals(b);
}
public static bool operator !=(ConsoleKeyInfo a, ConsoleKeyInfo b)
{
return !(a == b);
}
public override int GetHashCode()
{
return (int)_keyChar | (int) _mods;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System.Diagnostics.Contracts;
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*==============================================================================
**
** Class: ConsoleKeyInfo
**
**
** Purpose: This value type represents a single key press, with modifier keys
** like Alt, Control, and Shift.
**
**
=============================================================================*/
namespace System {
[Serializable]
public struct ConsoleKeyInfo {
private char _keyChar;
private ConsoleKey _key;
private ConsoleModifiers _mods;
public ConsoleKeyInfo(char keyChar, ConsoleKey key, bool shift, bool alt, bool control) {
// Limit ConsoleKey values to 0 to 255, but don't check whether the
// key is a valid value in our ConsoleKey enum. There are a few
// values in that enum that we didn't define, and reserved keys
// that might start showing up on keyboards in a few years.
if (((int)key) < 0 || ((int)key) > 255)
throw new ArgumentOutOfRangeException("key", Environment.GetResourceString("ArgumentOutOfRange_ConsoleKey"));
Contract.EndContractBlock();
_keyChar = keyChar;
_key = key;
_mods = 0;
if (shift)
_mods |= ConsoleModifiers.Shift;
if (alt)
_mods |= ConsoleModifiers.Alt;
if (control)
_mods |= ConsoleModifiers.Control;
}
public char KeyChar {
get { return _keyChar; }
}
public ConsoleKey Key {
get { return _key; }
}
public ConsoleModifiers Modifiers {
get { return _mods; }
}
public override bool Equals(Object value)
{
if (value is ConsoleKeyInfo)
return Equals((ConsoleKeyInfo)value);
else
return false;
}
public bool Equals(ConsoleKeyInfo obj)
{
return obj._keyChar == _keyChar && obj._key == _key && obj._mods == _mods;
}
public static bool operator ==(ConsoleKeyInfo a, ConsoleKeyInfo b)
{
return a.Equals(b);
}
public static bool operator !=(ConsoleKeyInfo a, ConsoleKeyInfo b)
{
return !(a == b);
}
public override int GetHashCode()
{
return (int)_keyChar | (int) _mods;
}
}
}
// 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
- EntityDataSourceView.cs
- KnownTypesProvider.cs
- SqlRewriteScalarSubqueries.cs
- ISAPIApplicationHost.cs
- DocumentGridContextMenu.cs
- Storyboard.cs
- PaperSize.cs
- LinqDataSourceStatusEventArgs.cs
- ImageCodecInfo.cs
- ServiceObjectContainer.cs
- Form.cs
- TypedElement.cs
- TextBox.cs
- ConfigurationStrings.cs
- TrustManagerMoreInformation.cs
- Size.cs
- XmlHierarchicalDataSourceView.cs
- TypeViewSchema.cs
- XsltSettings.cs
- WebPartMenuStyle.cs
- BitHelper.cs
- ChooseAction.cs
- ProviderBase.cs
- XmlSchemaElement.cs
- ServerValidateEventArgs.cs
- odbcmetadatacollectionnames.cs
- BaseCollection.cs
- RectAnimationBase.cs
- IIS7WorkerRequest.cs
- SystemThemeKey.cs
- Util.cs
- CommandArguments.cs
- safex509handles.cs
- MediaEntryAttribute.cs
- InfoCardKeyedHashAlgorithm.cs
- GenericTypeParameterBuilder.cs
- RegexRunner.cs
- RegularExpressionValidator.cs
- Base64Encoder.cs
- BaseTemplateCodeDomTreeGenerator.cs
- COAUTHINFO.cs
- MainMenu.cs
- DebugView.cs
- FlowDocumentPage.cs
- TextUtf8RawTextWriter.cs
- SoapSchemaImporter.cs
- DbExpressionRules.cs
- ClientTargetCollection.cs
- ModuleBuilder.cs
- SiteMembershipCondition.cs
- XmlSchemaObject.cs
- KoreanLunisolarCalendar.cs
- Win32Native.cs
- XmlAnyElementAttributes.cs
- SimpleTextLine.cs
- DataTrigger.cs
- ConstructorBuilder.cs
- RtfToXamlReader.cs
- Int32Collection.cs
- IriParsingElement.cs
- SQLString.cs
- UserCancellationException.cs
- UInt64.cs
- JavascriptCallbackResponseProperty.cs
- VirtualizingPanel.cs
- ProtectedConfiguration.cs
- SqlTopReducer.cs
- UIElementHelper.cs
- OleDbDataReader.cs
- ExitEventArgs.cs
- Effect.cs
- ExpressionBinding.cs
- XmlSchemaAttribute.cs
- HtmlTextArea.cs
- PropertyEmitter.cs
- CompositeDataBoundControl.cs
- ThousandthOfEmRealPoints.cs
- WorkflowViewStateService.cs
- ToolStripContainer.cs
- PeerDuplexChannelListener.cs
- DebuggerAttributes.cs
- QilLiteral.cs
- BindingManagerDataErrorEventArgs.cs
- Propagator.cs
- FileNotFoundException.cs
- ResXDataNode.cs
- SchemaImporterExtensionElement.cs
- SiteMapDataSource.cs
- CodeSubDirectoriesCollection.cs
- ImportCatalogPart.cs
- PrintEvent.cs
- DataGridHelper.cs
- Int32CAMarshaler.cs
- EditorOptionAttribute.cs
- OutputCacheProfile.cs
- dataprotectionpermissionattribute.cs
- XsltOutput.cs
- RowParagraph.cs
- EventLogPermissionEntry.cs
- PublishLicense.cs