- Timestamp:
- 06/12/14 13:26:18 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/DataPreprocessing/HeuristicLab.Persistence
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Persistence (added) merged: 10889,10895-10896,10958,10960-10961
- Property svn:mergeinfo changed
-
branches/DataPreprocessing/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Char2XmlFormatter.cs
r9456 r11009 20 20 #endregion 21 21 22 using System; 23 using System.Text; 24 using System.Text.RegularExpressions; 22 25 using HeuristicLab.Persistence.Core; 23 26 using HeuristicLab.Persistence.Interfaces; … … 27 30 internal sealed class Char2XmlSerializer : PrimitiveSerializerBase<char, XmlString> { 28 31 32 private static readonly Regex base64Regex = new Regex("<Base64>(.+)</Base64>"); 33 34 private static bool IsSpecial(char c) { 35 return c <= 0x1F && c != 0x9 && c != 0xA && c != 0xD; 36 } 37 38 private static string ToBase64String(char c) { 39 return string.Format("<Base64>{0}</Base64>", Convert.ToBase64String(Encoding.ASCII.GetBytes(new[] {c}))); 40 } 41 29 42 public override XmlString Format(char c) { 30 return new XmlString( new string(c, 1));43 return new XmlString(IsSpecial(c) ? ToBase64String(c) : new string(c, 1)); 31 44 } 32 45 33 46 public override char Parse(XmlString x) { 34 if (x.Data.Length != 1) 35 throw new PersistenceException("Invalid character format, XML string length != 1"); 36 return x.Data[0]; 47 if (x.Data.Length <= 1) return x.Data[0]; 48 var m = base64Regex.Match(x.Data); 49 if (m.Success) 50 return Encoding.ASCII.GetString(Convert.FromBase64String(m.Groups[1].Value))[0]; 51 throw new PersistenceException("Invalid character format, XML string length != 1"); 37 52 } 38 53 } -
branches/DataPreprocessing/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/String2XmlSerializer.cs
r9456 r11009 20 20 #endregion 21 21 22 using System; 22 23 using System.Text; 23 24 using System.Text.RegularExpressions; 24 25 using HeuristicLab.Persistence.Core; 25 26 26 27 27 namespace HeuristicLab.Persistence.Default.Xml.Primitive { … … 42 42 sb.Append(s.Replace("]]>", "]]]]><![CDATA[>")); 43 43 sb.Append("]]>"); 44 return new XmlString(sb.ToString()); 44 s = special.Replace(sb.ToString(), m => ToBase64Tag(m.Value)); 45 return new XmlString(s); 45 46 } 46 47 47 private static Regex re = new Regex(@"<!\[CDATA\[((?:[^]]|\](?!\]>))*)\]\]>", RegexOptions.Singleline); 48 private static readonly Regex re = new Regex(@"<!\[CDATA\[((?:[^]]|\](?!\]>))*)\]\]>|<Base64>([^<]*)</Base64>", RegexOptions.Singleline); 49 private static readonly Regex special = new Regex(@"[\x00-\x08\x0b\x0c\x0e-\x1f]+", RegexOptions.Singleline); 50 51 private static string ToBase64Tag(string s) { 52 return new StringBuilder() 53 .Append("]]><Base64>") 54 .Append(Convert.ToBase64String(Encoding.ASCII.GetBytes(s))) 55 .Append("</Base64><![CDATA[") 56 .ToString(); 57 } 48 58 49 59 /// <summary> … … 55 65 StringBuilder sb = new StringBuilder(); 56 66 foreach (Match m in re.Matches(x.Data)) { 57 sb.Append(m.Groups[1]); 67 if (m.Groups[1].Success) 68 sb.Append(m.Groups[1].Value); 69 else if (m.Groups[2].Success) { 70 sb.Append(Encoding.ASCII.GetString(Convert.FromBase64String(m.Groups[2].Value))); 71 } 58 72 } 59 73 string result = sb.ToString(); -
branches/DataPreprocessing/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/System.Drawing/Font2XmlSerializer.cs
r9988 r11009 28 28 public override XmlString Format(Font font) { 29 29 return new XmlString(string.Format("{0};{1};{2};{3};{4};{5}", 30 font.FontFamily.Name,30 GetFontFamilyName(font.FontFamily), 31 31 Float2XmlSerializer.FormatG8(font.Size), 32 32 font.Style, … … 39 39 string[] tokens = fontData.Data.Split(';'); 40 40 return new Font( 41 tokens[0],41 GetFontFamily(tokens[0]), 42 42 Float2XmlSerializer.ParseG8(tokens[1]), 43 43 (FontStyle)Enum.Parse(typeof(FontStyle), tokens[2]), … … 46 46 bool.Parse(tokens[5])); 47 47 } 48 49 public const string GENERIC_MONOSPACE_NAME = "_GenericMonospace"; 50 public const string GENERIC_SANS_SERIF_NAME = "_GenericSansSerif"; 51 public const string GENERIC_SERIF_NAME = "_GenericSerif"; 52 53 public static FontFamily GetFontFamily(string name) { 54 if (name == GENERIC_MONOSPACE_NAME) return FontFamily.GenericMonospace; 55 if (name == GENERIC_SANS_SERIF_NAME) return FontFamily.GenericSansSerif; 56 if (name == GENERIC_SERIF_NAME) return FontFamily.GenericSerif; 57 return new FontFamily(name); 58 } 59 60 public static string GetFontFamilyName(FontFamily ff) { 61 if (ff.Equals(FontFamily.GenericMonospace)) return GENERIC_MONOSPACE_NAME; 62 if (ff.Equals(FontFamily.GenericSansSerif)) return GENERIC_SANS_SERIF_NAME; 63 if (ff.Equals(FontFamily.GenericSerif)) return GENERIC_SERIF_NAME; 64 return ff.Name; 65 } 66 48 67 } 49 68 }
Note: See TracChangeset
for help on using the changeset viewer.