Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/11/10 12:54:14 (14 years ago)
Author:
epitzer
Message:

add complete persistence API docs (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Auxiliary/TypeName.cs

    r2859 r3004  
    44using System.Reflection.Emit;
    55using System.Collections.Generic;
     6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    67
    78namespace HeuristicLab.Persistence.Auxiliary {
    89 
     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)]
    916  public class TypeName {
     17
     18    [Storable]
    1019    public string Namespace { get; private set; }
     20
     21    [Storable]
    1122    public string ClassName { get; private set; }
     23
     24    [Storable]
    1225    public List<TypeName> GenericArgs { get; internal set; }
    1326    public bool IsGeneric { get { return GenericArgs.Count > 0; } }
     27
     28    [Storable]
    1429    public string MemoryMagic { get; internal set; }
     30
     31    [Storable]
    1532    public string AssemblyName { get; internal set; }
     33
     34    [Storable]
    1635    public Dictionary<string, string> AssemblyAttribues { get; internal set; }
     36
     37    [Storable]
    1738    public bool IsReference { get; internal set; }
    1839
     
    2546    }
    2647
     48    /// <param name="full">include assembly properties and generic parameters</param>   
    2749    public string ToString(bool full) {
    2850      return ToString(full, true);
    2951    }
    3052
    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) {     
    3256      StringBuilder sb = new StringBuilder();
    3357      if (!string.IsNullOrEmpty(Namespace))
     
    6084    }
    6185
    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) {
    6392      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)
    6796          throw new Exception("Cannot compare versions of different types");
    6897        if (CompareVersions(
    6998          this.AssemblyAttribues["Version"],
    70           t.AssemblyAttribues["Version"]) > 0)
     99          typeName.AssemblyAttribues["Version"]) > 0)
    71100          return true;
    72101        IEnumerator<TypeName> thisIt = this.GenericArgs.GetEnumerator();
    73         IEnumerator<TypeName> tIt = t.GenericArgs.GetEnumerator();
     102        IEnumerator<TypeName> tIt = typeName.GenericArgs.GetEnumerator();
    74103        while (thisIt.MoveNext()) {
    75104          tIt.MoveNext();
     
    83112    }
    84113
    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) {
    86120      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)
    90124          throw new Exception("Cannot compare versions of different types");
    91125        Version thisVersion = new Version(this.AssemblyAttribues["Version"]);
    92         Version tVersion = new Version(t.AssemblyAttribues["Version"]);
     126        Version tVersion = new Version(typeName.AssemblyAttribues["Version"]);
    93127        if (thisVersion.Major != tVersion.Major ||
    94128          thisVersion.Minor != tVersion.Minor)
    95129          return false;
    96130        IEnumerator<TypeName> thisIt = this.GenericArgs.GetEnumerator();
    97         IEnumerator<TypeName> tIt = t.GenericArgs.GetEnumerator();
     131        IEnumerator<TypeName> tIt = typeName.GenericArgs.GetEnumerator();
    98132        while (thisIt.MoveNext()) {
    99133          tIt.MoveNext();
Note: See TracChangeset for help on using the changeset viewer.