public void BumpAssemblyFile()
        {
            AssemblyBumper.BumpIt(new FileInfo(@".\TestInputs\Project1\Properties\AssemblyInfo.cs"), 9, 9, 9, 9);

            string content = new FileInfo(@".\TestInputs\Project1\Properties\AssemblyInfo.cs").OpenText().ReadToEnd();
            Assert.IsTrue(content.Contains(@"[assembly: AssemblyVersion(""9.9.9.9"")]"));
            Assert.IsTrue(content.Contains(@"[assembly: AssemblyFileVersion(""9.9.9.9"")]"));
        }
Exemplo n.º 2
0
        public static string GetSafeAbsolutePath(string relativeFileName)
        {
            string Result = "";

            try
            {
                // Get absolute path for the given relative path
                string SavedCurrentDirectory = Environment.CurrentDirectory;
                Environment.CurrentDirectory = ProcessUtils.StartupPath;
                string AbsoluteFileName = new FileInfo(relativeFileName).FullName;
                Environment.CurrentDirectory = SavedCurrentDirectory;

                if (AbsoluteFileName.Contains(ProcessUtils.StartupPath))
                {
                    // Path is in the LORD2 directory (or a subdirectory), so lowercase the filename so we don't have mixed case usage (for Linux)
                    string Directory = Path.GetDirectoryName(AbsoluteFileName);
                    string FileName = Path.GetFileName(AbsoluteFileName).ToLower();
                    Result = StringUtils.PathCombine(Directory, FileName);
                }
            }
            catch
            {
                // Ignore, we'll return the default ""
            }

            return Result;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Download the MPQ Files which are in nodeList and not in mpqFiles
 /// </summary>
 /// <param name="nodeList">Node List existing in version.xml</param>
 /// <param name="mpqFiles">MPQ Files existing in Data/ directory</param>
 /// <param name="dataDir">Absolute path to Data/ directory</param>
 public void Download(XmlNodeList nodeList, FileInfo[] mpqFiles, string dataDir)
 {
     DialogResult result = MessageBox.Show("Une nouvelle mise à jour a été trouvée !\r\n Télécharger ?", "Avertissement", MessageBoxButtons.OKCancel);
     if (result == DialogResult.Cancel)
     {
         Close();
     }
     else
     {
         foreach (XmlNode node in nodeList)
         {
             if (!mpqFiles.Contains(new FileInfo(node.InnerText)))
             {
                 // Have to create two WebClient
                 WebClient webClient = new WebClient();
                 WebClient webClient2 = new WebClient();
                 labelDl.Text = "Téléchargement de la mise à jour : " + node.Attributes["nom"].Value;
                 webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
                 webClient2.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient2_DownloadStringCompleted);
                 webClient2.DownloadStringAsync(new Uri(node.Attributes["desc"].Value));
                 webClient.DownloadFileAsync(new Uri(node.Attributes["lien"].Value), Path.Combine(dataDir, node.InnerText));
             }
         }
         buttonClose.Visible = true;
     }
 }
        public Plugin loadPlugin(string PluginPath)
        {
            try
            {
                string name = new FileInfo(PluginPath).Name;
                Assembly pluginAssembly = Assembly.LoadFrom(PluginPath);
                if (name.Contains("."))
                {
                    name = name.Split('.')[0];
                }

                Type pluginType = pluginAssembly.GetType(name + "." + name);
                Plugin plugin = (Plugin)Activator.CreateInstance(pluginType);
                if (plugin == null)
                {
                    Console.WriteLine("Error Loading Plugin '" + PluginPath + "'. Is it up to Date?");
                }
                else
                {
                    plugin.Server = server;
                    plugin.Load();
                    return plugin;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error Loading Plugin '" + PluginPath + "' : "
                    + exception.ToString());
            }

            return null;
        }
Exemplo n.º 5
0
        public void BumpAssemblyFile()
        {
            WXSBumper.BumpIt(new FileInfo(@".\TestInputs\Project3\Product.wxs"), 9, 9, 9, 9);

            string content = new FileInfo(@".\TestInputs\Project3\Product.wxs").OpenText().ReadToEnd();

            Assert.IsTrue(content.Contains(@"Version=""9.9.9.9"""));
        }
Exemplo n.º 6
0
Arquivo: ACCCxxx.cs Projeto: GregXP/XP
        public String GetHTML()
        {
            String email = Resource1.Email;
            try
            {
                String shortName = new FileInfo(Filename).Name;
                String typArq = shortName.Substring(shortName.IndexOf("ACCC"), 7);
                String sTypArq = Utils.GetTypArq(typArq);

                email = email.Replace(MAIL_NOMARQ, shortName);
                email = email.Replace(MAIL_TIPARQ, typArq + " - " + sTypArq);
                email = email.Replace(MAIL_TAMARQ, Tamanho.ToString("F2") + " MB");
                email = email.Replace(MAIL_PRO, shortName.Contains("PRO.xml") ? "Sim" : "N&atilde;o");

                StringBuilder sb = new StringBuilder();

                //header
                sb.AppendLine(String.Format(MAIL_LINHA_HDR, "Cabe&ccedil;alho"));
                foreach (KeyValuePair<String, String> dado in Header)
                {
                    String value = dado.Value;
                    if (!value.Equals(String.Empty))
                    {
                        sb.AppendLine(String.Format(MAIL_LINHADADO_HDR, dado.Key, dado.Value));
                    }
                }
                //body
                sb.AppendLine(String.Format(MAIL_LINHA_HDR, "Dados"));
                foreach (KeyValuePair<String, String> dado in Body)
                {
                    sb.AppendLine(String.Format(MAIL_LINHADADO, dado.Key, dado.Value));
                }
                email = email.Replace(MAIL_DADOSARQ, sb.ToString());
            }
            catch (Exception ex)
            {
                if (Utils._logger != null)
                    Utils._logger.Error("Erro ao construir o body do email." + ex.Message);
            }
            return email;
        }
        /// <summary>
        ///     Loads the plugin.yml file of a .jar plugin
        /// </summary>
        /// <param name="path">the path of the plugin.jar file</param>
        /// <param name="readCache">if this plugin should be read from cache if possible</param>
        /// <returns>The InstalledPlugin (me)</returns>
        /// <remarks></remarks>
        public InstalledPlugin Loadplugin(string path, bool readCache = true)
        {
            try
            {
                // to reduce load times and CPU usage, plugin.yml files are cached
                // location: cache/plugins/plugin_name/plugin.yml

                // Detect reletive locations and prepend thise with the plugin dir

                if (path.Contains(":\\") == false) // has to start with C:\ (\\ due to escaping special characters)
                    path = Fl.Location(RequestFile.Plugindir) + "\\" + path;

                // get a fileinfo object for the plugin
                FileInfo plugFileInfo = new FileInfo(path);

                // get a fileinfo object for the cache
                FileInfo cacheFileInfo =
                    new FileInfo(Fl.Location(RequestFile.Cache) + "/plugins/" + plugFileInfo.Name + "/plugin.yml");

                Logger.Log(LogLevel.Info, "InstalledPlugin",
                    "loading plugin (step 1/2): " + plugFileInfo.Name + " - cache allowed:" + readCache);

                //check if the cache exists, if not, create cache (we need this cache file, it will be read later on)
                if (cacheFileInfo.Exists & readCache)
                {
                    // cache exists, ok
                    Logger.Log(LogLevel.Info, "InstalledPlugin", "Reading plugin data from cache...");
                }
                else
                {
                    // cache doesn't exist or is forcefully invalidated by parameter, create

                    //safety check
                    if (string.IsNullOrEmpty(path) || plugFileInfo.Exists == false)
                    {
                        return null;
                    }

                    Logger.Log(LogLevel.Info, "InstalledPlugin",
                        "Plugin data not available in cache or cache not allowed. Building cache for plugin...");
                    Compression.Decompress(Fl.Location(RequestFile.Temp) + "/plugin", path);

                    // check if the plugin.yml file was decompressed
                    if (!File.Exists(Fl.Location(RequestFile.Temp) + "/plugin/plugin.yml"))
                    {
                        return null;
                    }

                    if (cacheFileInfo.Directory != null && !cacheFileInfo.Directory.Exists) cacheFileInfo.Directory.Create();
                    //copy the yml to cache
                    File.Copy(Fl.Location(RequestFile.Temp) + "/plugin/plugin.yml", cacheFileInfo.FullName, true);
                    if (Directory.Exists(Fl.Location(RequestFile.Temp) + "/plugin"))
                        Directory.Delete(Fl.Location(RequestFile.Temp) + "/plugin", true);
                }
                // either way is cache now okay, it already existed or was created just now
                Logger.Log(LogLevel.Info, "InstalledPlugin",
                    "loading plugin (step 2/2): " + plugFileInfo.Name + " - cache allowed:" + readCache);

                // load the yml file
                if (File.Exists(cacheFileInfo.FullName))
                    Loadymlfile(cacheFileInfo.FullName);

                FileCreationDate = File.GetLastWriteTime(path);
                FileName = new FileInfo(path).Name;

                if (Name == null || string.IsNullOrEmpty(Name) && FileName.Contains("."))
                    Name = FileName.Split('.')[0];
                //if name couldn't be read from yml, parse FileName

                Logger.Log(LogLevel.Info, "InstalledPlugin",
                    "loaded plugin: " + plugFileInfo.Name + " - cache allowed:" + readCache);

                return this;
                //return this item
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Warning, "InstalledPlugin", "An exception occured when trying to load plugin",
                    ex.Message);
                return null;
            }
        }
Exemplo n.º 8
0
        public async Task<bool> AddProjectInclude(string containerDirectory, string scriptFile = null)
        {
            if (!Project.Saved)
            {
                var saveDialogResult = MessageBox.Show(_ownerWindow, "Save pending changes to solution?",
                    "Save pending changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (saveDialogResult == DialogResult.OK || saveDialogResult == DialogResult.Yes)
                    _dte.SaveAll();
            }
            if (!Project.Saved || string.IsNullOrEmpty(Project.FullName))
            {
                var saveDialogResult = MessageBox.Show(_ownerWindow, "Pending changes need to be saved. Please save the project before adding project imports, then retry.", "Save first",
                    MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                if (saveDialogResult != DialogResult.Cancel) _dte.SaveAll();
                return false;
            }
            _logger.LogInfo("Begin adding project import file");
            if (string.IsNullOrWhiteSpace(containerDirectory))
                containerDirectory = Project.GetDirectory();

            if (string.IsNullOrWhiteSpace(scriptFile))
            {
                _logger.LogInfo("Prompting for file name");
                var dialog = new AddBuildScriptNamePrompt(containerDirectory, ".targets")
                {
                    HideInvokeBeforeAfter = true
                };
                var dialogResult = dialog.ShowDialog(VsEnvironment.OwnerWindow);
                if (dialogResult == DialogResult.Cancel) return false;
                scriptFile = dialog.FileName;
                _logger.LogInfo("File name chosen: " + scriptFile);
                dialogResult = MessageBox.Show(_ownerWindow, @"        !! IMPORTANT !!

You must not move, rename, or remove this file once it has been added to the project. By adding this file you are extending the project file itself. If you must change the filename or location, you must update the project XML directly where <Import> references it.",
                    "This addition is permanent", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.Cancel) return false;
            }
            var scriptFileName = scriptFile;
            if (!scriptFile.Contains(":") && !scriptFile.StartsWith("\\\\"))
                scriptFile = Path.Combine(containerDirectory, scriptFile);
            var scriptFileRelativePath = FileUtilities.GetRelativePath(Project.GetDirectory(), scriptFile);
            var scriptFileShortName = new FileInfo(scriptFile).Name;
            if (scriptFileShortName.Contains("."))
                scriptFileShortName = scriptFileShortName.Substring(0, scriptFileShortName.LastIndexOf("."));

            if (Project == null) return false;

            File.WriteAllText(scriptFile, @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
    <Target Name=""" + scriptFileShortName + @"""><!-- consider adding attrib BeforeTargets=""Build"" or AfterTargets=""Build"" -->

        <!-- my tasks here -->
        <Message Importance=""high"" Text=""" + scriptFileShortName + @".targets output: ProjectGuid = $(ProjectGuid)"" />

    </Target>
</Project>");
            var projRoot = Project.GetProjectRoot();
            var import = projRoot.AddImport(scriptFileRelativePath);
            import.Condition = "Exists('" + scriptFileRelativePath + "')";
            Project = await Project.SaveProjectRoot();
            var addedItem = Project.ProjectItems.AddFromFile(scriptFile);
            addedItem.Properties.Item("ItemType").Value = "None";
            _logger.LogInfo("Project include file added to project: " + scriptFileName);
            Task.Run(() =>
            {
                System.Threading.Thread.Sleep(250);
                _dte.ExecuteCommand("File.OpenFile", "\"" + scriptFile + "\"");
            });
            return true;
        }
Exemplo n.º 9
0
        private void GetSelectedText()
        {
            int activeWinPtr = GetForegroundWindow().ToInt32();
               int activeThreadId = 0, processId;
               activeThreadId = GetWindowThreadProcessId(activeWinPtr, out processId);
               int currentThreadId = GetCurrentThreadId();
               //String prev = txtCmdLine.Text;
               if (activeThreadId != currentThreadId)
               {
               AttachThreadInput(activeThreadId, currentThreadId, true);
               SendCtrlC();
               System.Threading.Thread.Sleep(10);
               AttachThreadInput(activeThreadId, currentThreadId, false);
               ShowHide();
               if (Clipboard.ContainsText())
               {
                        HandleCmd(CmdInvoker.InvokeCommand("a "+Clipboard.GetText().Replace(Environment.NewLine," ")));
               }
               else if (Clipboard.ContainsFileDropList())
               {
                   for (int i = 0; i < Clipboard.GetFileDropList().Count; i++)
                   {
                       GGResult r;
                       String f = new FileInfo(Clipboard.GetFileDropList()[i]).Name;
                       if (f.Contains('.')) f = f.Substring(0, f.LastIndexOf('.'));
                       r = CmdInvoker.InvokeCommand("a \"" + f + "\"");
                       GGItem gg = CmdInvoker.GetGGList().GetGGItemAt(r.GetItemIndex());
                       HandleCmd(r);
                       HandleCmd(CmdInvoker.InvokeCommand("pin " + (CmdInvoker.GetGGList().IndexOfGGItem(gg) + 1) + " " + Clipboard.GetFileDropList()[i]));

                   }
               }
               //if (txtCmdLine.Text.Equals("a ")) txtCmdLine.Text = prev;
               }
        }
Exemplo n.º 10
0
        private ui_context file_to_context(string name)
        {
            string from_header = log_to_default_context.file_to_context(name);
            if (from_header != null) {
                var context_from_header = contexts_.FirstOrDefault(x => x.name == from_header);
                if (context_from_header != null)
                    // return it, only if we have a specific Template for it
                    return context_from_header;
            }

            string file_name_no_dir = new FileInfo(name).Name;
            var found = contexts_.FirstOrDefault(x => file_name_no_dir.Contains( x.name));
            if (found != null)
                return found;

            var default_ = contexts_.FirstOrDefault(x => x.name == "Default");
            return default_ ?? contexts_[0];
        }