Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / CommonUI / System / Drawing / Printing / TriState.cs / 1 / 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
- SimpleType.cs
- TemplateField.cs
- TransformedBitmap.cs
- XmlDataLoader.cs
- XPathDocumentIterator.cs
- XmlLoader.cs
- ParseElement.cs
- PixelFormat.cs
- EventProviderWriter.cs
- OracleConnection.cs
- ScriptControl.cs
- EmptyControlCollection.cs
- AnnotationHighlightLayer.cs
- DesignTimeParseData.cs
- SpeechSeg.cs
- ComPlusTypeValidator.cs
- FormParameter.cs
- HttpBindingExtension.cs
- RowTypePropertyElement.cs
- UnknownBitmapDecoder.cs
- TextRenderer.cs
- LoadGrammarCompletedEventArgs.cs
- HttpValueCollection.cs
- Imaging.cs
- UpdateTracker.cs
- PackagingUtilities.cs
- DecimalConstantAttribute.cs
- HttpRequestTraceRecord.cs
- XmlWrappingWriter.cs
- LocatorManager.cs
- VisualTarget.cs
- Converter.cs
- InplaceBitmapMetadataWriter.cs
- WebPartHelpVerb.cs
- TableRowCollection.cs
- QueryAsyncResult.cs
- XmlCharType.cs
- CompositionTarget.cs
- TextParaLineResult.cs
- Vector3D.cs
- EllipseGeometry.cs
- DataGridViewTextBoxCell.cs
- DebugView.cs
- OleDbReferenceCollection.cs
- BidPrivateBase.cs
- DataGridRelationshipRow.cs
- PropertyPathConverter.cs
- SafeLibraryHandle.cs
- connectionpool.cs
- XmlSchemaAny.cs
- FormViewInsertedEventArgs.cs
- ListControlConvertEventArgs.cs
- NonVisualControlAttribute.cs
- ParseHttpDate.cs
- UnsafeNetInfoNativeMethods.cs
- Freezable.cs
- FontDriver.cs
- InfocardExtendedInformationEntry.cs
- MaskInputRejectedEventArgs.cs
- RewritingValidator.cs
- SiteMapHierarchicalDataSourceView.cs
- XmlValueConverter.cs
- Stackframe.cs
- CodeDomConfigurationHandler.cs
- TemplatingOptionsDialog.cs
- Suspend.cs
- MainMenu.cs
- XmlNodeChangedEventManager.cs
- MessageSecurityException.cs
- RegexBoyerMoore.cs
- SingleResultAttribute.cs
- RegexCapture.cs
- SQLBinaryStorage.cs
- MeshGeometry3D.cs
- RoutedEventValueSerializer.cs
- WebHttpElement.cs
- DropDownList.cs
- ClusterSafeNativeMethods.cs
- Util.cs
- ObjectTypeMapping.cs
- Peer.cs
- XmlValidatingReaderImpl.cs
- Transform3DGroup.cs
- MarkupObject.cs
- SimpleApplicationHost.cs
- LoadGrammarCompletedEventArgs.cs
- DictionaryGlobals.cs
- DocumentXmlWriter.cs
- ActivatableWorkflowsQueryResult.cs
- CacheAxisQuery.cs
- MessageEventSubscriptionService.cs
- SplitContainer.cs
- ManipulationDeltaEventArgs.cs
- NumberFormatter.cs
- CodeLabeledStatement.cs
- WebPartMinimizeVerb.cs
- documentsequencetextview.cs
- UnknownBitmapDecoder.cs
- ResourceAttributes.cs
- SchemaImporterExtension.cs