Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CacheDict.cs
- DBConnection.cs
- Vector3DKeyFrameCollection.cs
- Vector.cs
- PreviewKeyDownEventArgs.cs
- MemberAccessException.cs
- SqlDataSourceParameterParser.cs
- OpenFileDialog.cs
- IconConverter.cs
- ServiceOperationParameter.cs
- RuntimeCompatibilityAttribute.cs
- MetadataAssemblyHelper.cs
- DataGridViewColumnStateChangedEventArgs.cs
- DataGridRowHeaderAutomationPeer.cs
- ListBindableAttribute.cs
- SqlCacheDependencyDatabaseCollection.cs
- PointLightBase.cs
- NativeMethodsOther.cs
- KeyValueConfigurationElement.cs
- CompilerWrapper.cs
- DesignOnlyAttribute.cs
- XmlSchemaAnnotation.cs
- AttributeUsageAttribute.cs
- DivideByZeroException.cs
- path.cs
- MetadataStore.cs
- InvalidTimeZoneException.cs
- DbXmlEnabledProviderManifest.cs
- TraceHandler.cs
- Nullable.cs
- XsdValidatingReader.cs
- ObjectFullSpanRewriter.cs
- TitleStyle.cs
- ToolStripCollectionEditor.cs
- Point4D.cs
- DownloadProgressEventArgs.cs
- PriorityQueue.cs
- DbSetClause.cs
- JoinCqlBlock.cs
- ReceiveActivity.cs
- KeyProperty.cs
- XmlSchemaAny.cs
- TransactionManager.cs
- BitmapEffectOutputConnector.cs
- _Connection.cs
- SqlHelper.cs
- EntityDataSourceContextCreatedEventArgs.cs
- ColorMatrix.cs
- SByte.cs
- ellipse.cs
- Hex.cs
- WebPageTraceListener.cs
- NonBatchDirectoryCompiler.cs
- PictureBox.cs
- ArgumentOutOfRangeException.cs
- EdmToObjectNamespaceMap.cs
- DynamicHyperLink.cs
- UnsafeNativeMethods.cs
- ReferentialConstraint.cs
- PrintController.cs
- WebEncodingValidator.cs
- CustomCategoryAttribute.cs
- XmlUtf8RawTextWriter.cs
- ConnectAlgorithms.cs
- WindowsTab.cs
- SID.cs
- Rule.cs
- Size3D.cs
- UnsafeNativeMethods.cs
- SymbolDocumentInfo.cs
- HierarchicalDataSourceConverter.cs
- WorkflowCompensationBehavior.cs
- KnownTypesHelper.cs
- XmlHierarchicalEnumerable.cs
- PersonalizationDictionary.cs
- COM2FontConverter.cs
- Floater.cs
- AppModelKnownContentFactory.cs
- RadioButtonStandardAdapter.cs
- Win32MouseDevice.cs
- WindowsComboBox.cs
- UIElement3D.cs
- Authorization.cs
- XmlMembersMapping.cs
- Transform3DGroup.cs
- XmlSerializationGeneratedCode.cs
- SchemaImporterExtensionsSection.cs
- TargetParameterCountException.cs
- StateMachine.cs
- LambdaCompiler.Binary.cs
- SoapAttributeOverrides.cs
- RegexCompiler.cs
- ImageBrush.cs
- Point4DValueSerializer.cs
- LockingPersistenceProvider.cs
- RenderDataDrawingContext.cs
- BindStream.cs
- LiteralTextParser.cs
- TimeSpanConverter.cs
- JsonFormatReaderGenerator.cs