Profile Picture

PersistencyFormat.CutomBinary and NDrawingDocument clone problems

Posted By Alexey Ochkov 11 Years Ago

PersistencyFormat.CutomBinary and NDrawingDocument clone problems

Author
Message
Alexey Ochkov
Posted 11 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 6, Visits: 15
1) When I save NDrawingDocument to PersistencyFormat.CutomBinary (from my program or from standard Nevron.Diagram.Designer.exe) links between ports and plugs are not saved. I send examples docs.zip with document saved in NDB (all links are ok) and CNDB (all links are broken).

2) NDrawingDocument implements ICloneable interface and CloneWithNewUniqueId method, but both possible clone methods fails when called. It is possible to clone NDrawingDocument without saving anl loading it from temporary file or memory stream? (on implementing cloning through save/restore from memory stream I found error with PersistencyFormat.CutomBinary).




Attachments
docs.zip (506 views, 15.00 KB)
Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 1 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi,

The problems with connectors serialization in binary format is fixed in the latest version of Nevron Diagram for .NET. In order to clone a drawing document you can now create a simple method that serializes the drawing document to a memory stream in binary format and then deserializes it from the same stream. The following is a simple implementation of such method:

private static NDrawingDocument CloneDocument(NDrawingDocument document)
{
    NDrawingDocument clonedDocument;
    using (MemoryStream stream = new MemoryStream())
    {
        // Serialize the document to stream
        NPersistencyManager manager = new NPersistencyManager();
        manager.Persistentdocument.Sections.Add(new NPersistentSection("Drawing", document));
        manager.SaveToStream(stream, PersistencyFormat.Binary, null);

        // Deserialize the document from the stream
        manager.LoadFromStream(stream, PersistencyFormat.Binary, null);
        clonedDocument = (NDrawingDocument)manager.Persistentdocument.Sections.GetByName("Drawing").Object;
    }

    return clonedDocument;
}



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic