123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System;
- namespace TBL.GodotSharp.Content
- {
- public partial class PackageNode
- {
- /// <summary>
- /// 包信息
- /// </summary>
- public struct Info
- {
- /// <summary>
- /// 包名称
- /// </summary>
- public readonly string Name;
- /// <summary>
- /// 作者信息
- /// </summary>
- public readonly string AuthorInfo;
-
- /// <summary>
- /// 版本信息
- /// </summary>
- public readonly Version VersionInfo;
- public Info(string name, string author, string version)
- {
- Name = name;
- AuthorInfo = author;
- if (!Version.TryParse(version, out VersionInfo))
- VersionInfo = new Version();
- }
- public Info(string name, string author, Version version)
- {
- Name = name;
- AuthorInfo = author;
- VersionInfo = version;
- }
- /// <summary>
- /// 判断本信息能否满足 <paramref name="target"/> 的版本要求
- /// </summary>
- /// <param name="target">依赖项信息</param>
- public bool IsCompatibleWith(DependencyInfo target)
- {
- return Content.IsCompatibleWith(VersionInfo, target.Target.VersionInfo,
- (target.Flags & DependencyInfo.FlagsEnum.Strict) != 0 ? 1 : 0);
- }
- public override string ToString() => $"[{Name}][{AuthorInfo}][{VersionInfo}]";
- }
- /// <summary>
- /// 包依赖信息
- /// </summary>
- public struct DependencyInfo
- {
- /// <summary>
- /// 依赖目标
- /// </summary>
- public readonly Info Target;
- /// <summary>
- /// 依赖属性
- /// </summary>
- public readonly FlagsEnum Flags;
-
- /// <summary>
- /// 依赖项属性
- /// </summary>
- [Flags]
- public enum FlagsEnum
- {
- /// <summary>
- /// 无属性
- /// </summary>
- None,
-
- /// <summary>
- /// 非必须依赖项
- /// </summary>
- Unnecessary,
- /// <summary>
- /// 严格(次版本号)兼容依赖项
- /// </summary>
- Strict
- }
- public DependencyInfo(Info target, FlagsEnum flags = FlagsEnum.None)
- {
- Target = target;
- Flags = flags;
- }
- }
- }
- }
|