PersistencyFormat.CutomBinary and NDrawingDocument clone problems


PersistencyFormat.CutomBinary and NDrawingDocument clone problems
Author
Message
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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


Alexey Ochkov
Alexey Ochkov
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
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 (567 views, 15.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search