/// <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); }
private void allkidsBump(object sender, RoutedEventArgs e) { json = getTools.openJSON((Projects.SelectedItem as User).Name); help = getTools.getjsonVersion(json); help.bumpTrivial(); obj.Name = help.getVersion(); }
private void Projects_MouseDown(object sender, MouseButtonEventArgs e) { var myitem = (e.OriginalSource as FrameworkElement).DataContext as User; try { json = getTools.openJSON(myitem.Name); } catch (NullReferenceException) { } Version welp = getTools.getjsonVersion(json); obj.Name = welp.getVersion(); }
public void TestGetJSONVersion() { string filename = @"c:\My Projects\Task Scheduler"; myFile json = getTools.openJSON(filename); SpeedBump.Version result = getTools.getjsonVersion(json); string expected = "1.0.0.0"; Assert.IsNotNull(expected); Assert.AreEqual(expected, result.getVersion()); }
private void Button_Click(object sender, RoutedEventArgs e) { int choice = (int)options.EnumProperty; json = getTools.openJSON((Projects.SelectedItem as User).Name); help = getTools.getjsonVersion(json); List <string> direcs = getTools.GetDirectories(selected); StringBuilder message = new StringBuilder(@"Are you sure you would like to bump "); message.Append((Projects.SelectedItem as User).Name); message.Append(" to version "); if (choice == 0) { help.bumpTrivial(); obj.Name = help.getVersion(); } else if (choice == 1) { help.bumpMinor(); obj.Name = help.getVersion(); } else if (choice == 2) { help.bumpMajor(); obj.Name = help.getVersion(); } else if (choice == 3) { help.bumpRewrite(); obj.Name = help.getVersion(); } message.Append(help.getVersion() + "?"); MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(message.ToString(), "Bump Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { } else { help = getTools.getjsonVersion(json); obj.Name = help.getVersion(); } }
public void TestParseJson() { myFile json = new myFile(); string expected = "1.0.0.0"; SpeedBump.Version ver = new SpeedBump.Version(); json.setFilename(@"c:\My Projects\TT Gateway"); json.add("version : \"1.0.0.0\""); ver = getTools.getjsonVersion(json); Assert.AreEqual(expected, ver.getVersion()); }
/// <summary> /// Bumps all of the children contained in a parent directory. Does not write anything to file. /// </summary> /// <param name="filename">Path to the main directory</param> /// <returns>Returns a dictionary containing the paths to the children and their corresponding bumped versions.</returns> public Dictionary <string, string> bumpChildrenRewrite(string filename) { Dictionary <string, string> kids = new Dictionary <string, string>(); List <string> files = GetDirectories(filename); myFile file = new myFile(); foreach (string child in files) { file = openAssemblyInfo(child); Version little = getchildVersion(file); little.bumpRewrite(); kids.Add(little.getName(), little.getVersion()); } return(kids); }
private void verdisp(object sender, RoutedEventArgs e) { User temp = new User(); // ... Get label. try { temp = new User { Name = help.getVersion() }; } catch (NullReferenceException l) { Console.WriteLine(l); } var label = sender as System.Windows.Controls.Label; // ... Set date in content. label.Content = temp.Name; }
/// <summary> /// Takes an original file and compares the version of it against the rest of the files that have it as a dependency /// </summary> /// <param name="json">Original File</param> /// <param name="list">List of all directories to check against</param> public bool verifyAllJson(myFile json, List <myFile> list) { bool exists = false; string tempstr; Version ver = getjsonVersion(json); foreach (myFile item in list) { int last = item.getFilename().LastIndexOf('\\'); tempstr = item.getFilename().Substring(last + 1); for (int i = 0; i < item.data.Count - 1; i++) { if (item.data[i].Contains(tempstr) && item.data[i + 1].Contains(ver.getVersion())) { exists = true; } } } return(exists); }
/// <summary> /// Takes a path and creates a dictionary containing the name of each child and the corresponding version of the child. /// </summary> /// <param name="filename">The path to the parent</param> /// <returns></returns> public Dictionary <string, string> getAllChildrenVersions(string filename) { Dictionary <string, string> kids = new Dictionary <string, string>(); List <string> filesdirec = GetDirectories(filename); myFile file = new myFile(); foreach (string child in filesdirec) { file = openAssemblyInfo(child); { if (file.getCount() != 0) { Version little = getchildVersion(file); kids.Add(little.getName(), little.getVersion()); } } } return(kids); }
/// <summary> /// Writes the manifest.json file with the version of the given object /// </summary> /// <param name="file">A version object to be written</param> /// <returns>Returns True if the file was written to and False if it was not</returns> public bool writejsonVersion(Version file) { bool worked = false; string pattern = "[:][' ']\"[^\"]+\""; int count = 0; string[] temp = File.ReadAllLines(file.getName() + "\\manifest.json"); foreach (string thing in temp) { if (thing.Contains("version") && count < 2) { temp[count] = Regex.Replace(thing, pattern, ": \"" + file.getVersion() + '"'); worked = true; break; } count++; } if (worked == true) { File.WriteAllLines(file.getName() + "\\manifest.json", temp); } return(worked); }
/// <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); }