// OVERLAP SAMPLE // RESULT CONFIG BASE CONFIG OVERLAPPER CONFIG // A2 = A1 <- A2 // B2 = UNDEF <- B2 // C1 = C1 <- UNDEF // UNDEF = UNDEF <- UNDEF /// <summary> /// This configValues will be the overlap of <paramref name="baseConfig"/>'s configValues with <paramref name="overlapperConfig"/>'s configValues. /// Note: if defintion is not NULL restrictions will be applied. /// </summary> /// <param name="baseConfig"></param> /// <param name="overlapperConfig"></param> public void Overlap(ConfigurationID baseConfig, ConfigurationID overlapperConfig) { List <ConfigValue> result = new List <ConfigValue>(); List <ConfigValue> aConfigs = new List <ConfigValue>(baseConfig.configValues); List <ConfigValue> bConfigs = new List <ConfigValue>(overlapperConfig.configValues); aConfigs = aConfigs.OrderBy(c => c.typeIndex).ToList(); bConfigs = bConfigs.OrderBy(c => c.typeIndex).ToList(); //Make them the same length if (aConfigs.Count < bConfigs.Count) { aConfigs.AddRange(bConfigs.GetRange(aConfigs.Count, bConfigs.Count - aConfigs.Count)); } else if (bConfigs.Count < aConfigs.Count) { bConfigs.AddRange(aConfigs.GetRange(aConfigs.Count, aConfigs.Count - bConfigs.Count)); } for (int i = 0; i < aConfigs.Count; i++) { result.Add(aConfigs[i].Overlap(bConfigs[i], true)); //<-- add with force type } if (definition != null) { result = definition.ApplyRestrictions(result, bConfigs).ToList(); } configValues = result; }
public override bool Same(ConfigurationIDBase other) { if (!Similar(other)) { return(false); } ConfigurationID otherID = other as ConfigurationID; if (configValues.Count != otherID.configValues.Count) { return(false); } if (configValues.Exists(v => !otherID.configValues.Exists(v2 => v2.typeIndex != v.typeIndex))) { return(false); } if (configValues.Exists(v => otherID.configValues.Exists(v2 => v2.typeIndex == v.typeIndex && v2.ValueIndex != v.ValueIndex))) { return(false); } return(true); }
/// <summary> /// Returns TRUE if all ConfigValues are similar. /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Similar(ConfigurationID other) { return(Similar(other.configValues)); }
/// <summary> /// Overlaps this configValues with other.configValues. /// </summary> /// <param name="other"></param> public void Overlap(ConfigurationID other) { Overlap(this, other); }