//istniejÄ…cy obiekt public static void DuplicateShiftAttributes(XElement source, Document destination) { var attrsToDuplicate = DuplicableAttributeFactory.ShiftDuplicableAttributesList(source); if (attrsToDuplicate.Count > 0) { foreach (XElement attrToDuplicate in attrsToDuplicate) { string documentFieldId = attrToDuplicate.Element(XmlName.DocumentFieldId).Value; DocumentField documentField = DictionaryMapper.Instance.GetDocumentField(new Guid(documentFieldId)); DocumentFieldName documentFieldName = documentField.TypeName; DocumentAttrValue destAttr = destination.Attributes.GetOrCreateNew(documentFieldName); destAttr.Value = new XElement(XmlName.Value, attrToDuplicate.Element(XmlName.Value).Nodes()); } } }
//nowy obiekt tylko nowe atrybuty public static void DuplicateShiftAttributes(XElement source, XDocument destination) { var attrsToDuplicate = DuplicableAttributeFactory.ShiftDuplicableAttributesList(source); if (attrsToDuplicate.Count > 0) { var destAttrsElement = destination.XPathSelectElement("/*/*/attributes"); var destAttrs = destAttrsElement.Elements(XmlName.Attribute); int order = destAttrs.Count() + 1; foreach (XElement attrToDuplicate in attrsToDuplicate) { XElement attr = new XElement(XmlName.Attribute , new XElement(XmlName.Id, Guid.NewGuid().ToUpperString()) , new XElement(attrToDuplicate.Element(XmlName.Value)) , new XElement(attrToDuplicate.Element(XmlName.DocumentFieldId)) , new XElement(XmlName.Order, order) ); destAttrsElement.Add(attr); order++; } } }