Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- UmAlQuraCalendar.cs
- ToolStripDropDownMenu.cs
- AuthenticationSchemesHelper.cs
- SubMenuStyle.cs
- SiteMapNodeItem.cs
- Exceptions.cs
- InvokeHandlers.cs
- DecimalConstantAttribute.cs
- TabRenderer.cs
- MenuCommand.cs
- _OSSOCK.cs
- FilteredAttributeCollection.cs
- CodeGeneratorOptions.cs
- XNameConverter.cs
- PreservationFileWriter.cs
- StylusCaptureWithinProperty.cs
- PatternMatcher.cs
- FixedSOMLineRanges.cs
- XmlSchemaFacet.cs
- AnimationTimeline.cs
- HttpResponse.cs
- SynchronizedInputAdaptor.cs
- CommunicationObjectFaultedException.cs
- TTSEngineProxy.cs
- GridViewCancelEditEventArgs.cs
- FileDialog.cs
- NavigationFailedEventArgs.cs
- SoundPlayer.cs
- DocumentViewerBaseAutomationPeer.cs
- PageAdapter.cs
- ReadContentAsBinaryHelper.cs
- BmpBitmapEncoder.cs
- UnsafeNativeMethods.cs
- COAUTHINFO.cs
- LayeredChannelFactory.cs
- PeerCredential.cs
- SystemNetHelpers.cs
- SqlDependency.cs
- XmlSchemaComplexType.cs
- ListBoxItem.cs
- ProfileSettingsCollection.cs
- ListParagraph.cs
- JpegBitmapEncoder.cs
- ProfilePropertySettingsCollection.cs
- Operator.cs
- SqlDependencyListener.cs
- SmtpFailedRecipientException.cs
- CheckBoxPopupAdapter.cs
- LinearGradientBrush.cs
- Int32Animation.cs
- CacheEntry.cs
- ResourceDictionaryCollection.cs
- ThemeDictionaryExtension.cs
- ClrPerspective.cs
- VerificationAttribute.cs
- ModifierKeysConverter.cs
- DbConnectionHelper.cs
- ProjectionPruner.cs
- DataSourceCollectionBase.cs
- RelationshipEnd.cs
- DataColumnChangeEvent.cs
- DataListItemCollection.cs
- IssuanceLicense.cs
- PageThemeBuildProvider.cs
- ArraySet.cs
- ProfileService.cs
- URI.cs
- CalendarDataBindingHandler.cs
- DnsEndpointIdentity.cs
- DbConnectionInternal.cs
- GorillaCodec.cs
- EdmTypeAttribute.cs
- HttpBrowserCapabilitiesWrapper.cs
- HashAlgorithm.cs
- LinqDataSourceView.cs
- ChtmlPhoneCallAdapter.cs
- ConstructorExpr.cs
- OletxTransactionFormatter.cs
- HandleRef.cs
- JournalEntry.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- CalendarDataBindingHandler.cs
- MimeParameter.cs
- EventRecord.cs
- FlowPosition.cs
- CompilerGeneratedAttribute.cs
- ParentQuery.cs
- DeclarativeCatalogPart.cs
- GCHandleCookieTable.cs
- FixedHyperLink.cs
- PrinterUnitConvert.cs
- XmlElement.cs
- ContractSearchPattern.cs
- MediaTimeline.cs
- EditorAttribute.cs
- PageThemeCodeDomTreeGenerator.cs
- GridItemProviderWrapper.cs
- ShimAsPublicXamlType.cs
- DrawingImage.cs
- DragStartedEventArgs.cs