Browse Source

fixed serialization of breakpoints and bookmarks

newNRvisualizers
Siegfried Pammer 13 years ago
parent
commit
93565945b1
  1. 4
      src/AddIns/Debugger/Debugger.Core/Breakpoint.cs
  2. 35
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TextLocation.cs
  3. 2
      src/Main/Base/Project/Editor/Bookmarks/BookmarkBase.cs
  4. 33
      src/Main/Core/Project/Src/Services/FileUtility/FileName.cs

4
src/AddIns/Debugger/Debugger.Core/Breakpoint.cs

@ -43,6 +43,10 @@ namespace Debugger @@ -43,6 +43,10 @@ namespace Debugger
public string TypeName { get; protected set; }
internal Breakpoint()
{
}
internal Breakpoint(string fileName, int line, int column, bool enabled)
{
this.FileName = fileName;

35
src/Libraries/NRefactory/ICSharpCode.NRefactory/TextLocation.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Globalization;
namespace ICSharpCode.NRefactory
@ -30,6 +31,7 @@ namespace ICSharpCode.NRefactory @@ -30,6 +31,7 @@ namespace ICSharpCode.NRefactory
/// <see cref="Editor.IDocument.GetOffset(TextLocation)"/> to convert between offsets and TextLocations.
/// </remarks>
[Serializable]
[TypeConverter(typeof(TextLocationConverter))]
public struct TextLocation : IComparable<TextLocation>, IEquatable<TextLocation>
{
/// <summary>
@ -185,4 +187,37 @@ namespace ICSharpCode.NRefactory @@ -185,4 +187,37 @@ namespace ICSharpCode.NRefactory
return 1;
}
}
public class TextLocationConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(TextLocation) || base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string) {
string[] parts = ((string)value).Split(';', ',');
if (parts.Length == 2) {
return new TextLocation(int.Parse(parts[0]), int.Parse(parts[1]));
}
}
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is TextLocation) {
var loc = (TextLocation)value;
return loc.Line + ";" + loc.Column;
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}

2
src/Main/Base/Project/Editor/Bookmarks/BookmarkBase.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
using System.Windows.Input;
using System.Windows.Media;
@ -20,6 +21,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks @@ -20,6 +21,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Bookmarks
IDocument document;
ITextAnchor anchor;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IDocument Document {
get {
return document;

33
src/Main/Core/Project/Src/Services/FileUtility/FileName.cs

@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
using System.Globalization;
using System.IO;
namespace ICSharpCode.Core
@ -10,6 +12,7 @@ namespace ICSharpCode.Core @@ -10,6 +12,7 @@ namespace ICSharpCode.Core
/// Represents a directory path or filename.
/// The equality operator is overloaded to compare for path equality (case insensitive, normalizing paths with '..\')
/// </summary>
[TypeConverter(typeof(FileNameConverter))]
public sealed class FileName : IEquatable<FileName>
{
readonly string normalizedFileName;
@ -118,4 +121,34 @@ namespace ICSharpCode.Core @@ -118,4 +121,34 @@ namespace ICSharpCode.Core
}
#endregion
}
public class FileNameConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(FileName) || base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string) {
return FileName.Create((string)value);
}
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
object value, Type destinationType)
{
if (destinationType == typeof(string)) {
return value.ToString();
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}

Loading…
Cancel
Save