public void Add_RDom_constructors() { var filePairs = UpdateUtilities.GetFilePairs("*.cs", inputDirectory, outputDirectory + "_B", subDirectories); UpdateUtilities.DoUpdateOnFiles(filePairs, root => GetRDomClasses(root), NeedsConstructor, AddConstructor); }
private void Update() { var executablePath = UpdateUtilities.DownloadUpdateExecutable(); var process = new Process { StartInfo = new ProcessStartInfo(executablePath, $"{Program.ApplicationType} {Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)}") }; process.Start(); }
public void Update_notify_property_changed() { //Assert.Inconclusive(); // workspace problem var filePairs = UpdateUtilities.GetFilePairs("*.cs", inputDirectory, outputDirectory + "_A", subDirectories); UpdateUtilities.DoUpdateOnFiles(filePairs, root => root.Descendants .OfType <IProperty>() .Where(x => IsInRDomClass(x)), new UpdateNotifyPropertyChanged()); }
private static void CheckForUpdate() { var remoteManifest = UpdateUtilities.GetRemoteManifest(ManifestUrl); if (!UpdateUtilities.IsUpdateAvailable(remoteManifest, _localManifest, true)) { return; } Console.WriteLine(); Console.WriteLine($"A new version is available: {remoteManifest.Version}-{remoteManifest.BuildNumber}"); }
public void Write_all_text_writes_root() { const string fileName = "temp.cs"; var csharpCode = @" using System.Diagnostics.Tracing; namespace Namespace1 { }"; IRoot root = RDom.CSharp.Load(csharpCode); Assert.IsNotNull(root); UpdateUtilities.WriteToFile(fileName, root); File.Exists(fileName); var actual = File.ReadAllText(fileName); Assert.AreEqual(csharpCode, actual); }
public void Write_all_text_writes_root_to_new_directory() { const string dirName = "TempTestDir"; string fileName = Path.Combine(dirName, "temp.cs"); if (Directory.Exists(dirName)) { Directory.Delete(dirName, true); } var csharpCode = @" using System.Diagnostics.Tracing; namespace Namespace1 { }"; IRoot root = RDom.CSharp.Load(csharpCode); Assert.IsNotNull(root); UpdateUtilities.WriteToFile(fileName, root); File.Exists(fileName); var actual = File.ReadAllText(fileName); Assert.AreEqual(csharpCode, actual); }
private static void InstallByKey(string key, Action asyncAction = null) { PluginDownloadItem plugin = Instance.AvailablePlugins.FirstOrDefault(p => string.Equals(p.Name, key, Constants.InvariantComparer)); if (plugin == null) { return; } UpdateView.View.AvailableLoadingInformation.Visibility = Visibility.Visible; UpdateView.View.AvailableLoadingProgressMessage.Visibility = Visibility.Visible; Func <bool> install = delegate { var updateCount = 0; var updateLimit = plugin.Files.Count; var sb = new StringBuilder(); foreach (PluginFile pluginFile in plugin.Files) { sb.Clear(); try { using (var client = new WebClient { CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore) }) { var saveLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Plugins", plugin.Name, pluginFile.Location, pluginFile.Name); Directory.CreateDirectory(Path.GetDirectoryName(saveLocation)); if (UpdateUtilities.VerifyFile(saveLocation, pluginFile.Checksum)) { // no need to download file, since it hasn't changed // count this file as "updated" for the purpose of checking if the install finished updateCount++; } else { sb.Append(plugin.SourceURI.Trim('/')); var location = pluginFile.Location.Trim('/'); if (!string.IsNullOrWhiteSpace(location)) { sb.AppendFormat("/{0}", location); } sb.AppendFormat("/{0}", pluginFile.Name.Trim('/')); var uri = new Uri(sb.ToString()); client.DownloadFileAsync(uri, saveLocation); client.DownloadProgressChanged += delegate { DispatcherHelper.Invoke( delegate { UpdateView.View.AvailableLoadingProgressMessage.Text = $"{pluginFile.Location.Trim('/')}/{pluginFile.Name}"; }); }; client.DownloadFileCompleted += delegate { updateCount++; if (updateCount >= updateLimit) { DispatcherHelper.Invoke( delegate { if (plugin.Status != PluginStatus.Installed) { plugin.Status = PluginStatus.Installed; Instance.SetupGrouping(); if (asyncAction != null) { DispatcherHelper.Invoke(asyncAction); } } UpdateView.View.AvailableLoadingProgressMessage.Text = string.Empty; UpdateView.View.AvailableLoadingInformation.Visibility = Visibility.Collapsed; UpdateView.View.AvailableLoadingProgressMessage.Visibility = Visibility.Collapsed; }, DispatcherPriority.Send); } }; } } } catch (Exception) { updateCount++; } } // need to check here aswell, since if all files mathced hash, none will be downloaded, so the DownloadFileCompleted delegate would never be triggered if (updateCount >= updateLimit) { if (plugin.Status != PluginStatus.Installed) { plugin.Status = PluginStatus.Installed; Instance.SetupGrouping(); if (asyncAction != null) { DispatcherHelper.Invoke(asyncAction); } } DispatcherHelper.Invoke( delegate { UpdateView.View.AvailableLoadingInformation.Visibility = Visibility.Collapsed; UpdateView.View.AvailableLoadingProgressMessage.Visibility = Visibility.Collapsed; }, DispatcherPriority.Send); } return(true); }; install.BeginInvoke(delegate { }, install); }