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)

Location:
trunk/sources/HeuristicLab.Persistence/3.3/Auxiliary
Files:
3 edited

Legend:

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

    r1823 r3004  
    1010namespace HeuristicLab.Persistence.Auxiliary {
    1111
    12   public class TypeLoader {
     12  internal class TypeLoader {
    1313
    1414    public static Type Load(string typeNameString) {
  • 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();
  • trunk/sources/HeuristicLab.Persistence/3.3/Auxiliary/TypeNameParser.cs

    r2859 r3004  
    1111  }
    1212
     13
     14  /// <summary>
     15  /// Parse a .NET type name using the following grammar: 
     16  ///   
     17  /// <para><code>
     18  /// TypeSpec := SimpleTypeSpec '&amp;'? 
     19  /// </code></para>
     20  ///
     21  /// <para><code>
     22  /// SimpleTypeSpec := (IDENTIFIER '.')*
     23  ///                   (IDENTIFIER '+')*
     24  ///                    IDENTIFIER
     25  ///                   ( '`\d+[' Generics ']' )?
     26  ///                   (\*|\[(\d+\.\.\d+|\d+\.\.\.|(|\*)(,(|\*))*)\])*
     27  ///                   (',\s*' IDENTIFIER (',\s*' AssemblyProperty)* )? 
     28  /// </code></para>
     29  ///
     30  /// <para><code>
     31  /// Generics := '[' SimpleTypeSpec ']' (',[' SimpleTypeSpec ']')
     32  /// </code></para>
     33  ///
     34  /// <para><code>
     35  /// AssemblyProperty := 'Version=' Version
     36  ///                  |  'PublicKey(Token)?=[a-fA-F0-9]+'
     37  ///                  |  'Culture=[a-zA-F0-9]+'
     38  /// </code></para>
     39  ///
     40  /// <para><code>
     41  /// Version := \d+\.\d+\.\d+\.\d+
     42  /// </code></para>
     43  ///
     44  /// <para><code>
     45  /// IDENTIFIER = [_a-zA-Z][_a-ZA-Z0-9]* 
     46  /// </code></para>
     47  /// </summary>
    1348  public class TypeNameParser {
    1449
     
    3570
    3671
    37     class Token {
     72    private class Token {
    3873      private static Dictionary<string, string> tokens =
    3974        new Dictionary<string, string> {
     
    68103        }
    69104      }
    70       public static IEnumerable<Token> Tokenize(string s) {
     105      public static IEnumerable<Token> Tokenize(string s) {       
    71106        int pos = 0;
    72107        foreach (Match m in TokenRegex.Matches(s)) {
Note: See TracChangeset for help on using the changeset viewer.