// effects: Given a set of values in domain // Returns all possible values that are present in domain. static CellConstantSet DeterminePossibleValues(IEnumerable <Constant> domain) { // E.g., if we have 1, 2, NOT(1) --> Result = 1, 2 // 1, NOT(1, 2) --> Result = 1, 2 // 1, 2, NOT(NULL) --> Result = 1, 2, NULL // 1, 2, NOT(2), NOT(3, 4) --> Result = 1, 2, 3, 4 CellConstantSet result = new CellConstantSet(Constant.EqualityComparer); foreach (Constant constant in domain) { NegatedConstant negated = constant as NegatedConstant; if (negated != null) { // Go through all the constants in negated and add them to domain // We add them to possible values also even if (say) Null is not allowed because we want the complete // partitioning of the space, e.g., if the values specified by the caller are 1, NotNull -> we want 1, Null foreach (Constant constElement in negated.Elements) { Debug.Assert(constElement as NegatedConstant == null, "Negated cell constant inside NegatedCellConstant"); result.Add(constElement); } } else { result.Add(constant); } } return(result); }
// effects: Given a member, determines all possible values that can be created from Metadata internal static CellConstantSet DeriveDomainFromMemberPath(MemberPath memberPath, EdmItemCollection edmItemCollection, bool leaveDomainUnbounded) { CellConstantSet domain = DeriveDomainFromType(memberPath.EdmType, edmItemCollection, leaveDomainUnbounded); if (memberPath.IsNullable) { domain.Add(Constant.Null); } return(domain); }
// effects: Given a set of values in domain // Returns all possible values that are present in domain. static CellConstantSet DeterminePossibleValues(IEnumerable<Constant> domain) { // E.g., if we have 1, 2, NOT(1) --> Result = 1, 2 // 1, NOT(1, 2) --> Result = 1, 2 // 1, 2, NOT(NULL) --> Result = 1, 2, NULL // 1, 2, NOT(2), NOT(3, 4) --> Result = 1, 2, 3, 4 CellConstantSet result = new CellConstantSet(Constant.EqualityComparer); foreach (Constant constant in domain) { NegatedConstant negated = constant as NegatedConstant; if (negated != null) { // Go through all the constants in negated and add them to domain // We add them to possible values also even if (say) Null is not allowed because we want the complete // partitioning of the space, e.g., if the values specified by the caller are 1, NotNull -> we want 1, Null foreach (Constant constElement in negated.Elements) { Debug.Assert(constElement as NegatedConstant == null, "Negated cell constant inside NegatedCellConstant"); result.Add(constElement); } } else { result.Add(constant); } } return result; }