Example #1
0
        /// <summary>
        /// Searches through other directories inside the main project and rewrites the manifest.json file with the updated version
        /// </summary>
        /// <param name="json">The main json file used to write the dependents</param>
        /// <param name="dir">Directory of the main project</param>
        /// <returns></returns>
        public bool writeOtherDep(myFile json, string dir)
        {
            Version       ver    = getjsonVersion(json);
            List <string> direcs = GetDirectories(dir);
            string        tempstr;
            string        pattern = "[:][' ']\"[^\"]+\"";

            foreach (string location in direcs)
            {
                int last = json.getFilename().LastIndexOf('\\');
                tempstr = json.getFilename().Substring(last + 1);
                try
                {
                    string[] temp = File.ReadAllLines(location + "\\manifest.json");
                    for (int i = 0; i < temp.Count() - 1; i++)
                    {
                        if (temp[i].Contains(tempstr))
                        {
                            temp[i + 1] = Regex.Replace(temp[i + 1], pattern, ": \"" + ver.getVersion() + '"');
                        }
                    }
                    File.WriteAllLines(location + "\\manifest.json", temp);
                }
                catch (FileNotFoundException e) { Console.WriteLine(e); }
            }

            return(true);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <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);
        }
Example #4
0
        /// <summary>
        /// Verifies that all versions in the main directory match.
        /// </summary>
        /// <param name="json">Original file which contains a path and its version</param>
        /// <param name="dir">The main directory</param>
        /// <returns>Returns false and throws exception if not matching</returns>
        public bool verify(myFile json, string dir)
        {
            bool    matches     = true;
            Version jsonversion = getjsonVersion(json);
            Dictionary <string, string> kids = getAllChildrenVersions(json.getFilename());
            List <myFile> direcs             = openAllJson(dir);

            foreach (KeyValuePair <string, string> entry in kids)
            {
                if (entry.Value != jsonversion.getVersion())
                {
                    matches = false;
                    Exception MismatchedVersion = new Exception(); throw MismatchedVersion;
                }
            }

            if (verifyAllJson(json, direcs) != true)
            {
                matches = false; Exception MismatchedVersion = new Exception(); throw MismatchedVersion;
            }
            ;


            return(matches);
        }