Пример #1
0
        public override bool Equals(object obj)
        {
            bool equal = false;

            if (obj.GetType().Name == "StringPair")
            {
                StringPair comparePair = (StringPair)obj;
                equal = (comparePair.Dependant == this.Dependant && comparePair.Independant == this.Independant);
            }
            else
            {
                equal = base.Equals(obj);
            }
            return(equal);
        }
Пример #2
0
 public void Validate(List <Segment> segments)
 {
     foreach (Segment segToValidate in segments)
     {
         string error    = "";
         string indValue = ((StringProperty)segToValidate[indPropertyName]).Value;
         string depValue = ((StringProperty)segToValidate[depPropertyName]).Value;
         if (!(acceptable.Contains(new StringPair(indValue, depValue))))
         {
             error = "Invalid value pair: (" + indPropertyName + "," + depPropertyName + ") = (" + indValue + "," + depValue + ").";
             if (correctErrors)
             {
                 StringPair stringPairKey = null;
                 foreach (StringPair potentialKey in correction.Keys)
                 {
                     if (potentialKey.Equals(new StringPair(indValue, depValue)))
                     {
                         stringPairKey = potentialKey;
                         break;
                     }
                 }
                 if (stringPairKey != null)
                 {
                     ((StringProperty)segToValidate[depPropertyName]).Value = correction[stringPairKey];
                     error += "  Replaced dependent value with " + correction[stringPairKey] + ".";
                 }
                 else
                 {
                     error += "  Could not find replacement value.";
                     segToValidate.Exclude = true;
                 }
             }
             segToValidate.AddError(error);
         }
     }
 }