Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / clr / src / BCL / System / ConsoleKeyInfo.cs / 1 / ConsoleKeyInfo.cs
// ==++== // // 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")); _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. // // ==--== /*============================================================================== ** ** 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")); _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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProjectedSlot.cs
- ImplicitInputBrush.cs
- M3DUtil.cs
- OperationInvokerBehavior.cs
- FilteredAttributeCollection.cs
- odbcmetadatacolumnnames.cs
- TriggerActionCollection.cs
- RestHandler.cs
- ConfigXmlCDataSection.cs
- ConfigurationStrings.cs
- FontStretchConverter.cs
- XmlAttributeOverrides.cs
- FontNamesConverter.cs
- RIPEMD160.cs
- RealProxy.cs
- MasterPage.cs
- DataConnectionHelper.cs
- ProcessMonitor.cs
- MDIControlStrip.cs
- SimpleType.cs
- XmlAnyElementAttributes.cs
- FilterException.cs
- XmlILModule.cs
- InternalDispatchObject.cs
- MSG.cs
- DrawingContextWalker.cs
- SystemIPv4InterfaceProperties.cs
- fixedPageContentExtractor.cs
- MatrixAnimationUsingKeyFrames.cs
- RowToParametersTransformer.cs
- InternalResources.cs
- StaticExtensionConverter.cs
- HttpInputStream.cs
- InputBinder.cs
- ComponentConverter.cs
- DataSourceHelper.cs
- VersionPair.cs
- StylusShape.cs
- PrimitiveXmlSerializers.cs
- FunctionDefinition.cs
- ConstraintManager.cs
- ProxySimple.cs
- UrlPath.cs
- NotImplementedException.cs
- RegistrySecurity.cs
- SqlMethodCallConverter.cs
- WebPartManager.cs
- ActiveDesignSurfaceEvent.cs
- BamlTreeNode.cs
- StorageRoot.cs
- Win32SafeHandles.cs
- GatewayIPAddressInformationCollection.cs
- StandardOleMarshalObject.cs
- QueryPageSettingsEventArgs.cs
- WebHttpSecurityModeHelper.cs
- XmlNamespaceDeclarationsAttribute.cs
- ProfileParameter.cs
- PersonalizationStateInfoCollection.cs
- AppDomainAttributes.cs
- CharacterString.cs
- ChildTable.cs
- PropertyPathConverter.cs
- Walker.cs
- WebPartConnectionsCloseVerb.cs
- XmlSchemaObjectTable.cs
- EventlogProvider.cs
- AddInProcess.cs
- PathGeometry.cs
- ScriptingSectionGroup.cs
- XmlEncodedRawTextWriter.cs
- GiveFeedbackEvent.cs
- ObjectDataSource.cs
- PassportIdentity.cs
- EntitySqlQueryBuilder.cs
- SwitchElementsCollection.cs
- MimeFormImporter.cs
- StopRoutingHandler.cs
- WorkflowServiceHostFactory.cs
- JournalNavigationScope.cs
- Pen.cs
- CommunicationObjectFaultedException.cs
- CharacterHit.cs
- XmlReturnWriter.cs
- IDataContractSurrogate.cs
- BinaryKeyIdentifierClause.cs
- CommandPlan.cs
- TreeViewCancelEvent.cs
- SafeArchiveContext.cs
- NodeInfo.cs
- EncodingInfo.cs
- ResourceProviderFactory.cs
- EnumerableValidator.cs
- FunctionQuery.cs
- PageTrueTypeFont.cs
- EntityObject.cs
- XmlSchemaException.cs
- ResourceExpression.cs
- Error.cs
- SQLSingleStorage.cs
- IIS7WorkerRequest.cs