Changeset 3935
- Timestamp:
- 06/21/10 15:58:31 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Auxiliary/TypeName.cs
r3903 r3935 176 176 sb.Append(">"); 177 177 } 178 sb.Append(MemoryMagic); 179 return sb.ToString(); 180 } 181 182 public string GetTypeNameInCode(bool includeAllNamespaces) { 183 StringBuilder sb = new StringBuilder(); 184 if (includeAllNamespaces) 185 sb.Append(Namespace).Append('.'); 186 sb.Append(ClassName); 187 if (IsGeneric) { 188 sb.Append("<"); 189 sb.Append( 190 string.Join(", ", 191 GenericArgs 192 .Select(a => a.GetTypeNameInCode(includeAllNamespaces)) 193 .ToArray())); 194 sb.Append(">"); 195 } 196 sb.Append(MemoryMagic); 178 197 return sb.ToString(); 179 198 } -
trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs
r3742 r3935 40 40 public class XmlGenerator : GeneratorBase<string> { 41 41 42 pr ivateint depth;43 pr ivateint Depth {42 protected int depth; 43 protected int Depth { 44 44 get { 45 45 return depth; … … 51 51 } 52 52 53 pr ivatestring prefix;53 protected string prefix; 54 54 55 55 … … 61 61 } 62 62 63 pr ivateenum NodeType { Start, End, Inline } ;64 65 pr ivatestatic void AddXmlTagContent(StringBuilder sb, string name, Dictionary<string, object> attributes) {63 protected enum NodeType { Start, End, Inline } ; 64 65 protected static void AddXmlTagContent(StringBuilder sb, string name, Dictionary<string, object> attributes) { 66 66 sb.Append(name); 67 67 foreach (var attribute in attributes) { … … 76 76 } 77 77 78 pr ivatestatic void AddXmlStartTag(StringBuilder sb, string name, Dictionary<string, object> attributes) {78 protected static void AddXmlStartTag(StringBuilder sb, string name, Dictionary<string, object> attributes) { 79 79 sb.Append('<'); 80 80 AddXmlTagContent(sb, name, attributes); … … 82 82 } 83 83 84 pr ivatestatic void AddXmlInlineTag(StringBuilder sb, string name, Dictionary<string, object> attributes) {84 protected static void AddXmlInlineTag(StringBuilder sb, string name, Dictionary<string, object> attributes) { 85 85 sb.Append('<'); 86 86 AddXmlTagContent(sb, name, attributes); … … 88 88 } 89 89 90 pr ivatestatic void AddXmlEndTag(StringBuilder sb, string name) {90 protected static void AddXmlEndTag(StringBuilder sb, string name) { 91 91 sb.Append("</"); 92 92 sb.Append(name); … … 94 94 } 95 95 96 pr ivatestring CreateNodeStart(string name, Dictionary<string, object> attributes) {96 protected string CreateNodeStart(string name, Dictionary<string, object> attributes) { 97 97 StringBuilder sb = new StringBuilder(); 98 98 sb.Append(prefix); … … 103 103 } 104 104 105 pr ivatestring CreateNodeStart(string name) {105 protected string CreateNodeStart(string name) { 106 106 return CreateNodeStart(name, new Dictionary<string, object>()); 107 107 } 108 108 109 pr ivatestring CreateNodeEnd(string name) {109 protected string CreateNodeEnd(string name) { 110 110 Depth -= 1; 111 111 StringBuilder sb = new StringBuilder(); … … 116 116 } 117 117 118 pr ivatestring CreateNode(string name, Dictionary<string, object> attributes) {118 protected string CreateNode(string name, Dictionary<string, object> attributes) { 119 119 StringBuilder sb = new StringBuilder(); 120 120 sb.Append(prefix); … … 124 124 } 125 125 126 pr ivatestring CreateNode(string name, Dictionary<string, object> attributes, string content) {126 protected string CreateNode(string name, Dictionary<string, object> attributes, string content) { 127 127 StringBuilder sb = new StringBuilder(); 128 128 sb.Append(prefix); … … 148 148 } 149 149 150 pr ivatevoid AddTypeInfo(int typeId, Dictionary<string, object> dict) {150 protected void AddTypeInfo(int typeId, Dictionary<string, object> dict) { 151 151 if (lastTypeToken != null) { 152 152 if (typeId == lastTypeToken.Id) { … … 225 225 } 226 226 227 pr ivateTypeToken lastTypeToken;227 protected TypeToken lastTypeToken; 228 228 /// <summary> 229 229 /// Formats the specified token. … … 236 236 } 237 237 238 pr ivatestring FlushTypeToken() {238 protected string FlushTypeToken() { 239 239 if (lastTypeToken == null) 240 240 return ""; -
trunk/sources/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj
r3832 r3935 158 158 <Compile Include="Default\Xml\Compact\NumberArray2XmlSerializerBase.cs" /> 159 159 <Compile Include="Default\Xml\Compact\NumberEnumeration2XmlSerializerBase.cs" /> 160 <Compile Include="Default\Xml\EasyXmlGenerator.cs" /> 160 161 <Compile Include="Default\Xml\Primitive\System.Drawing\Bitmap2XmlSerializer.cs" /> 161 162 <Compile Include="Default\Xml\Primitive\Bool2XmlSerializer.cs" /> -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r3811 r3935 42 42 namespace HeuristicLab.Persistence_33.Tests { 43 43 44 [StorableClass] 44 [StorableClass] 45 45 public class NumberTest { 46 46 [Storable] … … 288 288 Root newR = (Root)XmlParser.Deserialize(tempFile); 289 289 CompareComplexStorables(r, newR); 290 } 291 292 [TestMethod] 293 public void ComplexEasyStorable() { 294 Root r = InitializeComplexStorable(); 295 ReadableXmlGenerator.Serialize(r, tempFile); 296 using (var reader = new StreamReader(tempFile)) { 297 string text = reader.ReadToEnd(); 298 Assert.IsTrue(text.StartsWith("<Root")); 299 } 290 300 } 291 301 … … 774 784 775 785 Assert.AreEqual(bitmap.Size, newBitmap.Size); 776 for (int i=0; i< bitmap.Size.Width; i++)777 for (int j =0; j< bitmap.Size.Height; j++)778 Assert.AreEqual(bitmap.GetPixel(i, j),newBitmap.GetPixel(i,j));786 for (int i = 0; i < bitmap.Size.Width; i++) 787 for (int j = 0; j < bitmap.Size.Height; j++) 788 Assert.AreEqual(bitmap.GetPixel(i, j), newBitmap.GetPixel(i, j)); 779 789 } 780 790 … … 813 823 Assert.IsFalse(newHookTest.WasSerialized); 814 824 } 815 825 816 826 [StorableClass] 817 827 private class CustomConstructor { … … 858 868 859 869 [TestMethod] 860 public void TestRejectionJustifications() { 870 public void TestRejectionJustifications() { 861 871 NonSerializable ns = new NonSerializable(); 862 872 try { … … 864 874 Assert.Fail("PersistenceException expected"); 865 875 } catch (PersistenceException x) { 866 Assert.IsTrue(x.Message.Contains(new StorableSerializer().JustifyRejection(typeof(NonSerializable)))); 876 Assert.IsTrue(x.Message.Contains(new StorableSerializer().JustifyRejection(typeof(NonSerializable)))); 867 877 } 868 878 } … … 967 977 Assert.AreEqual(afs.Value3, newAfs.Value3); 968 978 Assert.AreEqual(afs.Value4, newAfs.Value4); 969 979 970 980 } 971 981 … … 996 1006 Assert.AreEqual(afs.Value2, newAfs.Value2); 997 1007 Assert.AreEqual(afs.Value3, newAfs.Value3); 998 Assert.AreEqual(afs.Value4, newAfs.Value4); 1008 Assert.AreEqual(afs.Value4, newAfs.Value4); 999 1009 } 1000 1010 … … 1022 1032 XmlGenerator.Serialize(afs, tempFile); 1023 1033 MarkedOnlyStorable newAfs = (MarkedOnlyStorable)XmlParser.Deserialize(tempFile); 1024 Assert.AreEqual(1, newAfs.Value1); 1034 Assert.AreEqual(1, newAfs.Value1); 1025 1035 Assert.AreEqual(afs.Value2, newAfs.Value2); 1026 1036 Assert.AreEqual(0, newAfs.Value3); … … 1054 1064 Assert.IsTrue(double.IsNaN(newSpecials[2])); 1055 1065 } 1056 1066 1057 1067 1058 1068 [ClassInitialize]
Note: See TracChangeset
for help on using the changeset viewer.