For CDLC provides information about Toolkit version, the package author, the package version and a comment.
コード例 #1
0
        public static ToolkitInfo GetToolkitInfo(StreamReader reader)
        {
            if (reader == null)
            {
                return(null);
            }

            var    tkInfo = new ToolkitInfo();
            string line   = null;

            while ((line = reader.ReadLine()) != null)
            {
                // we need to decipher what this line contains;
                // older toolkit versions just put a single line with the version number
                // newer versions put several lines in the format "key : value"
                var tokens = line.Split(new char[] { ':' });
                // trim all tokens of surrounding whitespaces
                for (int i = 0; i < tokens.Length; ++i)
                {
                    tokens[i] = tokens[i].Trim();
                }

                if (tokens.Length == 1)
                {
                    // this is probably just the version number
                    tkInfo.ToolkitVersion = tokens[0];
                }
                if (tokens.Length == 2)
                {
                    // key/value attribute
                    var key = tokens[0].ToLower();
                    switch (key)
                    {
                    case "toolkit version":
                        tkInfo.ToolkitVersion = tokens[1]; break;

                    case "package author":
                        tkInfo.PackageAuthor = tokens[1]; break;

                    case "package version":
                        tkInfo.PackageVersion = tokens[1]; break;

                    case "package comment":
                        tkInfo.PackageComment = tokens[1]; break;

                    case "package rating":
                        tkInfo.PackageRating = tokens[1]; break;

                    default:
                        Console.WriteLine("  Notice: Unknown key in toolkit.version: {0}", key);
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("  Notice: Unrecognized line in toolkit.version: {0}", line);
                }
            }
            return(tkInfo);
        }
コード例 #2
0
        public ToolkitInfo ExtractToolkitInfo()
        {
            var tkInfo = new ToolkitInfo();
            var toolkitVersionEntry = _archive.TOC.FirstOrDefault(x => (x.Name.Equals("toolkit.version")));

            if (toolkitVersionEntry != null)
            {
                _archive.InflateEntry(toolkitVersionEntry);
                toolkitVersionEntry.Data.Position = 0;
                tkInfo = GeneralExtensions.GetToolkitInfo(new StreamReader(toolkitVersionEntry.Data));
            }
            else
            {
                // this helps prevent null exceptions
                tkInfo.ToolkitVersion = "N/A";
                tkInfo.PackageAuthor = "Ubisoft";
                tkInfo.PackageVersion = "N/A";
                tkInfo.PackageComment = "N/A";
            }

            return tkInfo;
        }