• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CkanModule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CkanModule的典型用法代码示例。如果您正苦于以下问题:C# CkanModule类的具体用法?C# CkanModule怎么用?C# CkanModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CkanModule类属于命名空间,在下文中一共展示了CkanModule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
开发者ID:adamhomer88,项目名称:CKAN,代码行数:26,代码来源:StrictGameComparator.cs


示例2: GetInternalAvc

 public AvcVersion GetInternalAvc(CkanModule module, string filePath, string internalFilePath = null)
 {
     using (var zipfile = new ZipFile(filePath))
     {
         return GetInternalAvc(module, zipfile, internalFilePath);
     }
 }
开发者ID:Zor-X-L,项目名称:CKAN,代码行数:7,代码来源:ModuleService.cs


示例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;
 }
开发者ID:Rusk85,项目名称:CKAN,代码行数:25,代码来源:TestData.cs


示例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;
        }
开发者ID:KSP-CKAN,项目名称:CKAN,代码行数:11,代码来源:GrasGameComparator.cs


示例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);
        }
开发者ID:KSP-CKAN,项目名称:CKAN,代码行数:13,代码来源:GrasGameComparator.cs


示例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();
        }
开发者ID:WCapelle,项目名称:CKAN-plugins,代码行数:14,代码来源:PartManagerUI.cs


示例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;
        }
开发者ID:Zor-X-L,项目名称:CKAN,代码行数:14,代码来源:ModuleService.cs


示例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);
        }
开发者ID:CliftonMarien,项目名称:CKAN,代码行数:46,代码来源:StrictGameComparator.cs


示例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;
        }
开发者ID:KSP-CKAN,项目名称:CKAN,代码行数:46,代码来源:StrictGameComparator.cs


示例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;
        }
开发者ID:adamhomer88,项目名称:CKAN,代码行数:20,代码来源:GrasGameComparator.cs


示例11: Recommended

 public Recommended(CkanModule module)
 {
     if (module == null) throw new ArgumentNullException();
     Parent = module;
 }
开发者ID:sarbian,项目名称:CKAN,代码行数:5,代码来源:RelationshipResolver.cs


示例12: Suggested

 public Suggested(CkanModule module)
 {
     if (module == null) throw new ArgumentNullException();
     Parent = module;
 }
开发者ID:sarbian,项目名称:CKAN,代码行数:5,代码来源:RelationshipResolver.cs


示例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);
            }
        }
开发者ID:sarbian,项目名称:CKAN,代码行数:27,代码来源:RelationshipResolver.cs


示例14: Depends

 public Depends(CkanModule module)
 {
     if (module == null) throw new ArgumentNullException();
     Parent = module;
 }
开发者ID:sarbian,项目名称:CKAN,代码行数:5,代码来源:RelationshipResolver.cs


示例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;
        }
开发者ID:adamhomer88,项目名称:CKAN,代码行数:38,代码来源:ModuleInstaller.cs


示例16: MightBeInstallable

        /// <summary>
        /// Tests that a module might be able to be installed via checking if dependencies
        /// exist for current version.
        /// </summary>
        /// <param name="module">The module to consider</param>
        /// <param name="compatible">For internal use</param>
        /// <returns>If it has dependencies compatible for the current version</returns>
        private bool MightBeInstallable(CkanModule module, List<string> compatible = null)
        {
            if (module.depends == null) return true;
            if (compatible == null)
            {
                compatible = new List<string>();
            }
            else if (compatible.Contains(module.identifier))
            {
                return true;
            }
            //When checking the dependencies we assume that this module is installable
            // in case a dependent depends on it
            compatible.Add(module.identifier);

            var needed = module.depends.Select(depend => registry.LatestAvailableWithProvides(depend.name, kspversion));
            //We need every dependency to have at least one possible module
            var installable = needed.All(need => need.Any(mod => MightBeInstallable(mod, compatible)));
            compatible.Remove(module.identifier);
            return installable;
        }
开发者ID:sarbian,项目名称:CKAN,代码行数:28,代码来源:RelationshipResolver.cs


示例17: AddAvailable

        /// <summary>
        /// Mark a given module as available.
        /// </summary>
        public void AddAvailable(CkanModule module)
        {
            SealionTransaction();

            var identifier = module.identifier;
            // If we've never seen this module before, create an entry for it.
            if (! available_modules.ContainsKey(identifier))
            {
                log.DebugFormat("Adding new available module {0}", identifier);
                available_modules[identifier] = new AvailableModule(identifier);
            }

            // Now register the actual version that we have.
            // (It's okay to have multiple versions of the same mod.)

            log.DebugFormat("Available: {0} version {1}", identifier, module.version);
            available_modules[identifier].Add(module);
        }
开发者ID:Gustavo6046,项目名称:CKAN_LPIP,代码行数:21,代码来源:Registry.cs


示例18: OnModChanged

 public void OnModChanged(CkanModule module, GUIModChangeType changeType)
 {
     if (changeType == GUIModChangeType.Update || changeType == GUIModChangeType.Install)
     {
         // Todo: logic that will handle an updated mod, check all of its part files against the modified versions and propogate the changes if it can or alert the user if it can't.
     }
 }
开发者ID:WCapelle,项目名称:CKAN-plugins,代码行数:7,代码来源:PartEditorUI.cs


示例19: GetModuleContentsList

        /// <summary>
        /// Returns the module contents if and only if we have it
        /// available in our cache. Returns null, otherwise.
        ///
        /// Intended for previews.
        /// </summary>
        // TODO: Return files relative to GameRoot
        public IEnumerable<string> GetModuleContentsList(CkanModule module)
        {
            string filename = ksp.Cache.GetCachedZip(module.download);

            if (filename == null)
            {
                return null;
            }

            return FindInstallableFiles(module, filename, ksp)
                .Select(x => x.destination);
        }
开发者ID:adamhomer88,项目名称:CKAN,代码行数:19,代码来源:ModuleInstaller.cs


示例20: ShowMod

        /// <summary>
        /// Shows information about the mod.
        /// </summary>
        /// <returns>Success status.</returns>
        /// <param name="module">The module to show.</param>
        public int ShowMod(CkanModule module)
        {
            #region Abstract and description
            if (!string.IsNullOrEmpty([email protected]))
            {
                user.RaiseMessage("{0}: {1}", module.name, [email protected]);
            }
            else
            {
                user.RaiseMessage("{0}", module.name);
            }

            if (!string.IsNullOrEmpty(module.description))
            {
                user.RaiseMessage("\n{0}\n", module.description);
            }
            #endregion

            #region General info (author, version...)
            user.RaiseMessage("\nModule info:");
            user.RaiseMessage("- version:\t{0}", module.version);

            if (module.author != null)
            {
                user.RaiseMessage("- authors:\t{0}", string.Join(", ", module.author));
            }
            else
            {
                // Did you know that authors are optional in the spec?
                // You do now. #673.
                user.RaiseMessage("- authors:\tUNKNOWN");
            }

            user.RaiseMessage("- status:\t{0}", module.release_status);
            user.RaiseMessage("- license:\t{0}", string.Join(", ", module.license)); 
            #endregion

            #region Relationships
            if (module.depends != null && module.depends.Count > 0)
            {
                user.RaiseMessage("\nDepends:");
                foreach (RelationshipDescriptor dep in module.depends)
                    user.RaiseMessage("- {0}", RelationshipToPrintableString(dep));
            }

            if (module.recommends != null && module.recommends.Count > 0)
            {
                user.RaiseMessage("\nRecommends:");
                foreach (RelationshipDescriptor dep in module.recommends)
                    user.RaiseMessage("- {0}", RelationshipToPrintableString(dep));
            }

            if (module.suggests != null && module.suggests.Count > 0)
            {
                user.RaiseMessage("\nSuggests:");
                foreach (RelationshipDescriptor dep in module.suggests)
                    user.RaiseMessage("- {0}", RelationshipToPrintableString(dep));
            }

            if (module.ProvidesList != null && module.ProvidesList.Count > 0)
            {
                user.RaiseMessage("\nProvides:");
                foreach (string prov in module.ProvidesList)
                    user.RaiseMessage("- {0}", prov);
            } 
            #endregion

            user.RaiseMessage("\nResources:");
            if (module.resources != null)
            {
                if (module.resources.bugtracker != null)
                    user.RaiseMessage("- bugtracker: {0}", Uri.EscapeUriString(module.resources.bugtracker.ToString()));
                if (module.resources.homepage != null)
                    user.RaiseMessage("- homepage: {0}", Uri.EscapeUriString(module.resources.homepage.ToString()));
                if (module.resources.kerbalstuff != null)
                    user.RaiseMessage("- kerbalstuff: {0}", Uri.EscapeUriString(module.resources.kerbalstuff.ToString()));
                if (module.resources.repository != null)
                    user.RaiseMessage("- repository: {0}", Uri.EscapeUriString(module.resources.repository.ToString()));
            }

            // Compute the CKAN filename.
            string file_uri_hash = NetFileCache.CreateURLHash(module.download);
            string file_name = CkanModule.StandardName(module.identifier, module.version);

            user.RaiseMessage("\nFilename: {0}", file_uri_hash + "-" + file_name);

            return Exit.OK;
        }
开发者ID:adamhomer88,项目名称:CKAN,代码行数:93,代码来源:Show.cs



注:本文中的CkanModule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Claim类代码示例发布时间:2022-05-24
下一篇:
C# City类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap