/// <summary> /// Registers (already existing) copies of the members of <paramref name="sourceCollection"/> into <paramref name="targetCollection"/>. /// </summary> public static void CopyRefCollection <T>(this IExolutioCloneable cloneable, IEnumerable <T> sourceCollection, UndirectCollection <T> targetCollection, ProjectVersion projectVersion, ElementCopiesMap createdCopies, bool asGuid = false) where T : ExolutioObject { foreach (T collectionItem in sourceCollection) { Guid guid = createdCopies.GetGuidForCopyOf(collectionItem); if (!asGuid) { targetCollection.Add(targetCollection.Project.TranslateComponent <T>(guid)); } else { targetCollection.AddAsGuidSilent(guid); } } }
public static void DeserializeWrappedIDRefCollection <T>(this IExolutioSerializable component, [NotNull] string collectionNodeName, [NotNull] string idRefAttribute, UndirectCollection <T> idRefCollection, XElement parentNode, SerializationContext context) where T : ExolutioObject { XElement collectionNode = parentNode.Element(context.ExolutioNS + collectionNodeName); if (collectionNode == null) { context.Log.AddErrorFormat(SerializationLogMessages.Collection_node__0__not_found_in_node__1__, collectionNodeName, parentNode); return; } int?count = null; if (collectionNode.Attribute("Count") == null) { context.Log.AddWarningFormat(SerializationLogMessages.Collection_node__0__missing_attribute__Count__, collectionNode); } else { count = int.Parse(collectionNode.Attribute("Count").Value); } int subelementsCount = 0; foreach (XElement xmlElement in collectionNode.Elements()) { Guid deserializedIdRef = component.DeserializeIDRef(idRefAttribute, xmlElement, context); idRefCollection.AddAsGuidSilent(deserializedIdRef); subelementsCount++; } if (count.HasValue && count != subelementsCount) { context.Log.AddWarningFormat(SerializationLogMessages.InconsistentCount, count, collectionNode, subelementsCount); } }