コード例 #1
0
 private void RefreshCommandCacheItems()
 {
     if (TabControl.SelectedTab == tabPageCommandCache)
     {
         RefreshListBox(CommandCacheItems, GitCommandCache.CachedCommands());
     }
 }
コード例 #2
0
 public void TestTryGetFails()
 {
     Assert.IsFalse(GitCommandCache.TryGet(null, out var output, out var error));
     Assert.IsFalse(GitCommandCache.TryGet(String.Empty, out output, out error));
     Assert.IsNull(output);
     Assert.IsNull(error);
 }
コード例 #3
0
        private void GitLogFormLoad(object sender, EventArgs e)
        {
            RestorePosition("log");

            LogItems.DataSource = Settings.GitLog.Commands();

            CommandCacheItems.DataSource = GitCommandCache.CachedCommands().ToList();
        }
コード例 #4
0
        public void TestAdd()
        {
            byte[]   output = new byte[] { 11, 12 };
            byte[]   error  = new byte[] { 13, 14 };
            string[] expectedCachedCommand = { "git command" };

            GitCommandCache.Add("git command", output, error);

            Assert.IsTrue(expectedCachedCommand.SequenceEqual(GitCommandCache.CachedCommands()));
        }
コード例 #5
0
ファイル: FormGitLog.cs プロジェクト: yuenshome/gitextensions
        private void CommandCacheItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            string command = (string)CommandCacheItems.SelectedItem;

            if (GitCommandCache.TryGet(command, out var cmdout, out var cmderr))
            {
                commandCacheOutput.Text = command + "\n-------------------------------------\n\n";
                Encoding encoding = GitModule.SystemEncoding;
                commandCacheOutput.Text += EncodingHelper.DecodeString(cmdout, cmderr, ref encoding).Replace("\0", "\\0");
            }
コード例 #6
0
        public void TestTryGetFails()
        {
            byte[] output = null;
            byte[] error  = null;

            Assert.IsFalse(GitCommandCache.TryGet(null, out output, out error));
            Assert.IsFalse(GitCommandCache.TryGet(String.Empty, out output, out error));
            Assert.IsNull(output);
            Assert.IsNull(error);
        }
コード例 #7
0
        public void TestTryGet()
        {
            byte[] originalOutput = new byte[] { 11, 12 };
            byte[] originalError  = new byte[] { 13, 14 };

            GitCommandCache.Add("git command", originalOutput, originalError);

            Assert.IsTrue(GitCommandCache.TryGet("git command", out var cachedOutput, out var cachedError));
            Assert.AreEqual(cachedOutput, originalOutput);
            Assert.AreEqual(cachedError, originalError);
        }
コード例 #8
0
        public void TestClean()
        {
            byte[]   output = { 11, 12 };
            byte[]   error  = { 13, 14 };
            string[] expectedCachedCommand = { "git command" };

            GitCommandCache.Add("git command", output, error);
            Assert.IsTrue(expectedCachedCommand.SequenceEqual(GitCommandCache.CachedCommands()));
            GitCommandCache.CleanCache();
            Assert.IsFalse(GitCommandCache.CachedCommands().Any());
        }
コード例 #9
0
        private void CommandCacheItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            string command = CommandCacheItems.SelectedItem as string;

            string output;

            if (GitCommandCache.TryGet(command, out output))
            {
                commandCacheOutput.Text  = command + "\n-------------------------------------\n\n";
                commandCacheOutput.Text += output.Replace("\0", "\\0");
            }
            else
            {
                commandCacheOutput.Text = string.Empty;
            }
        }
コード例 #10
0
ファイル: GitLogForm.cs プロジェクト: antis81/gitextensions
        protected void RefreshCommandCacheItems()
        {
            SendOrPostCallback method = o =>
            {
                if (TabControl.SelectedTab == tabPageCommandCache)
                {
                    bool selectLastIndex = CommandCacheItems.Items.Count == 0 || CommandCacheItems.SelectedIndex == CommandCacheItems.Items.Count - 1;
                    CommandCacheItems.DataSource = GitCommandCache.CachedCommands();
                    if (selectLastIndex && CommandCacheItems.Items.Count > 0)
                    {
                        CommandCacheItems.SelectedIndex = CommandCacheItems.Items.Count - 1;
                    }
                }
            };

            syncContext.Post(method, this);
        }
コード例 #11
0
 public void TestAddCannotCache()
 {
     GitCommandCache.Add(null, null, null);
     Assert.IsFalse(GitCommandCache.CachedCommands().Any());
 }
コード例 #12
0
 public void Cleanup()
 {
     GitCommandCache.CleanCache();
 }