markus / MarkusAutoUpdate / src / NetSparkle / Configurations / Configuration.cs @ ddc223b4
이력 | 보기 | 이력해설 | 다운로드 (4.39 KB)
1 | d8f5045e | taeseongkim | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using Microsoft.Win32; |
||
6 | using System.Diagnostics; |
||
7 | using NetSparkleUpdater.AssemblyAccessors; |
||
8 | using NetSparkleUpdater.Interfaces; |
||
9 | |||
10 | namespace NetSparkleUpdater.Configurations |
||
11 | { |
||
12 | /// <summary> |
||
13 | /// Abstract class to handle |
||
14 | /// update intervals. |
||
15 | /// |
||
16 | /// CheckForUpdate - Boolean - Whether NetSparkle should check for updates |
||
17 | /// LastCheckTime - time_t - Time of last check |
||
18 | /// SkipThisVersion - String - If the user skipped an update, then the version to ignore is stored here (e.g. "1.4.3") |
||
19 | /// DidRunOnce - Boolean - Check only one time when the app launched |
||
20 | /// </summary> |
||
21 | public abstract class Configuration |
||
22 | { |
||
23 | /// <summary> |
||
24 | /// The application name |
||
25 | /// </summary> |
||
26 | public string ApplicationName { get; protected set; } |
||
27 | /// <summary> |
||
28 | /// The previous version of the software that the user ran |
||
29 | /// </summary> |
||
30 | public string PreviousVersionOfSoftwareRan { get; protected set; } |
||
31 | /// <summary> |
||
32 | /// The currently-installed version |
||
33 | /// </summary> |
||
34 | public string InstalledVersion { get; set; } |
||
35 | /// <summary> |
||
36 | /// Flag to indicate if we should check for updates |
||
37 | /// </summary> |
||
38 | public bool CheckForUpdate { get; protected set; } |
||
39 | /// <summary> |
||
40 | /// True if this is the first time the application has been run based on save config data; false otherwise |
||
41 | /// </summary> |
||
42 | public bool IsFirstRun { get; protected set; } |
||
43 | /// <summary> |
||
44 | /// Last check time |
||
45 | /// </summary> |
||
46 | public DateTime LastCheckTime { get; protected set; } |
||
47 | /// <summary> |
||
48 | /// The last-skipped version number |
||
49 | /// </summary> |
||
50 | public string LastVersionSkipped { get; protected set; } |
||
51 | /// <summary> |
||
52 | /// Whether or not the application has run at least one time |
||
53 | /// </summary> |
||
54 | public bool DidRunOnce { get; protected set; } |
||
55 | /// <summary> |
||
56 | /// Last profile update |
||
57 | /// </summary> |
||
58 | public DateTime LastConfigUpdate { get; protected set; } |
||
59 | |||
60 | /// <summary> |
||
61 | /// Object that accesses version, title, etc. info for the currently running application |
||
62 | /// (or some other application) |
||
63 | /// </summary> |
||
64 | public IAssemblyAccessor AssemblyAccessor { get; protected set; } |
||
65 | |||
66 | /// <summary> |
||
67 | /// Constructor for Configuration -- should load values by the end of the constructor! |
||
68 | /// </summary> |
||
69 | /// <param name="assemblyAccessor">Object that accesses version, title, etc. info for the application |
||
70 | /// you would like to check for updates for</param> |
||
71 | public Configuration(IAssemblyAccessor assemblyAccessor) |
||
72 | { |
||
73 | // set default values |
||
74 | InitWithDefaultValues(); |
||
75 | |||
76 | try |
||
77 | { |
||
78 | // set some value from the binary |
||
79 | AssemblyAccessor = assemblyAccessor; |
||
80 | ApplicationName = assemblyAccessor.AssemblyProduct; |
||
81 | InstalledVersion = assemblyAccessor.AssemblyVersion; |
||
82 | } |
||
83 | catch |
||
84 | { |
||
85 | CheckForUpdate = false; |
||
86 | } |
||
87 | |||
88 | } |
||
89 | |||
90 | /// <summary> |
||
91 | /// Touches to profile time |
||
92 | /// </summary> |
||
93 | public virtual void TouchProfileTime() |
||
94 | { |
||
95 | LastConfigUpdate = DateTime.Now; |
||
96 | } |
||
97 | |||
98 | /// <summary> |
||
99 | /// Touches the check time to now, should be used after a check directly |
||
100 | /// </summary> |
||
101 | public virtual void TouchCheckTime() |
||
102 | { |
||
103 | LastCheckTime = DateTime.Now; |
||
104 | } |
||
105 | |||
106 | /// <summary> |
||
107 | /// This method allows to skip a specific version |
||
108 | /// </summary> |
||
109 | /// <param name="version">the version to skeip</param> |
||
110 | public virtual void SetVersionToSkip(String version) |
||
111 | { |
||
112 | LastVersionSkipped = version; |
||
113 | } |
||
114 | |||
115 | /// <summary> |
||
116 | /// Reloads the configuration object |
||
117 | /// </summary> |
||
118 | public abstract void Reload(); |
||
119 | |||
120 | /// <summary> |
||
121 | /// This method sets default values for the config |
||
122 | /// </summary> |
||
123 | protected void InitWithDefaultValues() |
||
124 | { |
||
125 | CheckForUpdate = true; |
||
126 | LastCheckTime = new DateTime(0); |
||
127 | LastVersionSkipped = string.Empty; |
||
128 | DidRunOnce = false; |
||
129 | } |
||
130 | } |
||
131 | } |