Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Common / Utils / Boolean / IdentifierService.cs / 1 / 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; 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(); 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. //---------------------------------------------------------------------- // // 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; 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(); 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
- SqlDataSourceCustomCommandPanel.cs
- StateDesigner.LayoutSelectionGlyph.cs
- DiffuseMaterial.cs
- SpotLight.cs
- InsufficientExecutionStackException.cs
- HttpRequestCacheValidator.cs
- SqlCachedBuffer.cs
- EntryPointNotFoundException.cs
- StructuralComparisons.cs
- ImplicitInputBrush.cs
- Pkcs9Attribute.cs
- FileLevelControlBuilderAttribute.cs
- UserControlParser.cs
- TypeElement.cs
- _HeaderInfoTable.cs
- XmlUTF8TextReader.cs
- ValueSerializerAttribute.cs
- BindableTemplateBuilder.cs
- TreeNodeConverter.cs
- Timeline.cs
- FontCacheUtil.cs
- TypeNameParser.cs
- TextTreeTextNode.cs
- Scalars.cs
- BlurEffect.cs
- RequestResizeEvent.cs
- BitStream.cs
- StorageEndPropertyMapping.cs
- Transform.cs
- XmlSchemaAttributeGroupRef.cs
- SocketPermission.cs
- Brush.cs
- MobileContainerDesigner.cs
- SemanticResultValue.cs
- CellParaClient.cs
- PolicyLevel.cs
- NativeMethods.cs
- PickDesigner.xaml.cs
- COM2TypeInfoProcessor.cs
- GetWorkflowTree.cs
- BinHexEncoder.cs
- oledbmetadatacollectionnames.cs
- SqlCacheDependency.cs
- BamlTreeNode.cs
- ThousandthOfEmRealDoubles.cs
- NonVisualControlAttribute.cs
- NavigationWindowAutomationPeer.cs
- ConnectionPointCookie.cs
- WebPartZoneCollection.cs
- ConnectionConsumerAttribute.cs
- SoapFault.cs
- DataControlPagerLinkButton.cs
- ColumnResizeAdorner.cs
- messageonlyhwndwrapper.cs
- DependentList.cs
- StylusButtonEventArgs.cs
- CustomDictionarySources.cs
- ObjectManager.cs
- CodeSnippetTypeMember.cs
- DataServiceQueryProvider.cs
- OperatorExpressions.cs
- PartialArray.cs
- ScrollableControl.cs
- PartialList.cs
- DSASignatureDeformatter.cs
- TrackingStringDictionary.cs
- EdmComplexPropertyAttribute.cs
- FilteredAttributeCollection.cs
- OwnerDrawPropertyBag.cs
- Compiler.cs
- ShapeTypeface.cs
- NavigateEvent.cs
- RuntimeWrappedException.cs
- ReadingWritingEntityEventArgs.cs
- FilterQueryOptionExpression.cs
- WindowsListViewItemStartMenu.cs
- LicenseContext.cs
- TextTreeNode.cs
- AsyncResult.cs
- AudioDeviceOut.cs
- _BasicClient.cs
- NumericExpr.cs
- ImportStoreException.cs
- BamlLocalizableResource.cs
- SafeRightsManagementEnvironmentHandle.cs
- SqlErrorCollection.cs
- ExceptionHandlerDesigner.cs
- InteropBitmapSource.cs
- ParallelActivityDesigner.cs
- NativeCppClassAttribute.cs
- InkCanvasInnerCanvas.cs
- Inflater.cs
- SqlNodeAnnotation.cs
- AnnotationObservableCollection.cs
- PeerPresenceInfo.cs
- ImageDrawing.cs
- SqlErrorCollection.cs
- CacheSection.cs
- SuppressIldasmAttribute.cs
- DataSourceHelper.cs