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);
}
///
///
///
///
/// Provides some interesting information about the TriState in
/// String form.
///
///
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.
//------------------------------------------------------------------------------
//
// 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);
}
///
///
///
///
/// Provides some interesting information about the TriState in
/// String form.
///
///
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GeneralTransformGroup.cs
- FileDialogPermission.cs
- XmlSchemaCompilationSettings.cs
- WindowsAltTab.cs
- Control.cs
- ServiceModelSecurityTokenRequirement.cs
- TokenBasedSet.cs
- BamlRecords.cs
- TranslateTransform.cs
- BoolExpression.cs
- Stacktrace.cs
- ConfigurationStrings.cs
- TableRowsCollectionEditor.cs
- path.cs
- OperatingSystemVersionCheck.cs
- ManipulationDelta.cs
- CurrencyManager.cs
- TranslateTransform.cs
- CodeAttributeDeclarationCollection.cs
- _NtlmClient.cs
- ViewEvent.cs
- SchemaNames.cs
- ComNativeDescriptor.cs
- ToolStripScrollButton.cs
- HeaderedContentControl.cs
- EvidenceBase.cs
- DateTimeValueSerializerContext.cs
- TableAdapterManagerMethodGenerator.cs
- FileChangesMonitor.cs
- XamlGridLengthSerializer.cs
- DirectoryRootQuery.cs
- Properties.cs
- CapabilitiesSection.cs
- COSERVERINFO.cs
- CodeArgumentReferenceExpression.cs
- LoginName.cs
- DirtyTextRange.cs
- TextProperties.cs
- CopyOfAction.cs
- RoutedCommand.cs
- ColorMap.cs
- ProvidePropertyAttribute.cs
- WeakEventManager.cs
- DataGridViewRowHeaderCell.cs
- MessageSecurityOverMsmqElement.cs
- HttpListenerElement.cs
- SchemaObjectWriter.cs
- SerializationUtilities.cs
- RawStylusInputCustomData.cs
- AppSecurityManager.cs
- Rectangle.cs
- FilteredDataSetHelper.cs
- XmlSubtreeReader.cs
- CompositeCollection.cs
- CodeBinaryOperatorExpression.cs
- FixedSOMElement.cs
- DomainUpDown.cs
- FragmentQuery.cs
- OperationAbortedException.cs
- EventItfInfo.cs
- AttributeCollection.cs
- MenuRendererStandards.cs
- printdlgexmarshaler.cs
- UseAttributeSetsAction.cs
- MultipleViewPatternIdentifiers.cs
- Walker.cs
- TopClause.cs
- DataGridViewRowPrePaintEventArgs.cs
- DataTemplateKey.cs
- SessionConnectionReader.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- FixedDocument.cs
- ListItemCollection.cs
- SafeMILHandle.cs
- TransactionFlowElement.cs
- MarkupCompilePass2.cs
- ClientFormsIdentity.cs
- WebPartHeaderCloseVerb.cs
- ConnectionsZoneAutoFormat.cs
- DriveNotFoundException.cs
- Int32Storage.cs
- ProviderException.cs
- OperationCanceledException.cs
- TraversalRequest.cs
- HtmlUtf8RawTextWriter.cs
- Options.cs
- EntityModelSchemaGenerator.cs
- PopupControlService.cs
- KnownBoxes.cs
- XPathCompiler.cs
- FamilyMap.cs
- HelpProvider.cs
- ClientType.cs
- ComponentResourceKey.cs
- XmlSchemaExternal.cs
- ParameterCollection.cs
- SqlProcedureAttribute.cs
- Matrix3D.cs
- XPathScanner.cs
- ListViewGroup.cs