Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- SQLByte.cs
- IProvider.cs
- FillBehavior.cs
- Model3DGroup.cs
- WebBrowserEvent.cs
- TextRunCacheImp.cs
- CodeDirectoryCompiler.cs
- ToolStripContextMenu.cs
- SecurityTokenValidationException.cs
- AxisAngleRotation3D.cs
- File.cs
- Formatter.cs
- XmlMembersMapping.cs
- DependencyPropertyDescriptor.cs
- ComPlusServiceHost.cs
- ProfileManager.cs
- MailHeaderInfo.cs
- XmlCodeExporter.cs
- SourceChangedEventArgs.cs
- XmlSchemaInfo.cs
- XmlObjectSerializerWriteContextComplex.cs
- LoginCancelEventArgs.cs
- AutomationTextAttribute.cs
- LineUtil.cs
- RoleManagerModule.cs
- ToolStripItemDesigner.cs
- CharStorage.cs
- ForceCopyBuildProvider.cs
- Attributes.cs
- DateTimeConverter.cs
- AssertFilter.cs
- BaseCollection.cs
- LineGeometry.cs
- PipelineModuleStepContainer.cs
- HttpClientCertificate.cs
- BasicBrowserDialog.designer.cs
- CompositeDataBoundControl.cs
- VBCodeProvider.cs
- ProxyWebPartConnectionCollection.cs
- TaskFileService.cs
- ClusterSafeNativeMethods.cs
- FileDataSource.cs
- TextViewSelectionProcessor.cs
- BamlLocalizabilityResolver.cs
- XsdValidatingReader.cs
- TextRangeEditLists.cs
- basenumberconverter.cs
- SchemaTableOptionalColumn.cs
- ConnectionOrientedTransportChannelListener.cs
- DataMisalignedException.cs
- PersistenceTypeAttribute.cs
- AsyncPostBackTrigger.cs
- XmlAttributes.cs
- NotImplementedException.cs
- ReaderWriterLock.cs
- SortDescription.cs
- RequestQueue.cs
- DataGridViewCellParsingEventArgs.cs
- PrtTicket_Base.cs
- DataObject.cs
- BaseCollection.cs
- QilList.cs
- WSSecurityPolicy11.cs
- VersionedStreamOwner.cs
- ClientRolePrincipal.cs
- XmlSerializerNamespaces.cs
- RadioButtonAutomationPeer.cs
- Authorization.cs
- ColumnResizeAdorner.cs
- DataGridParentRows.cs
- ProfileParameter.cs
- HGlobalSafeHandle.cs
- XmlILTrace.cs
- CuspData.cs
- UdpMessageProperty.cs
- InstanceKeyView.cs
- SerializationAttributes.cs
- EncryptRequest.cs
- CutCopyPasteHelper.cs
- DtdParser.cs
- DiscoveryMessageSequence11.cs
- AspCompat.cs
- ISAPIWorkerRequest.cs
- TraceData.cs
- MailAddressCollection.cs
- streamingZipPartStream.cs
- TextFormatterContext.cs
- ProcessProtocolHandler.cs
- UInt32Storage.cs
- StreamMarshaler.cs
- ContextItem.cs
- PagedDataSource.cs
- SrgsGrammar.cs
- UnsafeNativeMethods.cs
- Errors.cs
- PolyBezierSegment.cs
- IncrementalReadDecoders.cs
- BitmapImage.cs
- ProgressiveCrcCalculatingStream.cs
- RequiredAttributeAttribute.cs