- Timestamp:
- 03/11/10 12:54:14 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Auxiliary/TypeName.cs
r2859 r3004 4 4 using System.Reflection.Emit; 5 5 using System.Collections.Generic; 6 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 6 7 7 8 namespace HeuristicLab.Persistence.Auxiliary { 8 9 10 /// <summary> 11 /// Contains a more modular representation of type names that can 12 /// be used to compare versions and ignore extended assembly 13 /// attributes. 14 /// </summary> 15 [StorableClass(StorableClassType.MarkedOnly)] 9 16 public class TypeName { 17 18 [Storable] 10 19 public string Namespace { get; private set; } 20 21 [Storable] 11 22 public string ClassName { get; private set; } 23 24 [Storable] 12 25 public List<TypeName> GenericArgs { get; internal set; } 13 26 public bool IsGeneric { get { return GenericArgs.Count > 0; } } 27 28 [Storable] 14 29 public string MemoryMagic { get; internal set; } 30 31 [Storable] 15 32 public string AssemblyName { get; internal set; } 33 34 [Storable] 16 35 public Dictionary<string, string> AssemblyAttribues { get; internal set; } 36 37 [Storable] 17 38 public bool IsReference { get; internal set; } 18 39 … … 25 46 } 26 47 48 /// <param name="full">include assembly properties and generic parameters</param> 27 49 public string ToString(bool full) { 28 50 return ToString(full, true); 29 51 } 30 52 31 public string ToString(bool full, bool includeAssembly) { 53 54 /// <param name="full">include assembly properties and generic parameters</param> 55 public string ToString(bool full, bool includeAssembly) { 32 56 StringBuilder sb = new StringBuilder(); 33 57 if (!string.IsNullOrEmpty(Namespace)) … … 60 84 } 61 85 62 public bool IsNewerThan(TypeName t) { 86 87 /// <summary> 88 /// Lexicographically compare version information and make sure type and assembly 89 /// names are identical. This function recursively checks generic type arguments. 90 /// </summary> 91 public bool IsNewerThan(TypeName typeName) { 63 92 try { 64 if (this.ClassName != t .ClassName ||65 this.Namespace != t .Namespace ||66 this.AssemblyName != t .AssemblyName)93 if (this.ClassName != typeName.ClassName || 94 this.Namespace != typeName.Namespace || 95 this.AssemblyName != typeName.AssemblyName) 67 96 throw new Exception("Cannot compare versions of different types"); 68 97 if (CompareVersions( 69 98 this.AssemblyAttribues["Version"], 70 t .AssemblyAttribues["Version"]) > 0)99 typeName.AssemblyAttribues["Version"]) > 0) 71 100 return true; 72 101 IEnumerator<TypeName> thisIt = this.GenericArgs.GetEnumerator(); 73 IEnumerator<TypeName> tIt = t .GenericArgs.GetEnumerator();102 IEnumerator<TypeName> tIt = typeName.GenericArgs.GetEnumerator(); 74 103 while (thisIt.MoveNext()) { 75 104 tIt.MoveNext(); … … 83 112 } 84 113 85 public bool IsCompatible(TypeName t) { 114 115 /// <summary> 116 /// Make sure major and minor version number are identical. This function 117 /// recursively checks generic type arguments. 118 /// </summary> 119 public bool IsCompatible(TypeName typeName) { 86 120 try { 87 if (this.ClassName != t .ClassName ||88 this.Namespace != t .Namespace ||89 this.AssemblyName != t .AssemblyName)121 if (this.ClassName != typeName.ClassName || 122 this.Namespace != typeName.Namespace || 123 this.AssemblyName != typeName.AssemblyName) 90 124 throw new Exception("Cannot compare versions of different types"); 91 125 Version thisVersion = new Version(this.AssemblyAttribues["Version"]); 92 Version tVersion = new Version(t .AssemblyAttribues["Version"]);126 Version tVersion = new Version(typeName.AssemblyAttribues["Version"]); 93 127 if (thisVersion.Major != tVersion.Major || 94 128 thisVersion.Minor != tVersion.Minor) 95 129 return false; 96 130 IEnumerator<TypeName> thisIt = this.GenericArgs.GetEnumerator(); 97 IEnumerator<TypeName> tIt = t .GenericArgs.GetEnumerator();131 IEnumerator<TypeName> tIt = typeName.GenericArgs.GetEnumerator(); 98 132 while (thisIt.MoveNext()) { 99 133 tIt.MoveNext();
Note: See TracChangeset
for help on using the changeset viewer.