public int UpdateComponents(ParentChildRelationHierarchy hierarchy) { var updatedCount = 0; foreach (var relation in hierarchy.GetAllParentChildRelations()) { var sourceObject = relation.Child; var mapping = _mappings[sourceObject.GetType()]; var tuple = mapping.GetComponentInfo(sourceObject); var component = _session.GetChildComponent(relation); if (!HasChanges(component, tuple.Item2)) { continue; } component.Fields.Clear(); foreach (var pair in tuple.Item2) { component.Fields.Add(pair.Key, pair.Value); } _session.UpdateComponent(component); updatedCount++; } return(updatedCount); }
public int UpdateComponentTags(ParentChildRelationHierarchy hierarchy) { var updatedCount = 0; var tpl = GetComponentTagMap(); var componentTagMap = tpl.Item2; var componentMap = new Dictionary <Type, List <Component> >(); foreach (var relation in hierarchy.GetAllParentChildRelations()) { var sourceObject = relation.Child; var mapping = _mappings[sourceObject.GetType()]; var tuple = mapping.GetComponentInfo(sourceObject); var component = _session.GetChildComponent(relation); var tags = mapping.GetTags(sourceObject); if ((tags == null || !tags.Any()) && !componentTagMap.ContainsKey(component.Id)) { continue; } updatedCount += MaintainTagsForComponent(tags, component, _session.GetAllTags()); } return(updatedCount); }