Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/09/10 01:43:38 (15 years ago)
Author:
swagner
Message:

Added Version property for items (#1003)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/Attributes/ItemAttribute.cs

    r2931 r3728  
    2121
    2222using System;
     23using System.Linq;
     24using System.Reflection;
    2325using HeuristicLab.Common;
    2426
     
    5658      else return string.Empty;
    5759    }
     60    public static Version GetVersion(Type type) {
     61      Assembly assembly = Assembly.GetAssembly(type);
     62      AssemblyFileVersionAttribute version = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).
     63                                             Cast<AssemblyFileVersionAttribute>().FirstOrDefault();
     64      if (version != null) {
     65        return new Version(version.Version);
     66      } else {
     67        return assembly.GetName().Version;
     68      }
     69    }
    5870  }
    5971}
Note: See TracChangeset for help on using the changeset viewer.