Esempio n. 1
0
 public OutlineSettings GetStorableData(ITextSnapshot snapshot)
 {
     OutlineSettings settings = new OutlineSettings();
       foreach ( var trackingSpan in this.regions ) {
     SnapshotSpan span = trackingSpan.GetSpan(snapshot);
     if ( !span.IsEmpty ) {
       settings.Regions.Add(new Tuple<int, int>(span.Start, span.Length));
     }
       }
       return settings;
 }
Esempio n. 2
0
 public void LoadStoredData(ITextSnapshot snapshot, OutlineSettings settings)
 {
     foreach ( var region in settings.Regions ) {
     int start = region.Item1;
     int len = region.Item2;
     if ( start >= snapshot.Length || (start+len) > snapshot.Length ) {
       continue;
     }
     SnapshotSpan span = new SnapshotSpan(snapshot, start, len);
     this.Add(span);
       }
 }
 public void CanWrite()
 {
     var writer = new StringWriter();
       using ( var jw = new JsonTextWriter(writer) ) {
     OutlineSettings os = new OutlineSettings();
     os.Regions.Add(new Tuple<int, int>(10, 32));
     os.Regions.Add(new Tuple<int, int>(27, 15));
     os.Save(jw);
       }
       var jo = JObject.Parse(writer.ToString());
       Assert.Equal(10, (int)jo["regions"][0]["start"]);
       Assert.Equal(15, (int)jo["regions"][1]["length"]);
 }
 public void CanRead()
 {
     String json = @"
     { 'regions': [
       { 'start': 10, 'length': 20 },
       { 'start': 45, 'length': 30 }
     ]}";
       using ( var reader = NewReader(json) ) {
     OutlineSettings os = new OutlineSettings();
     os.Read(reader);
     Assert.Equal(2, os.Regions.Count);
     Assert.Equal(10, os.Regions[0].Item1);
     Assert.Equal(30, os.Regions[1].Item2);
       }
 }