Exemplo n.º 1
0
        private static SrmDocument CopyPaste(SrmDocument sourceDoc, IEnumerable <DocNode> nodes, SrmDocument targetDoc, IdentityPath to)
        {
            SetDefaultModifications(targetDoc);
            if (nodes != null)
            {
                sourceDoc = sourceDoc.RemoveAllBut(nodes);
            }

            var stringWriter = new XmlStringWriter();

            using (var writer = new XmlTextWriter(stringWriter)
            {
                Formatting = Formatting.Indented
            })
            {
                XmlSerializer ser = new XmlSerializer(typeof(SrmDocument));
                ser.Serialize(writer, sourceDoc);
            }
            IdentityPath newPath, nextAdd;

            targetDoc = targetDoc.ImportDocumentXml(new StringReader(stringWriter.ToString()),
                                                    null,
                                                    MeasuredResults.MergeAction.remove,
                                                    false,
                                                    null,
                                                    Settings.Default.StaticModList,
                                                    Settings.Default.HeavyModList,
                                                    to,
                                                    out newPath,
                                                    out nextAdd,
                                                    false);
            return(targetDoc);
        }
Exemplo n.º 2
0
        private static SrmDocument CopyPaste(SrmDocument sourceDoc, IEnumerable<DocNode> nodes, SrmDocument targetDoc, IdentityPath to)
        {
            SetDefaultModifications(targetDoc);
            if(nodes != null)
                sourceDoc = sourceDoc.RemoveAllBut(nodes);

            var stringWriter = new XmlStringWriter();
            using (var writer = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented })
            {
                XmlSerializer ser = new XmlSerializer(typeof(SrmDocument));
                ser.Serialize(writer, sourceDoc);
            }
            IdentityPath newPath, nextAdd;
            targetDoc = targetDoc.ImportDocumentXml(new StringReader(stringWriter.ToString()),
                                                    null,
                                                    MeasuredResults.MergeAction.remove,
                                                    false,
                                                    null,
                                                    Settings.Default.StaticModList,
                                                    Settings.Default.HeavyModList,
                                                    to,
                                                    out newPath,
                                                    out nextAdd,
                                                    false);
            return targetDoc;
        }