Example #1
0
 /// <summary>
 /// Creates an object representation of a bcf zip file.
 /// </summary>
 /// <param name="BCFZipData">A Stream of bytes representing a bcf .zip file</param>
 /// <returns>A new BCF object</returns>
 public static BCF Deserialize(Stream BCFZipData)
 {
     BCF bcf = new BCF();
     Topic currentTopic = null;
     Guid currentGuid = Guid.Empty;
     ZipArchive archive = new ZipArchive(BCFZipData);
     foreach (ZipArchiveEntry entry in archive.Entries)
     {
         if (entry.FullName.EndsWith(".bcfp", StringComparison.OrdinalIgnoreCase))
         {
             bcf.Project = new ProjectXMLFile(XDocument.Load(entry.Open()));
         }
         else if (entry.FullName.EndsWith(".version", StringComparison.OrdinalIgnoreCase))
         {
             bcf.Version = new VersionXMLFile(XDocument.Load(entry.Open()));
         }
         else if (entry.FullName.EndsWith(".bcf", StringComparison.OrdinalIgnoreCase))
         {
             if (entry.ExtractGuidFolderName() != currentGuid)
             {
                 if (currentTopic != null)
                 {
                     bcf.Topics.Add(currentTopic);
                 }
                 currentGuid = entry.ExtractGuidFolderName();
                 currentTopic = new Topic();
             }
             currentTopic.Markup = new MarkupXMLFile(XDocument.Load(entry.Open()));
         }
         else if (entry.FullName.EndsWith(".bcfv", StringComparison.OrdinalIgnoreCase))
         {
             if (entry.ExtractGuidFolderName() != currentGuid)
             {
                 if (currentTopic != null)
                 {
                     bcf.Topics.Add(currentTopic);
                 }
                 currentGuid = entry.ExtractGuidFolderName();
                 currentTopic = new Topic();
             }
             currentTopic.Visualization = new VisualizationXMLFile(XDocument.Load(entry.Open()));
         }
         else if (entry.FullName.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
         {
             if (entry.ExtractGuidFolderName() != currentGuid)
             {
                 if (currentTopic != null)
                 {
                     bcf.Topics.Add(currentTopic);
                 }
                 currentGuid = entry.ExtractGuidFolderName();
                 currentTopic = new Topic();
             }
             using (MemoryStream ms = new MemoryStream())
             {
                 entry.Open().CopyTo(ms);
                 currentTopic.Snapshots.Add(new KeyValuePair<string, byte[]>(entry.FullName, ms.ToArray()));
             }
         }
     }
     if (currentTopic != null)
     {
         bcf.Topics.Add(currentTopic);
     }
     return bcf;
 }
Example #2
0
 public Markup()
 {
     this.commentField = new BindingList<Comment>();
     this.topicField = new Topic();
     this.headerField = new BindingList<HeaderFile>();
 }
Example #3
0
 public static bool LoadFromFile(string fileName, out Topic obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
Example #4
0
 /// <summary>
 /// Deserializes xml markup from file into an Topic object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output Topic object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out Topic obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Topic);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Example #5
0
 public static bool Deserialize(string xml, out Topic obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
Example #6
0
 /// <summary>
 /// Deserializes workflow markup into an Topic object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output Topic object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out Topic obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Topic);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }