コード例 #1
0
ファイル: GetTools.cs プロジェクト: jpmacarthur/SpeedBump
        /// <summary>
        /// Gets the version of a child by parsing the assembly info file
        /// </summary>
        /// <param name="file">A myFile of a child</param>
        /// <returns>Returns a version object containing version number and name of the child</returns>
        public Version getchildVersion(myFile file)
        {
            Version ver = new Version();

            string temp    = "";
            string pattern = "\"[^\"]+\"";

            foreach (string line in file.getData())
            {
                if (line.Contains("[assembly: AssemblyVersion(") && !line.Contains("//"))
                {
                    ver = new Version();
                    ver.setType("Child");
                    ver.setName(file.getFilename());
                    var match = Regex.Match(line, pattern);
                    temp = (match.Value);
                    temp = temp.Substring(1);
                    temp = temp.TrimEnd('\"');
                    ver.setVersion(temp);

                    return(ver);
                }
            }


            return(ver);
        }
コード例 #2
0
ファイル: GetTools.cs プロジェクト: jpmacarthur/SpeedBump
        /// <summary>
        /// Parses manifest.json file to get the version of it
        /// </summary>
        /// <param name="json">A myFile that contains the contents of a manifest.json file and the path to the file</param>
        /// <returns>Returns a version object that contains the version and the name of the parent</returns>
        public Version getjsonVersion(myFile json)
        {
            Version ver   = new Version();
            int     count = 0;

            ver.setName(json.getFilename());

            string temp    = "";
            string pattern = "[:][' ']\"[^\"]+\"";

            foreach (string line in json.getData())
            {
                if (line.Contains("version") && count < 2)
                {
                    ver = new Version();
                    ver.setType("Parent");
                    var match = Regex.Match(line, pattern);
                    temp = (match.Value);
                    temp = temp.Substring(3);
                    temp = temp.TrimEnd('\"');
                    ver.setVersion(temp);
                    return(ver);
                }
                else
                {
                    count++;
                }
            }
            return(ver);
        }