-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from AlexanderDzhoganov/master
Reformatting
- Loading branch information
Showing
38 changed files
with
1,790 additions
and
1,686 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,66 @@ | ||
namespace CKAN { | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using log4net; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using log4net; | ||
|
||
namespace CKAN | ||
{ | ||
/// <summary> | ||
/// Utility class to track version -> module mappings | ||
/// Utility class to track version -> module mappings | ||
/// </summary> | ||
public class AvailableModule { | ||
|
||
public class AvailableModule | ||
{ | ||
// The map of versions -> modules, that's what we're about! | ||
// This *has* to be public, as it's generated by a JSON deserialiser | ||
public Dictionary<Version,CkanModule> module_version = new Dictionary<Version, CkanModule> (); | ||
|
||
private static readonly ILog log = LogManager.GetLogger(typeof(AvailableModule)); | ||
|
||
public AvailableModule() { } | ||
private static readonly ILog log = LogManager.GetLogger(typeof (AvailableModule)); | ||
public Dictionary<Version, CkanModule> module_version = new Dictionary<Version, CkanModule>(); | ||
|
||
public void Add(CkanModule module) { | ||
log.DebugFormat ("Adding {0}", module); | ||
public void Add(CkanModule module) | ||
{ | ||
log.DebugFormat("Adding {0}", module); | ||
module_version[module.version] = module; | ||
} | ||
|
||
/// <summary> | ||
/// Return the most recent release of a module. | ||
/// Optionally takes a KSP version number to target. | ||
/// Returns null if there are no compatible versions. | ||
/// Return the most recent release of a module. | ||
/// Optionally takes a KSP version number to target. | ||
/// Returns null if there are no compatible versions. | ||
/// </summary> | ||
public CkanModule Latest(KSPVersion ksp_version = null) { | ||
var available_versions = new List<Version> (module_version.Keys); | ||
public CkanModule Latest(KSPVersion ksp_version = null) | ||
{ | ||
var available_versions = new List<Version>(module_version.Keys); | ||
|
||
log.DebugFormat ("Our dictionary has {0} keys", module_version.Keys.Count); | ||
log.DebugFormat ("Choosing between {0} available versions", available_versions.Count); | ||
log.DebugFormat("Our dictionary has {0} keys", module_version.Keys.Count); | ||
log.DebugFormat("Choosing between {0} available versions", available_versions.Count); | ||
|
||
// Sort most recent versions first. | ||
|
||
available_versions.Sort (); | ||
available_versions.Sort(); | ||
available_versions.Reverse(); | ||
|
||
if (ksp_version == null) { | ||
CkanModule module = module_version [available_versions.First ()]; | ||
if (ksp_version == null) | ||
{ | ||
CkanModule module = module_version[available_versions.First()]; | ||
|
||
log.DebugFormat ("No KSP version restriction, {0} is most recent", module); | ||
log.DebugFormat("No KSP version restriction, {0} is most recent", module); | ||
return module; | ||
} | ||
|
||
// Time to check if there's anything that we can satisfy. | ||
|
||
foreach (Version v in available_versions) { | ||
if (module_version[v].IsCompatibleKSP (ksp_version)) { | ||
foreach (Version v in available_versions) | ||
{ | ||
if (module_version[v].IsCompatibleKSP(ksp_version)) | ||
{ | ||
return module_version[v]; | ||
} | ||
} | ||
|
||
log.DebugFormat ("No version of {0} is compatible with KSP {1}", module_version [available_versions[0]].identifier, ksp_version); | ||
log.DebugFormat("No version of {0} is compatible with KSP {1}", | ||
module_version[available_versions[0]].identifier, ksp_version); | ||
|
||
// Oh noes! Nothing available! | ||
return null; | ||
|
||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
namespace CKAN { | ||
using System; | ||
using System.Collections.Generic; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public class InstalledModuleFile { | ||
namespace CKAN | ||
{ | ||
public class InstalledModuleFile | ||
{ | ||
public string sha1_sum; | ||
} | ||
|
||
public class InstalledModule { | ||
public class InstalledModule | ||
{ | ||
public DateTime install_time; | ||
public Dictionary<string, InstalledModuleFile> installed_files; | ||
public Module source_module; | ||
public DateTime install_time; | ||
|
||
public InstalledModule (Dictionary <string, InstalledModuleFile> installed_files, Module source_module, DateTime install_time) | ||
public InstalledModule(Dictionary<string, InstalledModuleFile> installed_files, Module source_module, | ||
DateTime install_time) | ||
{ | ||
this.installed_files = installed_files; | ||
this.source_module = source_module; | ||
this.install_time = install_time; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.