本文整理汇总了C#中BoolExpression类的典型用法代码示例。如果您正苦于以下问题:C# BoolExpression类的具体用法?C# BoolExpression怎么用?C# BoolExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoolExpression类属于命名空间,在下文中一共展示了BoolExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Then
public Then(BoolExpression condition, Action thenAction, Action elseAction, object cookie)
{
this.condition=condition;
this.thenAction=thenAction;
this.elseAction=elseAction;
this.cookie=cookie;
}
示例2: CqlBlock
/// <summary>
/// Initializes a <see cref="CqlBlock"/> with the SELECT (<paramref name="slotInfos"/>), FROM (<paramref name="children"/>),
/// WHERE (<paramref name="whereClause"/>), AS (<paramref name="blockAliasNum"/>).
/// </summary>
protected CqlBlock(SlotInfo[] slotInfos, List<CqlBlock> children, BoolExpression whereClause, CqlIdentifiers identifiers, int blockAliasNum)
{
m_slots = new ReadOnlyCollection<SlotInfo>(slotInfos);
m_children = new ReadOnlyCollection<CqlBlock>(children);
m_whereClause = whereClause;
m_blockAlias = identifiers.GetBlockAlias(blockAliasNum);
}
示例3: BooleanProjectedSlot
/// <summary>
/// Creates a boolean slot for expression that comes from originalCellNum, i.e.,
/// the value of the slot is <paramref name="expr"/> and the name is "_from{<paramref name="originalCellNum"/>}", e.g., _from2
/// </summary>
internal BooleanProjectedSlot(BoolExpression expr, CqlIdentifiers identifiers, int originalCellNum)
{
m_expr = expr;
m_originalCell = new CellIdBoolean(identifiers, originalCellNum);
Debug.Assert(!(expr.AsLiteral is CellIdBoolean) ||
BoolLiteral.EqualityComparer.Equals((CellIdBoolean)expr.AsLiteral, m_originalCell), "Cellid boolean for the slot and cell number disagree");
}
示例4: ExtentCqlBlock
/// <summary>
/// Creates an cql block representing the <paramref name="extent"/> (the FROM part).
/// SELECT is given by <paramref name="slots"/>, WHERE by <paramref name="whereClause"/> and AS by <paramref name="blockAliasNum"/>.
/// </summary>
internal ExtentCqlBlock(EntitySetBase extent,
CellQuery.SelectDistinct selectDistinct,
SlotInfo[] slots,
BoolExpression whereClause,
CqlIdentifiers identifiers,
int blockAliasNum)
: base(slots, EmptyChildren, whereClause, identifiers, blockAliasNum)
{
m_extent = extent;
m_nodeTableAlias = identifiers.GetBlockAlias();
m_selectDistinct = selectDistinct;
}
示例5: CellQuery
// effects: Given all the fields, just sets them.
internal CellQuery(
ProjectedSlot[] projectedSlots,
BoolExpression whereClause,
List<BoolExpression> boolExprs,
SelectDistinct elimDupl, MemberPath rootMember)
{
m_boolExprs = boolExprs;
m_projectedSlots = projectedSlots;
m_whereClause = whereClause;
m_originalWhereClause = whereClause;
m_selectDistinct = elimDupl;
m_extentMemberPath = rootMember;
}
示例6: CqlGenerator
/// <summary>
/// Given the generated <paramref name="view"/>, the <paramref name="caseStatements"/> for the multiconstant fields,
/// the <paramref name="projectedSlotMap"/> that maps different paths of the entityset (for which the view is being generated) to slot indexes in the view,
/// creates an object that is capable of generating the Cql for <paramref name="view"/>.
/// </summary>
internal CqlGenerator(CellTreeNode view,
Dictionary<MemberPath,
CaseStatement> caseStatements,
CqlIdentifiers identifiers,
MemberProjectionIndex projectedSlotMap,
int numCellsInView,
BoolExpression topLevelWhereClause,
StorageMappingItemCollection mappingItemCollection)
{
m_view = view;
m_caseStatements = caseStatements;
m_projectedSlotMap = projectedSlotMap;
m_numBools = numCellsInView; // We have that many booleans
m_topLevelWhereClause = topLevelWhereClause;
m_identifiers = identifiers;
m_mappingItemCollection = mappingItemCollection;
}
示例7: CaseCqlBlock
internal CaseCqlBlock(
SlotInfo[] slots, int caseSlot, CqlBlock child, BoolExpression whereClause, CqlIdentifiers identifiers, int blockAliasNum)
: base(slots, new List<CqlBlock>(new[] { child }), whereClause, identifiers, blockAliasNum)
{
m_caseSlotInfo = slots[caseSlot];
}
示例8: While
public While(BoolExpression condition)
{
this.condition=condition;
this.cookie=FuncBuilder.Instance.StartInflightUtterance("While requires a Do");
}
示例9: ExtractProperties
// requires: "properties" corresponds to all the properties that are
// inside cNode.Value, e.g., cNode corresponds to an extent Person,
// properties contains all the properties inside Person (recursively)
// effects: Given C-side and S-side Cell Query for a cell, generates
// the projected slots on both sides corresponding to
// properties. Also updates the C-side whereclause corresponding to
// discriminator properties on the C-side, e.g, isHighPriority
private void ExtractProperties(
IEnumerable<StoragePropertyMapping> properties,
MemberPath cNode, List<ProjectedSlot> cSlots,
ref BoolExpression cQueryWhereClause,
MemberPath sRootExtent,
List<ProjectedSlot> sSlots,
ref BoolExpression sQueryWhereClause)
{
// For each property mapping, we add an entry to the C and S cell queries
foreach (var propMap in properties)
{
var scalarPropMap = propMap as StorageScalarPropertyMapping;
var complexPropMap = propMap as StorageComplexPropertyMapping;
var associationEndPropertypMap = propMap as StorageEndPropertyMapping;
var conditionMap = propMap as StorageConditionPropertyMapping;
Debug.Assert(
scalarPropMap != null ||
complexPropMap != null ||
associationEndPropertypMap != null ||
conditionMap != null, "Unimplemented property mapping");
if (scalarPropMap != null)
{
Debug.Assert(scalarPropMap.ColumnProperty != null, "ColumnMember for a Scalar Property can not be null");
// Add an attribute node to node
var cAttributeNode = new MemberPath(cNode, scalarPropMap.EdmProperty);
// Add a column (attribute) node the sQuery
// unlike the C side, there is no nesting. Hence we
// did not need an internal node
var sAttributeNode = new MemberPath(sRootExtent, scalarPropMap.ColumnProperty);
cSlots.Add(new MemberProjectedSlot(cAttributeNode));
sSlots.Add(new MemberProjectedSlot(sAttributeNode));
}
// Note: S-side constants are not allowed since they can cause
// problems -- for example, if such a cell says 5 for the
// third field, we cannot guarantee the fact that an
// application may not set that field to 7 in the C-space
// Check if the property mapping is for a complex types
if (complexPropMap != null)
{
foreach (var complexTypeMap in complexPropMap.TypeMappings)
{
// Create a node for the complex type property and call recursively
var complexMemberNode = new MemberPath(cNode, complexPropMap.EdmProperty);
//Get the list of types that this type map represents
var allTypes = new Set<EdmType>();
// Gather a set of all explicit types for an entity
// type mapping in allTypes.
var exactTypes = Helpers.AsSuperTypeList<ComplexType, EdmType>(complexTypeMap.Types);
allTypes.AddRange(exactTypes);
foreach (EdmType type in complexTypeMap.IsOfTypes)
{
allTypes.AddRange(
MetadataHelper.GetTypeAndSubtypesOf(
type, m_containerMapping.StorageMappingItemCollection.EdmItemCollection, false /*includeAbstractTypes*/));
}
var complexInTypes = BoolExpression.CreateLiteral(new TypeRestriction(complexMemberNode, allTypes), null);
cQueryWhereClause = BoolExpression.CreateAnd(cQueryWhereClause, complexInTypes);
// Now extract the properties of the complex type
// (which could have other complex types)
ExtractProperties(
complexTypeMap.AllProperties, complexMemberNode, cSlots,
ref cQueryWhereClause, sRootExtent, sSlots, ref sQueryWhereClause);
}
}
// Check if the property mapping is for an associaion
if (associationEndPropertypMap != null)
{
// create join tree node representing this relation end
var associationEndNode = new MemberPath(cNode, associationEndPropertypMap.EndMember);
// call recursively
ExtractProperties(
associationEndPropertypMap.Properties, associationEndNode, cSlots,
ref cQueryWhereClause, sRootExtent, sSlots, ref sQueryWhereClause);
}
//Check if the this is a condition and add it to the Where clause
if (conditionMap != null)
{
if (conditionMap.ColumnProperty != null)
{
//Produce a Condition Expression for the Condition Map.
var conditionExpression = GetConditionExpression(sRootExtent, conditionMap);
//Add the condition expression to the exisiting S side Where clause using an "And"
sQueryWhereClause = BoolExpression.CreateAnd(sQueryWhereClause, conditionExpression);
}
else
{
//.........这里部分代码省略.........
示例10: FindRewritingAndUsedViews
// Find rewriting for query SELECT <attributes> WHERE <whereClause> FROM _extentPath
// and add view appearing in rewriting to outputUsedViews
private bool FindRewritingAndUsedViews(
IEnumerable<MemberPath> attributes, BoolExpression whereClause,
HashSet<FragmentQuery> outputUsedViews, out Tile<FragmentQuery> rewriting)
{
IEnumerable<MemberPath> notCoveredAttributes;
return FindRewritingAndUsedViews(
attributes, whereClause, outputUsedViews, out rewriting,
out notCoveredAttributes);
}
示例11: UpdateWhereClause
// requires: The CellConstantDomains in the OneOfConsts of the where
// clause are partially done
// effects: Given the domains of different variables in domainMap,
// fixes the whereClause of this such that all the
// CellConstantDomains in OneOfConsts are complete
internal void UpdateWhereClause(MemberDomainMap domainMap)
{
var atoms = new List<BoolExpression>();
foreach (var atom in WhereClause.Atoms)
{
var literal = atom.AsLiteral;
var restriction = literal as MemberRestriction;
Debug.Assert(restriction != null, "All bool literals must be OneOfConst at this point");
// The oneOfConst needs to be fixed with the new possible values from the domainMap.
var possibleValues = domainMap.GetDomain(restriction.RestrictedMemberSlot.MemberPath);
var newOneOf = restriction.CreateCompleteMemberRestriction(possibleValues);
// Prevent optimization of single constraint e.g: "300 in (300)"
// But we want to optimize type constants e.g: "category in (Category)"
// To prevent optimization of bool expressions we add a Sentinel OneOF
var scalarConst = restriction as ScalarRestriction;
var addSentinel =
scalarConst != null &&
!scalarConst.Domain.Contains(Constant.Null) &&
!scalarConst.Domain.Contains(Constant.NotNull) &&
!scalarConst.Domain.Contains(Constant.Undefined);
if (addSentinel)
{
domainMap.AddSentinel(newOneOf.RestrictedMemberSlot.MemberPath);
}
atoms.Add(BoolExpression.CreateLiteral(newOneOf, domainMap));
if (addSentinel)
{
domainMap.RemoveSentinel(newOneOf.RestrictedMemberSlot.MemberPath);
}
}
// We create a new whereClause that has the memberDomainMap set
if (atoms.Count > 0)
{
m_whereClause = BoolExpression.CreateAnd(atoms.ToArray());
}
}
示例12: EnsureConfigurationIsFullyMapped
// make sure that we can find a rewriting for each possible entity shape appearing in an extent
// Possible optimization for OfType view generation:
// Cache "used views" for each (currentPath, domainValue) combination
private void EnsureConfigurationIsFullyMapped(
MemberPath currentPath,
BoolExpression currentWhereClause,
HashSet<FragmentQuery> outputUsedViews,
ErrorLog errorLog)
{
foreach (var domainValue in GetDomain(currentPath))
{
if (domainValue == Constant.Undefined)
{
continue; // no point in trying to recover a situation that can never happen
}
TraceVerbose("REWRITING FOR {0}={1}", currentPath, domainValue);
// construct WHERE clause for this value
var domainAddedWhereClause = CreateMemberCondition(currentPath, domainValue);
// AND the current where clause to it
var domainWhereClause = BoolExpression.CreateAnd(currentWhereClause, domainAddedWhereClause);
// first check whether we can recover instances of this type - don't care about the attributes - to produce a helpful error message
Tile<FragmentQuery> rewriting;
if (false == FindRewritingAndUsedViews(_keyAttributes, domainWhereClause, outputUsedViews, out rewriting))
{
if (!ErrorPatternMatcher.FindMappingErrors(_context, _domainMap, _errorLog))
{
var builder = new StringBuilder();
var extentName = StringUtil.FormatInvariant("{0}", _extentPath);
var whereClause = rewriting.Query.Condition;
whereClause.ExpensiveSimplify();
if (whereClause.RepresentsAllTypeConditions)
{
var tableString = Strings.ViewGen_Extent;
builder.AppendLine(Strings.ViewGen_Cannot_Recover_Types(tableString, extentName));
}
else
{
var entitiesString = Strings.ViewGen_Entities;
builder.AppendLine(Strings.ViewGen_Cannot_Disambiguate_MultiConstant(entitiesString, extentName));
}
RewritingValidator.EntityConfigurationToUserString(whereClause, builder);
var record = new ErrorLog.Record(
ViewGenErrorCode.AmbiguousMultiConstants, builder.ToString(), _context.AllWrappersForExtent, String.Empty);
errorLog.AddEntry(record);
}
}
else
{
var typeConstant = domainValue as TypeConstant;
if (typeConstant != null)
{
// we are enumerating types
var edmType = typeConstant.EdmType;
// If can recover the type, make sure can get all the necessary attributes (key is included for EntityTypes)
var nonConditionalAttributes =
GetNonConditionalScalarMembers(edmType, currentPath, _domainMap).Union(
GetNonConditionalComplexMembers(edmType, currentPath, _domainMap)).ToList();
IEnumerable<MemberPath> notCoverdAttributes;
if (nonConditionalAttributes.Count > 0
&&
!FindRewritingAndUsedViews(
nonConditionalAttributes, domainWhereClause, outputUsedViews, out rewriting, out notCoverdAttributes))
{
//Error: No mapping specified for some attributes
// remove keys
nonConditionalAttributes = new List<MemberPath>(nonConditionalAttributes.Where(a => !a.IsPartOfKey));
Debug.Assert(nonConditionalAttributes.Count > 0, "Must have caught key-only case earlier");
AddUnrecoverableAttributesError(notCoverdAttributes, domainAddedWhereClause, errorLog);
}
else
{
// recurse into complex members
foreach (var complexMember in GetConditionalComplexMembers(edmType, currentPath, _domainMap))
{
EnsureConfigurationIsFullyMapped(complexMember, domainWhereClause, outputUsedViews, errorLog);
}
// recurse into scalar members
foreach (var scalarMember in GetConditionalScalarMembers(edmType, currentPath, _domainMap))
{
EnsureConfigurationIsFullyMapped(scalarMember, domainWhereClause, outputUsedViews, errorLog);
}
}
}
}
}
}
示例13: If
public If(BoolExpression condition)
{
this.condition=condition;
this.cookie=FuncBuilder.Instance.StartInflightUtterance("If requires an Endif");
}
示例14: WithOptionalElse
public WithOptionalElse(BoolExpression condition, Action thenAction, Action elseAction, object cookie)
: base(condition, thenAction, elseAction, cookie)
{
}
示例15: AddUnrecoverableAttributesError
private void AddUnrecoverableAttributesError(
IEnumerable<MemberPath> attributes, BoolExpression domainAddedWhereClause, ErrorLog errorLog)
{
var builder = new StringBuilder();
var extentName = StringUtil.FormatInvariant("{0}", _extentPath);
var tableString = Strings.ViewGen_Extent;
var attributesString = StringUtil.ToCommaSeparatedString(GetTypeBasedMemberPathList(attributes));
builder.AppendLine(Strings.ViewGen_Cannot_Recover_Attributes(attributesString, tableString, extentName));
RewritingValidator.EntityConfigurationToUserString(domainAddedWhereClause, builder);
var record = new ErrorLog.Record(
ViewGenErrorCode.AttributesUnrecoverable, builder.ToString(), _context.AllWrappersForExtent, String.Empty);
errorLog.AddEntry(record);
}