private SUUpdater(KNBundle aBundle) { KNBundle bundle = KNBundle.BundleWithAssembly(Assembly.GetAssembly(this.GetType())); if (aBundle == null) { aBundle = KNBundle.MainBundle(); } if (sharedUpdaters.ContainsKey(aBundle)) { throw new Exception("Updater for this bundle exists - use SUUpdater.UpdaterForBundle()"); } SUInstaller.AddInstallerForFileType(new SUExecutableInstaller(), ".exe"); SUInstaller.AddInstallerForFileType(new SUMSIInstaller(), ".msi"); SUUnarchiver.AddUnarchiverForFileType(new SUZipUnarchiver(), ".zip"); SUUnarchiver.AddUnarchiverForFileType(new SUExeUnarchiver(), ".exe"); SUUnarchiver.AddUnarchiverForFileType(new SUExeUnarchiver(), ".msi"); sharedUpdaters.Add(aBundle, this); host = new SUHost(aBundle); // Clean out old update files if they exist if (host.ObjectForUserDefaultsKey(SUConstants.SUExtractedFilesForCleanupKey) != null) { string path = (string)host.ObjectForUserDefaultsKey(SUConstants.SUExtractedFilesForCleanupKey); try { FileAttributes attr = File.GetAttributes(path); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { Directory.Delete(path, true); } else { File.Delete(path); } } catch { } finally { host.SetObjectForUserDefaultsKey(null, SUConstants.SUExtractedFilesForCleanupKey); } } OfferToAutomaticallyUpdateIfAppropriate(); ScheduleNextUpdateCheck(); }
/// <summary> /// Returns the shared updater for the given bundle. /// </summary> /// <param name="bundle">The bundle to get the updater for.</param> /// <returns>A shared updater for the given bundle.</returns> public static SUUpdater UpdaterForBundle(KNBundle bundle) { if (bundle == null) { bundle = KNBundle.MainBundle(); } SUUpdater updater = null; if (!sharedUpdaters.TryGetValue(bundle, out updater)) { updater = new SUUpdater(bundle); } return updater; }
/// <summary> /// Returns the shared updater for the given bundle. /// </summary> /// <param name="bundle">The bundle to get the updater for.</param> /// <returns>A shared updater for the given bundle.</returns> public static SUUpdater UpdaterForBundle(KNBundle bundle) { if (bundle == null) { bundle = KNBundle.MainBundle(); } SUUpdater updater = null; if (!sharedUpdaters.TryGetValue(bundle, out updater)) { updater = new SUUpdater(bundle); } return(updater); }
public SUHost(KNBundle aBundle) { bundle = aBundle; defaults = KNUserDefaults.UserDefaultsForDomain(bundle.BundleIdentifier); }
/// <summary> /// Get the shared update for the main bundle. /// </summary> /// <returns>The updater for the main bundle.</returns> public static SUUpdater SharedUpdater() { return(UpdaterForBundle(KNBundle.MainBundle())); }
private SUUpdater() : this(KNBundle.MainBundle()) { }