-
Notifications
You must be signed in to change notification settings - Fork 1
/
XbimAssemblyInfo.cs
66 lines (58 loc) · 1.84 KB
/
XbimAssemblyInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace NuSpecHelper
{
public class XbimAssemblyInfo
{
private Assembly _assembly;
public XbimAssemblyInfo(Assembly assembly)
{
_assembly = assembly;
}
public XbimAssemblyInfo(Type type)
{
_assembly = Assembly.GetAssembly(type);
}
public Version AssemblyVersion
{
get { return _assembly.GetName().Version; }
}
public string FileVersion
{
get
{
var fvi = FileVersionInfo.GetVersionInfo(_assembly.Location);
return fvi.FileVersion;
}
}
public DateTime CompilationTime
{
get
{
var ret = DateTime.MinValue;
var versArray = FileVersion.Split(new[] { "." }, StringSplitOptions.None);
if (versArray.Length != 4)
return DateTime.MinValue;
try
{
var dateYear = 2000 + Convert.ToInt32(versArray[2].Substring(0, 2));
var dateMonth = Convert.ToInt32(versArray[2].Substring(2, 2));
var dateday = Convert.ToInt32(versArray[3].Substring(0, 2));
var dateMinuteOfDay = Convert.ToInt32(versArray[3].Substring(2)) * 2;
var dateMinute = dateMinuteOfDay % 60;
var dateHour = dateMinuteOfDay / 60;
return new DateTime(dateYear, dateMonth, dateday, dateHour, dateMinute, 0);
}
catch (Exception)
{
return ret;
}
}
}
}
}