Exemple #1
0
        void BuildLookupTable()
        {
            // initialize
            lookupTables = new Hashtable[this.parameters.Count];
            for (int i = 0; i < this.parameters.Count; ++i)
            {
                PairwiseParameter       pp     = this.parameters[i];
                PairwiseValueCollection values = pp.Values;
                Hashtable h = new Hashtable(values.Count);

                foreach (PairwiseValue pv in values)
                {
                    string key = LookupInputValue(pv);

                    h[key] = pv;
                    if (pv.Aliases.Count != 0)
                    {
                        foreach (PairwiseValue a in pv.Aliases)
                        {
                            h[LookupInputValue(a)] = a;
                        }
                    }
                }

                lookupTables[i] = h;
            }
        }
Exemple #2
0
        internal PairwiseComparisonTerm(PairwiseComparison comparison, PairwiseParameter left, PairwiseParameter rightParam, PairwiseValue rightVal) : base(left)
        {
            if (rightVal == null && rightParam == null)
            {
                throw new ArgumentException("Can't have both val and param == null!");
            }

            if (rightVal != null && rightParam != null)
            {
                throw new ArgumentException("Can't have both val and param non-null!");
            }

            if (left == rightParam)
            {
                throw new ArgumentException("Can't have the same two parameters in the same comparison");
            }

            this.rel          = comparison;
            this.rhsValue     = rightVal;
            this.rhsParameter = rightParam;
            if (rightVal != null && !this.Parameter.IsCompatibleWith(rightVal))
            {
                throw new ArgumentException(string.Format("Mismatched types: {0} != {1}", left.PairwiseValueType, rightVal.PairwiseValueType));
            }

            if (rightParam != null && !this.Parameter.IsCompatibleWith(rightParam))
            {
                throw new ArgumentException(string.Format("Mismatched types: {0} != {1}", left.PairwiseValueType, rightParam.PairwiseValueType));
            }

            if (!this.Parameter.IsCompatibleWith(rel))
            {
                throw new NotSupportedException("Not supported: " + rel + " on " + this.Parameter + "; might be possible, though!");
            }
        }
Exemple #3
0
 public PairwiseValue this[PairwiseParameter parameter]
 {
     get
     {
         return(this[parameter.Name]);
     }
 }
Exemple #4
0
        public void Insert(int index, PairwiseParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            InnerList.Insert(index, parameter);
        }
Exemple #5
0
        public int IndexOf(PairwiseParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            return(InnerList.IndexOf(parameter));
        }
Exemple #6
0
        public bool Contains(PairwiseParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            return(InnerList.Contains(parameter));
        }
Exemple #7
0
        public void Remove(PairwiseParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            InnerList.Remove(parameter);
        }
Exemple #8
0
        protected override void OnValidate(object value)
        {
            base.OnValidate(value);

            PairwiseParameter parameter = value as PairwiseParameter;

            if (parameter == null)
            {
                throw new ArgumentException("PairwiseParameter");
            }
        }
Exemple #9
0
        public PairwiseLikeTerm(PairwiseParameter parameter, string wildcardPattern) : base(parameter)
        {
            if (wildcardPattern == null)
            {
                throw new ArgumentNullException("wildcardPattern");
            }

            // NOTE: theoretically, you could use "Like" with enums, but that fails when flags are involved
            if (parameter.PairwiseValueType != PairwiseValueType.String)
            {
                throw new ArgumentOutOfRangeException("parameter", parameter.PairwiseValueType, "Non-string value type given to Like operator");
            }

            this.wildcardPattern = wildcardPattern;
        }
Exemple #10
0
        string GetParameterLine(PairwiseParameter p)
        {
            StringBuilder sb = new StringBuilder(128);

            foreach (PairwiseValue o in p.Values)
            {
                if (sb.Length != 0)
                {
                    sb.Append(context.Settings.ValueDelimiter);
                }

                sb.Append(context.LookupValuesAndAliases(o));
            }

            return(string.Format("{0}{1}: {2}", GetComment(p), context.LookupName(p), sb));
        }
Exemple #11
0
        public PairwiseParameterConstraint(PairwiseParameter first, PairwiseComparison op, PairwiseParameter second) : base(first)
        {
            this.op     = op;
            this.second = second;

            // only allow between the same strong-ish-types
            if (!this.First.IsCompatibleWith(second))
            {
                throw new ArgumentException(string.Format("{0} != {1}", this.First.PairwiseValueType, this.second.PairwiseValueType));
            }

            bool isrelative     = !(op == PairwiseComparison.Equal || op == PairwiseComparison.NotEqual);
            PairwiseValueType t = this.First.PairwiseValueType;

            if (isrelative)
            {
                if (t == PairwiseValueType.Enum || t == PairwiseValueType.ComplexObject)
                {
                    throw new NotSupportedException("Not supported: " + op + " on " + t + "; might be possible, though!");
                }
            }
        }
Exemple #12
0
 public PairwiseLessThanOrEqualTerm LessThanOrEqual(PairwiseParameter parameter)
 {
     return(new PairwiseLessThanOrEqualTerm(this, parameter));
 }
Exemple #13
0
 public PairwiseNotEqualTerm NotEqual(PairwiseParameter parameter)
 {
     return(new PairwiseNotEqualTerm(this, parameter));
 }
Exemple #14
0
 public PairwiseGreaterThanOrEqualTerm GreaterThanOrEqual(PairwiseParameter parameter)
 {
     return(new PairwiseGreaterThanOrEqualTerm(this, parameter));
 }
Exemple #15
0
 internal bool IsCompatibleWith(PairwiseParameter parameter)
 {
     return(this.PairwiseValueType == parameter.PairwiseValueType);
 }
Exemple #16
0
 public void Add(PairwiseParameter first, params PairwiseParameter[] others)
 {
     this.parameters.Add(first, others);
 }
Exemple #17
0
 public PairwiseEqualTerm Equal(PairwiseParameter parameter)
 {
     // this constructor throws if not correct
     return(new PairwiseEqualTerm(this, parameter));
 }
Exemple #18
0
 public string LookupName(PairwiseParameter parameter)
 {
     return(parameter.Name);
 }
Exemple #19
0
 public void Add(PairwiseParameter parameter)
 {
     this.parameters.Add(parameter);
 }
 public PairwiseNotEqualTerm(PairwiseParameter parameter, PairwiseParameter right) : base(PairwiseComparison.NotEqual, parameter, right, null)
 {
 }
Exemple #21
0
 public void Add(PairwiseParameter first, params PairwiseParameter[] parameters)
 {
     this.Add(first);
     this.InnerList.AddRange(parameters);
 }
 public PairwiseNotEqualTerm(PairwiseParameter parameter, PairwiseValue value) : base(PairwiseComparison.NotEqual, parameter, null, value)
 {
 }
 public PairwiseGreaterThanOrEqualTerm(PairwiseParameter parameter, PairwiseParameter right) : base(PairwiseComparison.GreaterThanOrEqual, parameter, right, null)
 {
 }
 public PairwiseLessThanTerm(PairwiseParameter parameter, PairwiseValue value) : base(PairwiseComparison.LessThan, parameter, null, value)
 {
 }
Exemple #25
0
 public PairwiseInTerm(PairwiseParameter parameter, PairwiseValueCollection values) : base(parameter)
 {
     this.values = new PairwiseValueCollection(Check(values));
 }
Exemple #26
0
 internal PairwiseTerm(PairwiseParameter parameter)
 {
     this.parameter = parameter;
 }
 public PairwiseLessThanTerm(PairwiseParameter parameter, PairwiseParameter right) : base(PairwiseComparison.LessThan, parameter, right, null)
 {
 }
 public PairwiseGreaterThanOrEqualTerm(PairwiseParameter parameter, PairwiseValue value) : base(PairwiseComparison.GreaterThanOrEqual, parameter, null, value)
 {
 }