Changeset 9363 for branches/OaaS/HeuristicLab.Persistence
- Timestamp:
- 04/16/13 13:13:41 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 2 deleted
- 10 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Persistence
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Persistence (added) merged: 8246,8588,8600,8641,8647,8698-8699,8924,9005,9014-9015,9018
- Property svn:mergeinfo changed
-
branches/OaaS/HeuristicLab.Persistence/3.3/Auxiliary/StringExtensions.cs
r4068 r9363 1 using System.Collections.Generic; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System.Collections.Generic; 2 23 3 24 namespace HeuristicLab.Persistence.Auxiliary { -
branches/OaaS/HeuristicLab.Persistence/3.3/Auxiliary/TypeLoader.cs
r7259 r9363 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Reflection; 24 25 using HeuristicLab.Persistence.Core; … … 26 27 27 28 namespace HeuristicLab.Persistence.Auxiliary { 29 internal class TypeLoader { 30 #region Mono Compatibility 31 private static TypeName cachedMonoRuntimeType; 32 private static TypeName cachedWindowsRuntimeType; 33 private static TypeName cachedMonoObjectEqualityComparerType; 34 private static TypeName cachedWindowsObjectEqualityComparerType; 28 35 29 internal class TypeLoader { 36 private static bool MonoInstalled { 37 get { return Type.GetType("Mono.Runtime") != null; } 38 } 39 40 static TypeLoader() { 41 // we use Int32 here because we get all the information about Mono's mscorlib and just have to change the class name 42 cachedMonoRuntimeType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName); 43 cachedMonoRuntimeType = new TypeName(cachedMonoRuntimeType, "MonoType"); 44 45 cachedWindowsRuntimeType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName); 46 cachedWindowsRuntimeType = new TypeName(cachedWindowsRuntimeType, "RuntimeType"); 47 48 // we need the information about the Persistence assembly, so we use TypeName here because it is contained in this assembly 49 cachedMonoObjectEqualityComparerType = TypeNameParser.Parse(typeof(TypeName).AssemblyQualifiedName); 50 cachedMonoObjectEqualityComparerType = new TypeName(cachedMonoObjectEqualityComparerType, "ObjectEqualityComparer", "HeuristicLab.Persistence.Mono"); 51 52 cachedWindowsObjectEqualityComparerType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName); 53 cachedWindowsObjectEqualityComparerType = new TypeName(cachedWindowsObjectEqualityComparerType, "ObjectEqualityComparer", "System.Collections.Generic"); 54 } 55 #endregion 30 56 31 57 public static Type Load(string typeNameString) { 58 TypeName typeName = null; 59 try { 60 typeName = TypeNameParser.Parse(typeNameString); 61 } 62 catch (Exception) { 63 throw new PersistenceException(String.Format( 64 "Could not parse type string \"{0}\"", 65 typeNameString)); 66 } 67 68 try { 69 // try to load type normally 70 return LoadInternal(typeName); 71 } 72 catch (PersistenceException) { 73 #region Mono Compatibility 74 // if that fails, try to convert to the corresponding Mono or .NET type 75 if (MonoInstalled) { 76 typeName = GetMonoType(typeName); 77 Logger.Info(String.Format(@"Trying to load Mono type ""{0}"" instead of .NET type ""{1}""", 78 typeName, typeNameString)); 79 } else { 80 typeName = GetDotNetType(typeName); 81 Logger.Info(String.Format(@"Trying to load .NET type ""{0}"" instead of Mono type ""{1}""", 82 typeName, typeNameString)); 83 84 } 85 return LoadInternal(typeName); 86 #endregion 87 } 88 } 89 90 private static Type LoadInternal(TypeName typeName) { 32 91 Type type; 33 92 try { 34 type = Type.GetType(typeName String, true);93 type = Type.GetType(typeName.ToString(true, true), true); 35 94 } 36 95 catch (Exception) { 37 96 Logger.Warn(String.Format( 38 "Cannot load type \"{0}\", falling back to partial name", typeNameString)); 39 try { 40 TypeName typeName = TypeNameParser.Parse(typeNameString); 41 #pragma warning disable 0618 42 Assembly a = Assembly.LoadWithPartialName(typeName.AssemblyName); 43 // the suggested Assembly.Load() method fails to load assemblies outside the GAC 44 #pragma warning restore 0618 45 type = a.GetType(typeName.ToString(false, false), true); 46 } 47 catch (Exception) { 48 throw new PersistenceException(String.Format( 49 "Could not load type \"{0}\"", 50 typeNameString)); 51 } 52 try { 53 TypeName requestedTypeName = TypeNameParser.Parse(typeNameString); 54 TypeName loadedTypeName = TypeNameParser.Parse(type.AssemblyQualifiedName); 55 if (!requestedTypeName.IsCompatible(loadedTypeName)) 56 throw new PersistenceException(String.Format( 57 "Serialized type is incompatible with available type: serialized: {0}, loaded: {1}", 58 typeNameString, 59 type.AssemblyQualifiedName)); 60 if (requestedTypeName.IsNewerThan(loadedTypeName)) 61 throw new PersistenceException(String.Format( 62 "Serialized type is newer than available type: serialized: {0}, loaded: {1}", 63 typeNameString, 64 type.AssemblyQualifiedName)); 65 } 66 catch (PersistenceException) { 67 throw; 68 } 69 catch (Exception e) { 70 Logger.Warn(String.Format( 71 "Could not perform version check requested type was {0} while loaded type is {1}:", 72 typeNameString, 73 type.AssemblyQualifiedName), 74 e); 75 } 97 "Cannot load type \"{0}\", falling back to partial name", typeName.ToString(true, true))); 98 type = LoadWithPartialName(typeName); 99 CheckCompatibility(typeName, type); 76 100 } 77 101 return type; 78 102 } 103 104 private static Type LoadWithPartialName(TypeName typeName) { 105 try { 106 #pragma warning disable 0618 107 Assembly a = Assembly.LoadWithPartialName(typeName.AssemblyName); 108 // the suggested Assembly.Load() method fails to load assemblies outside the GAC 109 #pragma warning restore 0618 110 return a.GetType(typeName.ToString(false, false), true); 111 } 112 catch (Exception) { 113 throw new PersistenceException(String.Format( 114 "Could not load type \"{0}\"", 115 typeName.ToString(true, true))); 116 } 117 } 118 119 private static void CheckCompatibility(TypeName typeName, Type type) { 120 try { 121 TypeName loadedTypeName = TypeNameParser.Parse(type.AssemblyQualifiedName); 122 if (!typeName.IsCompatible(loadedTypeName)) 123 throw new PersistenceException(String.Format( 124 "Serialized type is incompatible with available type: serialized: {0}, loaded: {1}", 125 typeName.ToString(true, true), 126 type.AssemblyQualifiedName)); 127 if (typeName.IsNewerThan(loadedTypeName)) 128 throw new PersistenceException(String.Format( 129 "Serialized type is newer than available type: serialized: {0}, loaded: {1}", 130 typeName.ToString(true, true), 131 type.AssemblyQualifiedName)); 132 } 133 catch (PersistenceException) { 134 throw; 135 } 136 catch (Exception e) { 137 Logger.Warn(String.Format( 138 "Could not perform version check requested type was {0} while loaded type is {1}:", 139 typeName.ToString(true, true), 140 type.AssemblyQualifiedName), 141 e); 142 } 143 } 144 145 #region Mono Compatibility 146 /// <summary> 147 /// Returns the corresponding type for the Mono runtime 148 /// </summary> 149 /// <returns> 150 /// The remapped typeName, or the original typeName if no mapping was found 151 /// </returns> 152 private static TypeName GetMonoType(TypeName typeName) { 153 // map System.RuntimeType to System.MonoType 154 if (typeName.Namespace == "System" && typeName.ClassName == "RuntimeType") { 155 return cachedMonoRuntimeType; 156 // map System.Collections.Generic.ObjectEqualityComparer to HeuristicLab.Mono.ObjectEqualityComparer 157 } else if (typeName.Namespace == "System.Collections.Generic" && typeName.ClassName == "ObjectEqualityComparer") { 158 TypeName newTypeName = new TypeName(cachedMonoObjectEqualityComparerType); 159 newTypeName.GenericArgs = new List<TypeName>(typeName.GenericArgs); 160 return newTypeName; 161 } 162 return typeName; 163 } 164 165 /// <summary> 166 /// Returns the corresponding type for the .NET runtime 167 /// </summary> 168 /// <returns> 169 /// The remapped typeName, or the original typeName if no mapping was found 170 /// </returns> 171 private static TypeName GetDotNetType(TypeName typeName) { 172 // map System.MonoType to System.RuntimeType 173 if (typeName.Namespace == "System" && typeName.ClassName == "MonoType") { 174 return cachedWindowsRuntimeType; 175 // maps Mono's string comparer to System.Collections.Generic.ObjectEqualityComparer<string> 176 } else if (typeName.Namespace == "System.Collections.Generic" && typeName.ClassName == "InternalStringComparer") { 177 TypeName newTypeName = new TypeName(cachedWindowsObjectEqualityComparerType); 178 var genericArgsList = new List<TypeName>(); 179 genericArgsList.Add(new TypeName(typeof(String).Namespace, "String")); 180 newTypeName.GenericArgs = genericArgsList; 181 return newTypeName; 182 } else if (typeName.Namespace == "System.Collections.Generic" && typeName.ClassName == "EqualityComparer+DefaultComparer") { 183 TypeName newTypeName = new TypeName(cachedWindowsObjectEqualityComparerType); 184 newTypeName.GenericArgs = new List<TypeName>(typeName.GenericArgs); 185 return newTypeName; 186 } 187 return typeName; 188 } 189 #endregion 79 190 } 80 191 } -
branches/OaaS/HeuristicLab.Persistence/3.3/Auxiliary/TypeName.cs
r7259 r9363 51 51 52 52 /// <summary> 53 /// Gets or sets the number of generic args for 54 /// each class in a series of nested classes. 55 /// </summary> 56 [Storable] 57 public List<int> GenericArgCounts { get; private set; } 58 59 /// <summary> 53 60 /// Gets or sets the generic args. 54 61 /// </summary> … … 103 110 /// <param name="nameSpace">The namespace.</param> 104 111 /// <param name="className">Name of the class.</param> 105 internal TypeName(string nameSpace, string className ) {112 internal TypeName(string nameSpace, string className, List<int> genericArgCounts=null) { 106 113 Namespace = nameSpace; 107 114 ClassName = className; … … 109 116 MemoryMagic = ""; 110 117 AssemblyAttribues = new Dictionary<string, string>(); 111 } 112 118 if (genericArgCounts != null) 119 GenericArgCounts = genericArgCounts.ToList(); 120 } 121 122 internal TypeName(TypeName typeName, string className = null, string nameSpace = null) { 123 Namespace = nameSpace ?? typeName.Namespace; 124 ClassName = className ?? typeName.ClassName; 125 GenericArgs = new List<TypeName>(typeName.GenericArgs); 126 AssemblyAttribues = new Dictionary<string, string>(typeName.AssemblyAttribues); 127 MemoryMagic = typeName.MemoryMagic; 128 AssemblyName = typeName.AssemblyName; 129 IsReference = typeName.IsReference; 130 if (typeName.GenericArgCounts != null) 131 GenericArgCounts = typeName.GenericArgCounts.ToList(); 132 } 113 133 114 134 /// <summary> … … 135 155 /// </returns> 136 156 public string ToString(bool full, bool includeAssembly) { 137 StringBuilder sb = new StringBuilder();157 var sb = new StringBuilder(); 138 158 if (!string.IsNullOrEmpty(Namespace)) 139 159 sb.Append(Namespace).Append('.'); 140 sb.Append(ClassName); 160 if (GenericArgCounts != null) { 161 sb.Append(string.Join("+", 162 ClassName 163 .Split('+') 164 .Zip(GenericArgCounts, (n, c) => 165 c > 0 ? String.Format("{0}`{1}", n, c) : n))); 166 } else { 167 sb.Append(ClassName); 168 if (IsGeneric) 169 sb.Append('`').Append(GenericArgs.Count); 170 } 141 171 if (IsGeneric) { 142 sb.Append('`').Append(GenericArgs.Count).Append('['); 143 bool first = true; 144 foreach (TypeName t in GenericArgs) { 145 if (first) 146 first = false; 147 else 148 sb.Append(','); 149 sb.Append('[').Append(t.ToString(full)).Append(']'); 150 } 172 sb.Append('['); 173 sb.Append(String.Join(",", GenericArgs.Select(a => 174 string.Format("[{0}]", a.ToString(full))))); 151 175 sb.Append(']'); 152 176 } … … 161 185 } 162 186 163 public string GetTypeNameInCode(HashSet<string> omitNamespaces) { 164 StringBuilder sb = new StringBuilder(); 165 if (!string.IsNullOrEmpty(Namespace) && omitNamespaces == null || !omitNamespaces.Contains(Namespace)) 166 sb.Append(Namespace).Append('.'); 167 sb.Append(ClassName); 168 if (IsGeneric) { 169 sb.Append("<"); 170 sb.Append( 171 string.Join(", ", 172 GenericArgs 173 .Select(a => a.GetTypeNameInCode(omitNamespaces)) 174 .ToArray())); 175 sb.Append(">"); 187 private IEnumerable<string> GetNestedClassesInCode(HashSet<string> omitNamespaces, bool includeAllNamespaces) { 188 var i = 0; 189 foreach (var pair in ClassName.Split('+').Zip(GenericArgCounts, (n, c) => new {n, c})) { 190 if (pair.c == 0) { 191 yield return pair.n; 192 } 193 else { 194 yield return string.Format("{0}<{1}>", 195 pair.n, 196 string.Join(",", 197 GenericArgs 198 .GetRange(i, pair.c) 199 .Select(a => a.GetTypeNameInCode(omitNamespaces, includeAllNamespaces)))); 200 i += pair.c; 201 } 202 } 203 } 204 205 private string GetTypeNameInCode(HashSet<string> omitNamespaces, bool includeNamespaces) { 206 var sb = new StringBuilder(); 207 if (!string.IsNullOrEmpty(Namespace) && 208 (omitNamespaces == null && includeNamespaces) || 209 omitNamespaces != null && !omitNamespaces.Contains(Namespace)) 210 sb.Append(Namespace).Append('.'); 211 if (GenericArgCounts != null) { 212 sb.Append(string.Join(".", GetNestedClassesInCode(omitNamespaces, includeNamespaces))); 213 } else { 214 sb.Append(ClassName); 215 if (IsGeneric) { 216 sb.Append("<"); 217 sb.Append( 218 string.Join(", ", 219 GenericArgs 220 .Select(a => a.GetTypeNameInCode(omitNamespaces, includeNamespaces)) 221 .ToArray())); 222 sb.Append(">"); 223 } 176 224 } 177 225 sb.Append(MemoryMagic); … … 179 227 } 180 228 181 public string GetTypeNameInCode(bool includeAllNamespaces) { 182 StringBuilder sb = new StringBuilder(); 183 if (includeAllNamespaces) 184 sb.Append(Namespace).Append('.'); 185 sb.Append(ClassName); 186 if (IsGeneric) { 187 sb.Append("<"); 188 sb.Append( 189 string.Join(", ", 190 GenericArgs 191 .Select(a => a.GetTypeNameInCode(includeAllNamespaces)) 192 .ToArray())); 193 sb.Append(">"); 194 } 195 sb.Append(MemoryMagic); 196 return sb.ToString(); 229 public string GetTypeNameInCode(HashSet<string> omitNamespaces) { 230 return GetTypeNameInCode(omitNamespaces, false); 231 } 232 233 public string GetTypeNameInCode(bool includeNamespaces) { 234 return GetTypeNameInCode(null, includeNamespaces); 197 235 } 198 236 … … 235 273 } 236 274 return false; 237 } catch (KeyNotFoundException) { 275 } 276 catch (KeyNotFoundException) { 238 277 throw new Exception("Could not extract version information from type string"); 239 278 } … … 272 311 } 273 312 return true; 274 } catch (KeyNotFoundException) { 313 } 314 catch (KeyNotFoundException) { 275 315 throw new Exception("Could not extract version infomration from type string"); 276 316 } -
branches/OaaS/HeuristicLab.Persistence/3.3/Auxiliary/TypeNameParser.cs
r7259 r9363 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using System.Text; 25 26 using System.Text.RegularExpressions; … … 46 47 /// 47 48 /// SimpleTypeSpec := (IDENTIFIER '.')* 48 /// (IDENTIFIER ' +')*49 /// (IDENTIFIER '`\d+'? '+')* 49 50 /// IDENTIFIER 50 51 /// ( '`\d+[' Generics ']' )? … … 69 70 70 71 SimpleTypeSpec := (IDENTIFIER '.')* 71 (IDENTIFIER ' +')*72 IDENTIFIER73 ( ' `\d+[' Generics ']' )?72 (IDENTIFIER '`\d+'? 73 ( '+' IDENTIFIER '`\d+'? )* 74 ( '[' Generics ']' )? 74 75 (\*|\[(\d+\.\.\d+|\d+\.\.\.|(|\*)(,(|\*))*)\])* 75 76 (',\s*' IDENTIFIER (',\s*' AssemblyProperty)* )? 76 77 77 Generics := '[' SimpleTypeSpec ']' (',[' SimpleTypeSpec ']') 78 Generics := '[' SimpleTypeSpec ']' (',[' SimpleTypeSpec ']')* 78 79 79 80 AssemblyProperty := 'Version=' Version … … 88 89 89 90 private class Token { 90 private static Dictionary<string, string> tokens = 91 new Dictionary<string, string> { 92 {"-", "DASH"}, 93 {"&", "AMPERSAND"}, 94 {".", "DOT"}, 95 {"+", "PLUS"}, 96 {",", "COMMA"}, 97 {"[", "OPEN_BRACKET"}, 98 {"]", "CLOSE_BRACKET"}, 99 {"*", "ASTERISK"}, 100 {" ", "SPACE"}, 101 {"=", "EQUALS"}, 102 {"`", "BACKTICK"} }; 103 private static Regex NumberRegex = new Regex("^\\d+$"); 104 private static Regex IdentifierRegex = new Regex("^[_a-zA-Z][_a-zA-Z0-9]*$"); 105 private static Regex TokenRegex = new Regex("[-&.+,\\[\\]* =`]|[a-f0-9]+|\\d+|[_a-zA-Z][_a-zA-Z0-9]*"); 106 public string Name { get; private set; } 91 public enum Symbol { None, Dash, Ampersand, Dot, Plus, Comma, OpenBracket, CloseBracket, Asterisk, Space, Equals, Backtick } 92 private static readonly Dictionary<string, Symbol> TOKENS = 93 new Dictionary<string, Symbol> { 94 {"-", Symbol.Dash}, 95 {"&", Symbol.Ampersand}, 96 {".", Symbol.Dot}, 97 {"+", Symbol.Plus}, 98 {",", Symbol.Comma}, 99 {"[", Symbol.OpenBracket}, 100 {"]", Symbol.CloseBracket}, 101 {"*", Symbol.Asterisk}, 102 {" ", Symbol.Space}, 103 {"=", Symbol.Equals}, 104 {"`", Symbol.Backtick}}; 105 private static readonly Regex NumberRegex = new Regex("^\\d+$"); 106 private static readonly Regex IdentifierRegex = new Regex("^[_a-zA-Z][_a-zA-Z0-9]*$"); 107 private static readonly Regex TokenRegex = new Regex("[-&.+,\\[\\]* =`]|[a-f0-9]+|\\d+|[_a-zA-Z][_a-zA-Z0-9]*"); 108 public Symbol Name { get; private set; } 107 109 public string Value { get; private set; } 108 110 public bool IsIdentifier { get; private set; } … … 111 113 private Token(string value, int pos) { 112 114 Position = pos; 113 if (tokens.ContainsKey(value)) { 114 Name = tokens[value]; 115 Name = Symbol.None; 116 if (TOKENS.ContainsKey(value)) { 117 Name = TOKENS[value]; 115 118 } else if (NumberRegex.IsMatch(value)) { 116 119 Number = int.Parse(value); … … 128 131 } 129 132 public override string ToString() { 130 if (Name != null)133 if (Name != Symbol.None) 131 134 return "Token(" + Name + ")"; 132 135 if (Value != null) … … 154 157 /// <summary> 155 158 /// Parses the specified typename string as obtained by 156 /// <c>System.Object.GetType().FullName"</c>. 159 /// <c>System.Object.GetType().FullName</c> or 160 /// <c>System.Object.GetType().AssemblyQualifiedName</c>. 157 161 /// </summary> 158 162 /// <param name="s">The typename string.</param> … … 181 185 private TypeName TransformTypeSpec() { 182 186 TypeName t = TransformSimpleTypeSpec(); 183 t.IsReference = ConsumeToken( "AMPERSAND");187 t.IsReference = ConsumeToken(Token.Symbol.Ampersand); 184 188 return t; 185 189 } 186 190 187 191 private TypeName TransformSimpleTypeSpec() { 188 List<string> nameSpace = new List<string>(); 189 nameSpace.Add(ConsumeIdentifier()); 190 while (ConsumeToken("DOT")) 192 var nameSpace = new List<string> { ConsumeIdentifier() }; 193 while (ConsumeToken(Token.Symbol.Dot)) 191 194 nameSpace.Add(ConsumeIdentifier()); 192 List<string>className = new List<string>();195 var className = new List<string>(); 193 196 if (nameSpace.Count > 0) { 194 197 className.Add(nameSpace[nameSpace.Count - 1]); 195 198 nameSpace.RemoveAt(nameSpace.Count - 1); 196 199 } 197 while (ConsumeToken("PLUS")) 200 var genericArgCounts = new List<int> { 201 ConsumeToken(Token.Symbol.Backtick) ? ConsumeNumber() : 0 202 }; 203 while (ConsumeToken(Token.Symbol.Plus)) { 198 204 className.Add(ConsumeIdentifier()); 199 TypeName typeName = new TypeName( 205 genericArgCounts.Add(ConsumeToken(Token.Symbol.Backtick) ? ConsumeNumber() : 0); 206 } 207 var nGenericArgs = genericArgCounts.Sum(); 208 var typeName = new TypeName( 200 209 string.Join(".", nameSpace.ToArray()), 201 string.Join("+", className.ToArray())); 202 if (ConsumeToken("BACKTICK")) { 203 int nGenericArgs = ConsumeNumber(); 204 if (ConsumeToken("OPEN_BRACKET") && 205 CanConsumeToken("OPEN_BRACKET")) { 206 typeName.GenericArgs.AddRange(TransformGenerics()); 207 ConsumeToken("CLOSE_BRACKET", true); 208 } 209 } 210 StringBuilder pointerOrArray = new StringBuilder(); 210 string.Join("+", className.ToArray()), 211 nGenericArgs > genericArgCounts.Last() ? genericArgCounts : null); 212 if (nGenericArgs > 0 && ConsumeToken(Token.Symbol.OpenBracket, true)) { 213 typeName.GenericArgs.AddRange(TransformGenerics()); 214 ConsumeToken(Token.Symbol.CloseBracket, true); 215 } 216 var pointerOrArray = new StringBuilder(); 211 217 while (true) { 212 if (ConsumeToken( "ASTERSIK")) {218 if (ConsumeToken(Token.Symbol.Asterisk)) { 213 219 pointerOrArray.Append("*"); 214 } else if (ConsumeToken( "OPEN_BRACKET")) {220 } else if (ConsumeToken(Token.Symbol.OpenBracket)) { 215 221 pointerOrArray.Append('['); 216 222 ParseDimension(pointerOrArray); 217 while (ConsumeToken( "COMMA")) {223 while (ConsumeToken(Token.Symbol.Comma)) { 218 224 pointerOrArray.Append(","); 219 225 ParseDimension(pointerOrArray); 220 226 } 221 ConsumeToken( "CLOSE_BRACKET", true);227 ConsumeToken(Token.Symbol.CloseBracket, true); 222 228 pointerOrArray.Append(']'); 223 229 } else { … … 227 233 typeName.MemoryMagic = pointerOrArray.ToString(); 228 234 if (ConsumeComma()) { 229 StringBuilder sb = new StringBuilder();235 var sb = new StringBuilder(); 230 236 sb.Append(ConsumeIdentifier()); 231 while (CanConsumeToken( "DOT") ||232 CanConsumeToken( "DASH") ||237 while (CanConsumeToken(Token.Symbol.Dot) || 238 CanConsumeToken(Token.Symbol.Dash) || 233 239 CanConsumeNumber() || 234 240 CanConsumeIdentifier()) { 235 if (ConsumeToken( "DOT"))241 if (ConsumeToken(Token.Symbol.Dot)) 236 242 sb.Append('.'); 237 else if (ConsumeToken( "DASH"))243 else if (ConsumeToken(Token.Symbol.Dash)) 238 244 sb.Append('-'); 239 245 else if (CanConsumeNumber()) … … 253 259 254 260 private void ParseDimension(StringBuilder sb) { 255 if (ConsumeToken( "ASTERSIK")) {261 if (ConsumeToken(Token.Symbol.Asterisk)) { 256 262 sb.Append("*"); 257 263 } else if (CanConsumeNumber()) { 258 264 sb.Append(ConsumeNumber()); 259 ConsumeToken( "DOT", true);260 ConsumeToken( "DOT", true);261 if (ConsumeToken( "DOT")) {265 ConsumeToken(Token.Symbol.Dot, true); 266 ConsumeToken(Token.Symbol.Dot, true); 267 if (ConsumeToken(Token.Symbol.Dot)) { 262 268 sb.Append("..."); 263 269 } else { … … 268 274 269 275 private IEnumerable<TypeName> TransformGenerics() { 270 ConsumeToken( "OPEN_BRACKET", true);276 ConsumeToken(Token.Symbol.OpenBracket, true); 271 277 yield return TransformSimpleTypeSpec(); 272 ConsumeToken( "CLOSE_BRACKET", true);273 while (ConsumeToken( "COMMA")) {274 ConsumeToken( "OPEN_BRACKET", true);278 ConsumeToken(Token.Symbol.CloseBracket, true); 279 while (ConsumeToken(Token.Symbol.Comma)) { 280 ConsumeToken(Token.Symbol.OpenBracket, true); 275 281 yield return TransformSimpleTypeSpec(); 276 ConsumeToken( "CLOSE_BRACKET", true);282 ConsumeToken(Token.Symbol.CloseBracket, true); 277 283 } 278 284 } … … 280 286 private KeyValuePair<string, string> TransformAssemblyProperty() { 281 287 if (ConsumeIdentifier("Version")) { 282 ConsumeToken( "EQUALS", true);288 ConsumeToken(Token.Symbol.Equals, true); 283 289 return new KeyValuePair<string, string>( 284 290 "Version", … … 300 306 301 307 private KeyValuePair<string, string> ConsumeAssignment(string name) { 302 ConsumeToken( "EQUALS", true);308 ConsumeToken(Token.Symbol.Equals, true); 303 309 return new KeyValuePair<string, string>(name, ConsumeToken()); 304 310 } … … 307 313 StringBuilder version = new StringBuilder(); 308 314 version.Append(ConsumeNumber()); 309 ConsumeToken( "DOT");315 ConsumeToken(Token.Symbol.Dot); 310 316 version.Append('.').Append(ConsumeNumber()); 311 ConsumeToken( "DOT");317 ConsumeToken(Token.Symbol.Dot); 312 318 version.Append('.').Append(ConsumeNumber()); 313 ConsumeToken( "DOT");319 ConsumeToken(Token.Symbol.Dot); 314 320 version.Append('.').Append(ConsumeNumber()); 315 321 return version.ToString(); … … 368 374 369 375 private bool ConsumeComma() { 370 if (ConsumeToken( "COMMA")) {371 while (ConsumeToken( "SPACE")) ;376 if (ConsumeToken(Token.Symbol.Comma)) { 377 while (ConsumeToken(Token.Symbol.Space)) ; 372 378 return true; 373 379 } else { … … 376 382 } 377 383 378 private bool ConsumeToken( string name) {379 return ConsumeToken( name, false);380 } 381 382 private bool CanConsumeToken( string name) {383 if (tokens.Count == 0) 384 return false; 385 if (tokens.Peek().Name == name)384 private bool ConsumeToken(Token.Symbol symbol) { 385 return ConsumeToken(symbol, false); 386 } 387 388 private bool CanConsumeToken(Token.Symbol symbol) { 389 if (tokens.Count == 0) 390 return false; 391 if (tokens.Peek().Name == symbol) 386 392 return true; 387 393 return false; 388 394 } 389 395 390 private bool ConsumeToken( string name, bool force) {396 private bool ConsumeToken(Token.Symbol symbol, bool force) { 391 397 if (tokens.Count == 0) 392 398 if (force) 393 399 throw new ParseError(String.Format( 394 400 "end of input while expecting token \"{0}\"", 395 name));401 symbol)); 396 402 else 397 403 return false; 398 if (tokens.Peek().Name == name) {404 if (tokens.Peek().Name == symbol) { 399 405 tokens.Dequeue(); 400 406 return true; … … 402 408 throw new ParseError(String.Format( 403 409 "expected \"{0}\" found \"{1}\"", 404 name,410 symbol, 405 411 tokens.Peek().ToString())); 406 412 } else { -
branches/OaaS/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TypeSerializer.cs
r7259 r9363 41 41 42 42 public bool CanSerialize(Type type) { 43 #region Mono Compatibility 43 44 return type == typeof(Type) || 44 type.VersionInvariantName() == "System.RuntimeType, mscorlib"; 45 type.VersionInvariantName() == "System.RuntimeType, mscorlib" || 46 type.VersionInvariantName() == "System.MonoType, mscorlib"; 47 #endregion 45 48 } 46 49 47 50 public string JustifyRejection(Type type) { 48 return "not System.Type nor System.RuntimeType"; 51 #region Mono Compatibility 52 return "not System.Type, System.RuntimeType, System.MonoType"; 53 #endregion 49 54 } 50 55 -
branches/OaaS/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj
r7021 r9363 125 125 </ItemGroup> 126 126 <ItemGroup> 127 <Compile Include="Auxiliary\ObjectEqualityComparer.cs" /> 127 128 <Compile Include="Auxiliary\StringExtensions.cs" /> 128 129 <Compile Include="Auxiliary\TypeLoader.cs" /> … … 246 247 </ItemGroup> 247 248 <PropertyGroup> 248 <PreBuildEvent >set Path=%25Path%25;$(ProjectDir);$(SolutionDir)249 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 249 250 set ProjectDir=$(ProjectDir) 250 251 set SolutionDir=$(SolutionDir) … … 252 253 253 254 call PreBuildEvent.cmd 255 </PreBuildEvent> 256 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 257 export ProjectDir=$(ProjectDir) 258 export SolutionDir=$(SolutionDir) 259 260 $SolutionDir/PreBuildEvent.sh 254 261 </PreBuildEvent> 255 262 <PostBuildEvent> -
branches/OaaS/HeuristicLab.Persistence/3.3/Plugin.cs.frame
r7259 r9363 27 27 /// The plugin for HeuriticLab.Persistence 28 28 /// </summary> 29 [Plugin("HeuristicLab.Persistence", "3.3. 6.$WCREV$")]29 [Plugin("HeuristicLab.Persistence", "3.3.7.$WCREV$")] 30 30 [PluginFile("HeuristicLab.Persistence-3.3.dll", PluginFileType.Assembly)] 31 31 [PluginDependency("HeuristicLab.Tracing", "3.3")] -
branches/OaaS/HeuristicLab.Persistence/3.3/Properties/AssemblyInfo.cs.frame
r7259 r9363 52 52 // 53 53 [assembly: AssemblyVersion("3.3.0.0")] 54 [assembly: AssemblyFileVersion("3.3. 6.$WCREV$")]54 [assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
Note: See TracChangeset
for help on using the changeset viewer.