Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Common / Utils / Boolean / IdentifierService.cs / 1599186 / IdentifierService.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Collections.ObjectModel; using System.Globalization; using System.Linq; using System.Runtime.CompilerServices; namespace System.Data.Common.Utils.Boolean { ////// Services related to different identifier types for Boolean expressions. /// internal abstract class IdentifierService{ #region Static members internal static readonly IdentifierService Instance = GetIdentifierService(); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static IdentifierService GetIdentifierService() { Type identifierType = typeof(T_Identifier); if (identifierType.IsGenericType && identifierType.GetGenericTypeDefinition() == typeof(DomainConstraint<,>)) { // initialize a domain constraint literal service Type[] genericArguments = identifierType.GetGenericArguments(); Type variableType = genericArguments[0]; Type elementType = genericArguments[1]; return (IdentifierService )Activator.CreateInstance( typeof(DomainConstraintIdentifierService<,>).MakeGenericType(identifierType, variableType, elementType)); } else { // initialize a generic literal service for all other identifier types return new GenericIdentifierService(); } } #endregion #region Constructors private IdentifierService() { } #endregion #region Service methods /// /// Returns negation of the given literal. /// internal abstract LiteralNegateLiteral(Literal literal); /// /// Creates a new conversion context. /// internal abstract ConversionContextCreateConversionContext(); /// /// Performs local simplification appropriate to the current identifier. /// internal abstract BoolExprLocalSimplify(BoolExpr expression); #endregion private class GenericIdentifierService : IdentifierService { internal override Literal NegateLiteral(Literal literal) { // just invert the sign return new Literal (literal.Term, !literal.IsTermPositive); } internal override ConversionContext CreateConversionContext() { return new GenericConversionContext (); } internal override BoolExpr LocalSimplify(BoolExpr expression) { return expression.Accept(Simplifier .Instance); } } private class DomainConstraintIdentifierService : IdentifierService > { internal override Literal > NegateLiteral(Literal > literal) { // negate the literal by inverting the range, rather than changing the sign // of the literal TermExpr > term = new TermExpr >( literal.Term.Identifier.InvertDomainConstraint()); return new Literal >(term, literal.IsTermPositive); } internal override ConversionContext > CreateConversionContext() { return new DomainConstraintConversionContext (); } internal override BoolExpr > LocalSimplify(BoolExpr > expression) { expression = NegationPusher.EliminateNot (expression); return expression.Accept(Simplifier >.Instance); } } } } // 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
- PaintEvent.cs
- XamlTypeWithExplicitNamespace.cs
- ValueSerializerAttribute.cs
- LineVisual.cs
- ComPlusServiceHost.cs
- DataFormat.cs
- HttpProfileBase.cs
- DataSourceControl.cs
- LoginAutoFormat.cs
- HttpRequestContext.cs
- base64Transforms.cs
- SymbolPair.cs
- BaseDataBoundControl.cs
- SQLInt32.cs
- SqlErrorCollection.cs
- RepeaterItemCollection.cs
- Simplifier.cs
- AutoCompleteStringCollection.cs
- ValidationHelper.cs
- MeasurementDCInfo.cs
- GiveFeedbackEvent.cs
- BoundField.cs
- ProfileService.cs
- DefaultParameterValueAttribute.cs
- FileDataSourceCache.cs
- XmlWriterSettings.cs
- WebRequestModulesSection.cs
- AvtEvent.cs
- SafeMILHandleMemoryPressure.cs
- RelationshipEndCollection.cs
- GridViewColumn.cs
- XmlText.cs
- EntityDataSourceContextDisposingEventArgs.cs
- SafeNativeMethods.cs
- ServiceDebugBehavior.cs
- BinaryParser.cs
- FileVersion.cs
- SelectionChangedEventArgs.cs
- FloaterBaseParagraph.cs
- ComplexPropertyEntry.cs
- WithStatement.cs
- SendSecurityHeaderElement.cs
- codemethodreferenceexpression.cs
- EmbeddedMailObject.cs
- DiffuseMaterial.cs
- CompleteWizardStep.cs
- RadialGradientBrush.cs
- StructuredProperty.cs
- KeyInfo.cs
- DataGridViewRowHeaderCell.cs
- RuleRefElement.cs
- UrlUtility.cs
- LowerCaseStringConverter.cs
- PixelShader.cs
- DataRow.cs
- RestHandlerFactory.cs
- DocumentPage.cs
- BindingCompleteEventArgs.cs
- Exceptions.cs
- SourceFilter.cs
- TypeUsage.cs
- XpsResourceDictionary.cs
- AutomationPatternInfo.cs
- CheckBoxList.cs
- PersonalizablePropertyEntry.cs
- GZipObjectSerializer.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- DbConnectionInternal.cs
- ScopelessEnumAttribute.cs
- XmlQueryContext.cs
- TimersDescriptionAttribute.cs
- ListViewHitTestInfo.cs
- DictionaryBase.cs
- FrameworkElementFactoryMarkupObject.cs
- PerspectiveCamera.cs
- ObjectView.cs
- SqlBinder.cs
- ActivitiesCollection.cs
- COM2ComponentEditor.cs
- SiteMapNode.cs
- ImageMap.cs
- ActivityScheduledRecord.cs
- Menu.cs
- Partitioner.cs
- HGlobalSafeHandle.cs
- COM2ICategorizePropertiesHandler.cs
- BatchParser.cs
- ReturnEventArgs.cs
- AddressHeaderCollectionElement.cs
- XmlDocument.cs
- WebConfigurationFileMap.cs
- UnknownBitmapDecoder.cs
- ResourceDescriptionAttribute.cs
- WriteableBitmap.cs
- AppDomainShutdownMonitor.cs
- SynchronizedInputPattern.cs
- UnicodeEncoding.cs
- _ListenerRequestStream.cs
- ProfileProvider.cs
- control.ime.cs