private static void AddSetByDerivedNos(INamedObjectContainer namedObjectContainer, NamedObjectSave namedObjectSetByDerived, bool instantiatedByBase) { NamedObjectSave existingNamedObject = null; foreach (NamedObjectSave namedObjectInDerived in namedObjectContainer.NamedObjects) { if (namedObjectInDerived.InstanceName == namedObjectSetByDerived.InstanceName) { existingNamedObject = namedObjectInDerived; break; } } if (existingNamedObject != null) { existingNamedObject.DefinedByBase = true; existingNamedObject.InstantiatedByBase = instantiatedByBase; } else { NamedObjectSave namedObjectSave = namedObjectSetByDerived.Clone(); namedObjectSave.SetDefinedByBaseRecursively(true); namedObjectSave.SetInstantiatedByBaseRecursively(instantiatedByBase); // This can't be set by derived because an object it inherits from has that already set namedObjectSave.SetSetByDerivedRecursively(false); namedObjectContainer.NamedObjects.Add(namedObjectSave); } }