Exemplo n.º 1
0
 private void OnDocumentSaved(DocumentSavedEvent documentSavedEvent)
 {
     if (documentSavedEvent.DocumentFullName == _filename)
     {
         RemoveEmptyTrackingSpans();
         FileDocumentation fileDocumentation = CreateFileDocumentationFromTrackingSpans();
         DocumentationFileSerializer.Serialize(CodyDocsFilename, fileDocumentation);
     }
 }
 public static void Serialize(string filepath, FileDocumentation data)
 {
     if (data.Fragments.Count == 0)
     {
         File.Delete(filepath);
     }
     else
     {
         string serialized = JsonConvert.SerializeObject(data);
         File.WriteAllText(filepath, serialized);
     }
 }
Exemplo n.º 3
0
        private FileDocumentation CreateFileDocumentationFromTrackingSpans()
        {
            var currentSnapshot = _buffer.CurrentSnapshot;
            List <DocumentationFragment> fragments = _trackingSpans
                                                     .Select(ts => new DocumentationFragment()
            {
                Selection = new TextViewSelection()
                {
                    StartPosition = ts.Key.GetStartPoint(currentSnapshot),
                    EndPosition   = ts.Key.GetEndPoint(currentSnapshot),
                    Text          = ts.Key.GetText(currentSnapshot)
                },
                Documentation = ts.Value,
            }).ToList();

            var fileDocumentation = new FileDocumentation()
            {
                Fragments = fragments
            };

            return(fileDocumentation);
        }
        public static void Serialize(string filepath, FileDocumentation data)
        {
            string serialized = JsonConvert.SerializeObject(data);

            File.WriteAllText(filepath, serialized);
        }