本文整理汇总了C#中CkanModule类的典型用法代码示例。如果您正苦于以下问题:C# CkanModule类的具体用法?C# CkanModule怎么用?C# CkanModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CkanModule类属于命名空间,在下文中一共展示了CkanModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compatible
public bool Compatible(KSPVersion gameVersion, CkanModule module)
{
KSPVersion ksp_version = module.ksp_version;
KSPVersion ksp_version_min = module.ksp_version_min;
KSPVersion ksp_version_max = module.ksp_version_max;
// Check the min and max versions.
if (ksp_version_min.IsNotAny() && gameVersion < ksp_version_min)
{
return false;
}
if (ksp_version_max.IsNotAny() && gameVersion > ksp_version_max)
{
return false;
}
// We didn't hit the min/max guards. They may not have existed.
// Note that since ksp_version is "any" if not specified, this
// will work fine if there's no target, or if there were min/max
// fields and we passed them successfully.
return ksp_version.Targets(gameVersion);
}
示例2: GetInternalAvc
public AvcVersion GetInternalAvc(CkanModule module, string filePath, string internalFilePath = null)
{
using (var zipfile = new ZipFile(filePath))
{
return GetInternalAvc(module, zipfile, internalFilePath);
}
}
示例3: GeneratorRandomModule
public CkanModule GeneratorRandomModule(
KSPVersion ksp_version = null,
List<RelationshipDescriptor> conflicts = null,
List<RelationshipDescriptor> depends = null,
List<RelationshipDescriptor> sugests = null,
List<String> provides = null,
string identifier = null,
Version version = null)
{
var mod = new CkanModule
{
name = Generator.Next().ToString(CultureInfo.InvariantCulture),
@abstract = Generator.Next().ToString(CultureInfo.InvariantCulture),
identifier = identifier??Generator.Next().ToString(CultureInfo.InvariantCulture),
spec_version = new Version(1.ToString(CultureInfo.InvariantCulture)),
ksp_version = ksp_version ?? new KSPVersion("0." + Generator.Next()),
version = version ?? new Version(Generator.Next().ToString(CultureInfo.InvariantCulture))
};
mod.ksp_version_max = mod.ksp_version_min = new KSPVersion(null);
mod.conflicts = conflicts;
mod.depends = depends;
mod.suggests = sugests;
mod.provides = provides;
return mod;
}
示例4: SingleVersionsCompatible
public override bool SingleVersionsCompatible(KspVersion gameVersion, CkanModule module)
{
// Otherwise, check if it's "generally recognise as safe".
// If we're running KSP 1.0.4, then allow the mod to run if we would have
// considered it compatible under 1.0.3 (as 1.0.4 was "just a hotfix").
if (gameVersion.Equals (KspVersion.Parse ("1.0.4")))
return strict.SingleVersionsCompatible (v103, module);
return false;
}
示例5: Compatible
public override bool Compatible(KspVersionCriteria gameVersionCriteria, CkanModule module)
{
// If it's strictly compatible, then it's compatible.
if (strict.Compatible (gameVersionCriteria, module))
return true;
// If we're in strict mode, and it's not strictly compatible, then it's
// not compatible.
if (module.ksp_version_strict)
return false;
return base.Compatible (gameVersionCriteria, module);
}
示例6: OnModChanged
public void OnModChanged(CkanModule module, GUIModChangeType changeType)
{
if (changeType == GUIModChangeType.Update || changeType == GUIModChangeType.Install)
{
var parts = GetInstalledModParts(module.identifier);
foreach (var part in parts.Where(part => _mDisabledParts.ContainsKey(part.Key)))
{
Cache.RemovePartFromCache(part.Key);
Cache.MovePartToCache(part.Key);
}
}
RefreshInstalledModsList();
}
示例7: HasInstallableFiles
public bool HasInstallableFiles(CkanModule module, string filePath)
{
try
{
ModuleInstaller.FindInstallableFiles(module, filePath, null);
}
catch (BadMetadataKraken)
{
// TODO: DBB: Let's not use exceptions for flow control
return false;
}
return true;
}
示例8: Compatible
public bool Compatible(KspVersion gameVersion, CkanModule module)
{
var gameVersionRange = gameVersion.ToVersionRange();
var moduleRange = KspVersionRange.Any;
if (module.ksp_version != null)
{
moduleRange = module.ksp_version.ToVersionRange();
}
else if (module.ksp_version_min != null || module.ksp_version_max != null)
{
if (module.ksp_version_min != null && module.ksp_version_max != null)
{
if (module.ksp_version_min <= module.ksp_version_max)
{
var minRange = module.ksp_version_min.ToVersionRange();
var maxRange = module.ksp_version_max.ToVersionRange();
moduleRange = new KspVersionRange(minRange.Lower, maxRange.Upper);
}
else
{
return false;
}
}
else if (module.ksp_version_min != null)
{
var minRange = module.ksp_version_min.ToVersionRange();
moduleRange = new KspVersionRange(minRange.Lower, KspVersionBound.Unbounded);
}
else if (module.ksp_version_max != null)
{
var maxRange = module.ksp_version_max.ToVersionRange();
moduleRange = new KspVersionRange(KspVersionBound.Unbounded, maxRange.Upper);
}
}
else
{
return true;
}
return moduleRange.IsSupersetOf(gameVersionRange);
}
示例9: SingleVersionsCompatible
public override bool SingleVersionsCompatible(KspVersion gameVersion, CkanModule module)
{
var gameVersionRange = gameVersion.ToVersionRange();
var moduleRange = KspVersionRange.Any;
if (module.ksp_version != null)
{
moduleRange = module.ksp_version.ToVersionRange();
}
else if (module.ksp_version_min != null || module.ksp_version_max != null)
{
if (module.ksp_version_min != null && module.ksp_version_max != null)
{
if (module.ksp_version_min <= module.ksp_version_max)
{
var minRange = module.ksp_version_min.ToVersionRange();
var maxRange = module.ksp_version_max.ToVersionRange();
moduleRange = new KspVersionRange(minRange.Lower, maxRange.Upper);
}
else
{
return false;
}
}
else if (module.ksp_version_min != null)
{
var minRange = module.ksp_version_min.ToVersionRange();
moduleRange = new KspVersionRange(minRange.Lower, KspVersionBound.Unbounded);
}
else if (module.ksp_version_max != null)
{
var maxRange = module.ksp_version_max.ToVersionRange();
moduleRange = new KspVersionRange(KspVersionBound.Unbounded, maxRange.Upper);
}
}
else
{
return true;
}
return gameVersionRange.IntersectWith(moduleRange) != null;
}
示例10: Compatible
public bool Compatible(KSPVersion gameVersion, CkanModule module)
{
// If it's strictly compatible, then it's compatible.
if (strict.Compatible(gameVersion, module))
return true;
// If we're in strict mode, and it's not strictly compatible, then it's
// not compatible.
if (module.ksp_version_strict)
return false;
// Otherwise, check if it's "generally recognise as safe".
// If we're running KSP 1.0.4, then allow the mod to run if we would have
// considered it compatible under 1.0.3 (as 1.0.4 was "just a hotfix").
if (gameVersion.Equals("1.0.4"))
return strict.Compatible(v103, module);
return false;
}
示例11: Recommended
public Recommended(CkanModule module)
{
if (module == null) throw new ArgumentNullException();
Parent = module;
}
示例12: Suggested
public Suggested(CkanModule module)
{
if (module == null) throw new ArgumentNullException();
Parent = module;
}
示例13: Resolve
/// <summary>
/// Resolves all relationships for a module.
/// May recurse to ResolveStanza, which may add additional modules to be installed.
/// </summary>
private void Resolve(CkanModule module, RelationshipResolverOptions options)
{
// Even though we may resolve top-level suggests for our module,
// we don't install suggestions all the down unless with_all_suggests
// is true.
var sub_options = (RelationshipResolverOptions) options.Clone();
sub_options.with_suggests = false;
log.DebugFormat("Resolving dependencies for {0}", module.identifier);
ResolveStanza(module.depends, new SelectionReason.Depends(module), sub_options);
if (options.with_recommends)
{
log.DebugFormat("Resolving recommends for {0}", module.identifier);
ResolveStanza(module.recommends, new SelectionReason.Recommended(module), sub_options, true);
}
if (options.with_suggests || options.with_all_suggests)
{
log.DebugFormat("Resolving suggests for {0}", module.identifier);
ResolveStanza(module.suggests, new SelectionReason.Suggested(module), sub_options, true);
}
}
示例14: Depends
public Depends(CkanModule module)
{
if (module == null) throw new ArgumentNullException();
Parent = module;
}
示例15: FindInstallableFiles
/// <summary>
/// Given a module and an open zipfile, return all the files that would be installed
/// for this module.
///
/// If a KSP instance is provided, it will be used to generate output paths, otherwise these will be null.
///
/// Throws a BadMetadataKraken if the stanza resulted in no files being returned.
/// </summary>
public static List<InstallableFile> FindInstallableFiles(CkanModule module, ZipFile zipfile, KSP ksp)
{
var files = new List<InstallableFile> ();
try
{
// Use the provided stanzas, or use the default install stanza if they're absent.
if (module.install != null && module.install.Length != 0)
{
foreach (ModuleInstallDescriptor stanza in module.install)
{
files.AddRange(FindInstallableFiles(stanza, zipfile, ksp));
}
}
else
{
ModuleInstallDescriptor default_stanza = ModuleInstallDescriptor.DefaultInstallStanza(module.identifier, zipfile);
files.AddRange(FindInstallableFiles(default_stanza, zipfile, ksp));
}
}
catch (BadMetadataKraken kraken)
{
// Decorate our kraken with the current module, as the lower-level
// methods won't know it.
kraken.module = module;
throw;
}
return files;
}