Skip to content

Commit

Permalink
Merge pull request #92 from AlexanderDzhoganov/master
Browse files Browse the repository at this point in the history
Reformatting
  • Loading branch information
pjf committed Oct 19, 2014
2 parents 3a1c2f5 + 31e209d commit 623d9b4
Show file tree
Hide file tree
Showing 38 changed files with 1,790 additions and 1,686 deletions.
50 changes: 31 additions & 19 deletions CKAN/CKAN.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CKAN", "CKAN\CKAN.csproj", "{3B9AEA22-FA3B-4E43-9283-EABDD81CF271}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{92442BD6-F533-4BB8-8E04-9D93A038035E}"
ProjectSection(ProjectDependencies) = postProject
{4336F356-33DB-442A-BF74-5E89AF47A5B9} = {4336F356-33DB-442A-BF74-5E89AF47A5B9}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CmdLine", "CmdLine\CmdLine.csproj", "{E97D81F6-85E2-4F1F-906D-BE21766602E5}"
EndProject
Expand All @@ -14,45 +19,55 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B9AEA22-FA3B-4E43-9283-EABDD81CF271}.Debug|Any CPU.ActiveCfg = Debug|x86
{3B9AEA22-FA3B-4E43-9283-EABDD81CF271}.Debug|Any CPU.Build.0 = Debug|x86
{3B9AEA22-FA3B-4E43-9283-EABDD81CF271}.Debug|x86.ActiveCfg = Debug|x86
{3B9AEA22-FA3B-4E43-9283-EABDD81CF271}.Release|Any CPU.ActiveCfg = Release|x86
{3B9AEA22-FA3B-4E43-9283-EABDD81CF271}.Release|Any CPU.Build.0 = Release|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Debug|Any CPU.ActiveCfg = Debug|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Debug|Any CPU.Build.0 = Debug|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Debug|x86.ActiveCfg = Debug|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Debug|x86.Build.0 = Debug|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Release|Any CPU.ActiveCfg = Release|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Release|Any CPU.Build.0 = Release|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Release|x86.ActiveCfg = Release|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Release|x86.Build.0 = Release|x86
{3B9AEA22-FA3B-4E43-9283-EABDD81CF271}.Release|x86.ActiveCfg = Release|x86
{92442BD6-F533-4BB8-8E04-9D93A038035E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92442BD6-F533-4BB8-8E04-9D93A038035E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92442BD6-F533-4BB8-8E04-9D93A038035E}.Debug|x86.ActiveCfg = Debug|Any CPU
{92442BD6-F533-4BB8-8E04-9D93A038035E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92442BD6-F533-4BB8-8E04-9D93A038035E}.Release|Any CPU.Build.0 = Release|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Release|Any CPU.Build.0 = Release|Any CPU
{92442BD6-F533-4BB8-8E04-9D93A038035E}.Release|x86.ActiveCfg = Release|Any CPU
{E97D81F6-85E2-4F1F-906D-BE21766602E5}.Debug|Any CPU.ActiveCfg = Debug|x86
{E97D81F6-85E2-4F1F-906D-BE21766602E5}.Debug|Any CPU.Build.0 = Debug|x86
{E97D81F6-85E2-4F1F-906D-BE21766602E5}.Debug|x86.ActiveCfg = Debug|x86
{E97D81F6-85E2-4F1F-906D-BE21766602E5}.Release|Any CPU.ActiveCfg = Release|x86
{E97D81F6-85E2-4F1F-906D-BE21766602E5}.Release|Any CPU.Build.0 = Release|x86
{E97D81F6-85E2-4F1F-906D-BE21766602E5}.Release|x86.ActiveCfg = Release|x86
{A79F9D54-315C-472B-928F-713A5860B2BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Debug|x86.ActiveCfg = Debug|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Release|Any CPU.Build.0 = Release|Any CPU
{A79F9D54-315C-472B-928F-713A5860B2BE}.Release|x86.ActiveCfg = Release|Any CPU
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Debug|Any CPU.ActiveCfg = Debug|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Debug|Any CPU.Build.0 = Debug|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Debug|x86.ActiveCfg = Debug|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Debug|x86.Build.0 = Debug|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Release|Any CPU.ActiveCfg = Release|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Release|Any CPU.Build.0 = Release|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Release|x86.ActiveCfg = Release|x86
{4336F356-33DB-442A-BF74-5E89AF47A5B9}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = CKAN\CKAN.csproj
Policies = $0
$0.TextStylePolicy = $1
$0.TextStylePolicy = $2
$1.FileWidth = 120
$1.TabsToSpaces = False
$1.inheritsSet = VisualStudio
$1.inheritsScope = text/plain
$0.TextStylePolicy = $2
$2.inheritsSet = VisualStudio
$2.inheritsScope = text/plain
$2.scope = text/x-csharp
Expand Down Expand Up @@ -83,7 +98,4 @@ Global
$3.scope = text/x-csharp
$4.IncludeInNewFiles = True
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
64 changes: 33 additions & 31 deletions CKAN/CKAN/AvailableModule.cs
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;

}
}
}

}
20 changes: 12 additions & 8 deletions CKAN/CKAN/InstalledModule.cs
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;
}
}
}
}
Loading

0 comments on commit 623d9b4

Please sign in to comment.