Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Printing / TriState.cs / 1305376 / TriState.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing.Printing { using System.ComponentModel; using System.Diagnostics; using System; [Serializable] internal struct TriState { private byte value; // 0 is "default", not false public static readonly TriState Default = new TriState(0); public static readonly TriState False = new TriState(1); public static readonly TriState True = new TriState(2); private TriState(byte value) { this.value = value; } public bool IsDefault { get { return this == Default;} } public bool IsFalse { get { return this == False;} } public bool IsNotDefault { get { return this != Default;} } public bool IsTrue { get { return this == True;} } public static bool operator ==(TriState left, TriState right) { return left.value == right.value; } public static bool operator !=(TriState left, TriState right) { return !(left == right); } public override bool Equals( object o ) { TriState state = (TriState)o; return this.value == state.value; } public override int GetHashCode() { return value; } public static implicit operator TriState(bool value) { return(value) ? True : False; } public static explicit operator bool(TriState value) { if (value.IsDefault) throw new InvalidCastException(SR.GetString(SR.TriStateCompareError)); else return(value == TriState.True); } ////// /// /// public override string ToString() { if (this == Default) return "Default"; else if (this == False) return "False"; else return "True"; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ ///// Provides some interesting information about the TriState in /// String form. /// ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing.Printing { using System.ComponentModel; using System.Diagnostics; using System; [Serializable] internal struct TriState { private byte value; // 0 is "default", not false public static readonly TriState Default = new TriState(0); public static readonly TriState False = new TriState(1); public static readonly TriState True = new TriState(2); private TriState(byte value) { this.value = value; } public bool IsDefault { get { return this == Default;} } public bool IsFalse { get { return this == False;} } public bool IsNotDefault { get { return this != Default;} } public bool IsTrue { get { return this == True;} } public static bool operator ==(TriState left, TriState right) { return left.value == right.value; } public static bool operator !=(TriState left, TriState right) { return !(left == right); } public override bool Equals( object o ) { TriState state = (TriState)o; return this.value == state.value; } public override int GetHashCode() { return value; } public static implicit operator TriState(bool value) { return(value) ? True : False; } public static explicit operator bool(TriState value) { if (value.IsDefault) throw new InvalidCastException(SR.GetString(SR.TriStateCompareError)); else return(value == TriState.True); } ////// /// /// public override string ToString() { if (this == Default) return "Default"; else if (this == False) return "False"; else return "True"; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// Provides some interesting information about the TriState in /// String form. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- isolationinterop.cs
- WinFormsComponentEditor.cs
- Stream.cs
- SelectorAutomationPeer.cs
- FloaterParaClient.cs
- CapiNative.cs
- CompilerLocalReference.cs
- WasNotInstalledException.cs
- HuffCodec.cs
- ImageIndexConverter.cs
- httpstaticobjectscollection.cs
- ProfileModule.cs
- BulletDecorator.cs
- TypePresenter.xaml.cs
- DeviceSpecificDialogCachedState.cs
- SqlUdtInfo.cs
- HostedHttpContext.cs
- SR.Designer.cs
- OleDragDropHandler.cs
- KerberosSecurityTokenProvider.cs
- ValueSerializerAttribute.cs
- XmlDownloadManager.cs
- CompilerWrapper.cs
- XmlAnyAttributeAttribute.cs
- DelimitedListTraceListener.cs
- Figure.cs
- CapabilitiesPattern.cs
- GrammarBuilder.cs
- isolationinterop.cs
- DBDataPermission.cs
- FixUpCollection.cs
- FormViewRow.cs
- StylusDevice.cs
- FormsAuthenticationEventArgs.cs
- CopyNodeSetAction.cs
- DataComponentNameHandler.cs
- FusionWrap.cs
- RealProxy.cs
- InfoCardMetadataExchangeClient.cs
- GraphicsPathIterator.cs
- OleDbRowUpdatingEvent.cs
- InternalBase.cs
- TrackingQuery.cs
- CollectionBuilder.cs
- Parser.cs
- HandlerFactoryWrapper.cs
- TypeElementCollection.cs
- Polygon.cs
- DeobfuscatingStream.cs
- StaticDataManager.cs
- StandardMenuStripVerb.cs
- OdbcErrorCollection.cs
- ContextStaticAttribute.cs
- AnonymousIdentificationModule.cs
- NetworkInterface.cs
- HttpListenerPrefixCollection.cs
- CodeEventReferenceExpression.cs
- DurableInstance.cs
- BaseValidatorDesigner.cs
- AppDomainManager.cs
- TextServicesManager.cs
- LoginUtil.cs
- ButtonBase.cs
- __TransparentProxy.cs
- WindowsListViewGroupSubsetLink.cs
- PrintDocument.cs
- OraclePermissionAttribute.cs
- MSAAWinEventWrap.cs
- AggregationMinMaxHelpers.cs
- CustomErrorCollection.cs
- PrimitiveOperationFormatter.cs
- ColorPalette.cs
- InvokeAction.cs
- MessageLogTraceRecord.cs
- CngKeyCreationParameters.cs
- WeakReadOnlyCollection.cs
- DateTimeConverter2.cs
- safesecurityhelperavalon.cs
- GlobalItem.cs
- SQLInt32.cs
- FixedNode.cs
- SafeThemeHandle.cs
- XmlElement.cs
- RuntimeConfig.cs
- IResourceProvider.cs
- RegexCharClass.cs
- MimeObjectFactory.cs
- Privilege.cs
- AutomationProperties.cs
- ReferenceList.cs
- HTMLTagNameToTypeMapper.cs
- DisplayMemberTemplateSelector.cs
- UidManager.cs
- InternalConfigRoot.cs
- RegexFCD.cs
- SoundPlayer.cs
- DefaultBinder.cs
- IisTraceListener.cs
- SafeArrayRankMismatchException.cs
- BitmapEffectRenderDataResource.cs