public QualitySpecification CreateCopy() { QualitySpecification result = CreateEmptyCopy(string.Format("Copy of {0}", Name)); foreach (QualitySpecificationElement element in _elements) { result.AddElement(element.QualityCondition, element.StopOnErrorOverride, element.AllowErrorsOverride); } return(result); }
public QualitySpecification Union([NotNull] QualitySpecification other, out int equal) { Assert.ArgumentNotNull(other, nameof(other)); var result = new QualitySpecification(Name + "*" + other.Name) { _isUnion = true }; equal = 0; var minOther = 0; // index des minimalen other elements, das noch nicht geprueft wurde, ob es in die union gehoert foreach (QualitySpecificationElement thisElement in _elements) { bool stopOnError = thisElement.StopOnError; bool allowErrors = thisElement.AllowErrors; bool enabled = thisElement.Enabled; int otherIndex = other.IndexOf(thisElement.QualityCondition); if (otherIndex >= 0) { QualitySpecificationElement otherElement; for (int idxOther = minOther; idxOther < otherIndex; idxOther++) { otherElement = other._elements[idxOther]; QualityCondition otherCond = otherElement.QualityCondition; if (IndexOf(otherCond) >= 0 || result.IndexOf(otherCond) >= 0) { continue; } result.AddElement(otherElement.QualityCondition, otherElement.StopOnError, otherElement.AllowErrors, !otherElement.Enabled); equal |= 2; // == equal = equal | 2; Beispiel equal = 1 --> nachher equal = 1 | 2 = 3 } minOther = otherIndex; otherElement = other._elements[otherIndex]; if (stopOnError != otherElement.StopOnError) { equal |= stopOnError ? 1 : 2; stopOnError = true; } if (allowErrors != otherElement.AllowErrors) { equal |= allowErrors ? 1 : 2; allowErrors = true; } } else { equal |= 1; } result.AddElement(thisElement.QualityCondition, stopOnError, allowErrors, !enabled); } foreach (QualitySpecificationElement otherElement in other._elements) { int unionIndex = result.IndexOf(otherElement.QualityCondition); if (unionIndex >= 0) { continue; } equal |= 2; result.AddElement(otherElement.QualityCondition, otherElement.StopOnError, otherElement.AllowErrors, !otherElement.Enabled); } return(result); }