Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / Utils / Boolean / Literal.cs / 1305376 / Literal.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Collections.ObjectModel;
using System.Diagnostics;
namespace System.Data.Common.Utils.Boolean
{
///
/// Represents a literal in a normal form expression of the form:
///
/// Term
///
/// or
///
/// !Term
///
///
internal sealed class Literal : NormalFormNode,
IEquatable>
{
private readonly TermExpr _term;
private readonly bool _isTermPositive;
///
/// Initialize a new literal.
///
/// Term
/// Sign of term
internal Literal(TermExpr term, bool isTermPositive)
: base(isTermPositive ? (BoolExpr)term : (BoolExpr)new NotExpr(term))
{
Debug.Assert(null != term);
_term = term;
_isTermPositive = isTermPositive;
}
///
/// Gets literal term.
///
internal TermExpr Term
{
get { return _term; }
}
///
/// Gets sign of term.
///
internal bool IsTermPositive
{
get { return _isTermPositive; }
}
///
/// Creates a negated version of this literal.
///
/// !this
internal Literal MakeNegated()
{
return IdentifierService.Instance.NegateLiteral(this);
}
public override string ToString()
{
return StringUtil.FormatInvariant("{0}{1}",
_isTermPositive ? String.Empty : "!",
_term);
}
public override bool Equals(object obj)
{
Debug.Fail("use typed Equals");
return Equals(obj as Literal);
}
public bool Equals(Literal other)
{
return null != other &&
other._isTermPositive == _isTermPositive &&
other._term.Equals(_term);
}
public override int GetHashCode()
{
return _term.GetHashCode();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Collections.ObjectModel;
using System.Diagnostics;
namespace System.Data.Common.Utils.Boolean
{
///
/// Represents a literal in a normal form expression of the form:
///
/// Term
///
/// or
///
/// !Term
///
///
internal sealed class Literal : NormalFormNode,
IEquatable>
{
private readonly TermExpr _term;
private readonly bool _isTermPositive;
///
/// Initialize a new literal.
///
/// Term
/// Sign of term
internal Literal(TermExpr term, bool isTermPositive)
: base(isTermPositive ? (BoolExpr)term : (BoolExpr)new NotExpr(term))
{
Debug.Assert(null != term);
_term = term;
_isTermPositive = isTermPositive;
}
///
/// Gets literal term.
///
internal TermExpr Term
{
get { return _term; }
}
///
/// Gets sign of term.
///
internal bool IsTermPositive
{
get { return _isTermPositive; }
}
///
/// Creates a negated version of this literal.
///
/// !this
internal Literal MakeNegated()
{
return IdentifierService.Instance.NegateLiteral(this);
}
public override string ToString()
{
return StringUtil.FormatInvariant("{0}{1}",
_isTermPositive ? String.Empty : "!",
_term);
}
public override bool Equals(object obj)
{
Debug.Fail("use typed Equals");
return Equals(obj as Literal);
}
public bool Equals(Literal other)
{
return null != other &&
other._isTermPositive == _isTermPositive &&
other._term.Equals(_term);
}
public override int GetHashCode()
{
return _term.GetHashCode();
}
}
}
// 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
- HwndSourceParameters.cs
- FontFamilyValueSerializer.cs
- AdapterUtil.cs
- EventWaitHandle.cs
- CommandBinding.cs
- UTF7Encoding.cs
- DeflateStream.cs
- EmbeddedObject.cs
- HelpKeywordAttribute.cs
- sapiproxy.cs
- ListViewAutomationPeer.cs
- DPCustomTypeDescriptor.cs
- CaseInsensitiveComparer.cs
- WebPartUtil.cs
- DoubleCollection.cs
- OverrideMode.cs
- PrimitiveXmlSerializers.cs
- SQLGuidStorage.cs
- DesignerRegionMouseEventArgs.cs
- FloaterBaseParagraph.cs
- Polyline.cs
- IListConverters.cs
- URIFormatException.cs
- PerformanceCounterPermissionAttribute.cs
- WebPartConnectionsCancelEventArgs.cs
- SafeEventLogWriteHandle.cs
- XDRSchema.cs
- DataServiceBuildProvider.cs
- KeySplineConverter.cs
- LocalBuilder.cs
- DataServiceEntityAttribute.cs
- DefaultValueMapping.cs
- XmlSchemaSimpleTypeUnion.cs
- PropertySourceInfo.cs
- MemberPathMap.cs
- TextSegment.cs
- DataGridViewRowCollection.cs
- MessageHeaderDescription.cs
- UpdateProgress.cs
- SecureConversationVersion.cs
- Error.cs
- ValueTypePropertyReference.cs
- Package.cs
- OracleNumber.cs
- StdValidatorsAndConverters.cs
- ChannelAcceptor.cs
- WebPartCatalogCloseVerb.cs
- TextProperties.cs
- XmlSchemaValidationException.cs
- BufferedGraphicsManager.cs
- DbProviderFactories.cs
- ChameleonKey.cs
- EventRoute.cs
- ObjectConverter.cs
- ListItemConverter.cs
- DataGridViewIntLinkedList.cs
- GroupByExpressionRewriter.cs
- DataKeyCollection.cs
- XmlRawWriterWrapper.cs
- Dispatcher.cs
- XPathMultyIterator.cs
- WindowsSysHeader.cs
- BinaryMessageEncoder.cs
- WsatConfiguration.cs
- SafeLibraryHandle.cs
- ImportOptions.cs
- StrokeCollectionDefaultValueFactory.cs
- XmlChildNodes.cs
- DocumentationServerProtocol.cs
- PersonalizationStateInfo.cs
- XmlChoiceIdentifierAttribute.cs
- ColumnHeaderCollectionEditor.cs
- SchemaImporterExtensionElement.cs
- ArgumentNullException.cs
- ContextMenuService.cs
- DoubleAnimationClockResource.cs
- SecurityTokenResolver.cs
- ControllableStoryboardAction.cs
- SqlServer2KCompatibilityCheck.cs
- HttpHandlerAction.cs
- CategoryValueConverter.cs
- RSAPKCS1SignatureFormatter.cs
- Hashtable.cs
- ForeignKeyConstraint.cs
- AsymmetricKeyExchangeDeformatter.cs
- HeaderedItemsControl.cs
- FlowDocumentView.cs
- CheckPair.cs
- Brush.cs
- WindowsListViewGroupHelper.cs
- FileLogRecord.cs
- XamlPoint3DCollectionSerializer.cs
- DataSourceComponent.cs
- ListItemCollection.cs
- SqlErrorCollection.cs
- CompilationSection.cs
- BamlRecordReader.cs
- __ConsoleStream.cs
- TreeViewDataItemAutomationPeer.cs
- DataServiceQueryProvider.cs