/// <summary> /// Replace fields from another item /// </summary> /// <param name="item">DatItem to pull new information from</param> /// <param name="fields">List of Fields representing what should be updated</param> public override void ReplaceFields(DatItem item, List <Field> fields) { // Replace common fields first base.ReplaceFields(item, fields); // If we don't have a Adjuster to replace from, ignore specific fields if (item.ItemType != ItemType.Adjuster) { return; } // Cast for easier access Adjuster newItem = item as Adjuster; // Replace the fields if (fields.Contains(Field.DatItem_Name)) { Name = newItem.Name; } if (fields.Contains(Field.DatItem_Default)) { Default = newItem.Default; } // DatItem_Condition_* doesn't make sense here // since not every condition under the other item // can replace every condition under this item }
public override bool Equals(DatItem other) { // If we don't have a Adjuster, return false if (ItemType != other.ItemType) { return(false); } // Otherwise, treat it as a Adjuster Adjuster newOther = other as Adjuster; // If the Adjuster information matches bool match = (Name == newOther.Name && Default == newOther.Default); if (!match) { return(match); } // If the conditions match if (ConditionsSpecified) { foreach (Condition condition in Conditions) { match &= newOther.Conditions.Contains(condition); } } return(match); }