Permalink
Browse files

* src/CommandContexts/DirectoryManagement/ListDirectoriesContext.cs,

  src/CommandContexts/DirectoryManagement/RemoveDirectoryContext.cs,
  src/CommandContexts/ListenerManagement/RemoveListenerContext.cs,
  src/CommandContexts/ListenerManagement/ListListenersContext.cs,
  src/CommandContexts/Options/Options.cs, src/TrackerHost.cs: Fixed
  issues when listing or removing Directories and Listeners

svn path=/trunk/tsunami/; revision=114788
  • Loading branch information...
1 parent d6ea421 commit 79b6cd21a2cfefa7a8dd6287a1ef74cd3584bcc7 @alanmcgovern alanmcgovern committed Oct 3, 2008
@@ -27,6 +27,7 @@
//
using System;
+using System.IO;
namespace Tsunami
{
@@ -35,9 +36,16 @@ class ListDirectoriesContext : Context
public ListDirectoriesContext(Context parent)
{
Parent = parent;
+ }
+ protected override void PrintImpl(TextWriter writer)
+ {
+ Options.Clear();
foreach (string s in ((GeneralContext)BaseContext).Tracker.Watchers.Keys)
Options.Add(new Option(s));
+
+ writer.WriteLine("There are {0} monitored directories");
+ base.PrintImpl(writer);
}
}
}
@@ -35,8 +35,6 @@ class RemoveDirectoryContext : Context
public RemoveDirectoryContext(Context parent)
{
Parent = parent;
- foreach (string s in ((GeneralContext)BaseContext).Tracker.Watchers.Keys)
- Options.Add(new Option(s, (Options.Count + 1).ToString()));
}
protected override Result HandleImpl(string line)
@@ -54,6 +52,10 @@ protected override Result HandleImpl(string line)
protected override void PrintImpl(System.IO.TextWriter writer)
{
+ Options.Clear();
+ foreach (string s in ((GeneralContext)BaseContext).Tracker.Watchers.Keys)
+ Options.Add(new Option(s, (Options.Count + 1).ToString()));
+
writer.WriteLine("Choose the directory to stop monitoring");
base.PrintImpl(writer);
}
@@ -35,13 +35,14 @@ class ListListenersContext : Context
public ListListenersContext(Context parent)
{
Parent = parent;
-
- foreach (Uri uri in ((GeneralContext)BaseContext).Tracker.Listeners.Keys)
- Options.Add(new Option(uri.ToString(), (Options.Count + 1).ToString()));
}
protected override void PrintImpl(System.IO.TextWriter writer)
{
+ Options.Clear();
+ foreach (Uri uri in ((GeneralContext)BaseContext).Tracker.Listeners.Keys)
+ Options.Add(new Option(uri.ToString()));
+
writer.WriteLine("There are {0} registered addresses", Options.Count);
base.PrintImpl(writer);
}
@@ -35,9 +35,6 @@ class RemoveListenerContext : Context
public RemoveListenerContext(Context parent)
{
Parent = parent;
-
- foreach (Uri uri in ((GeneralContext)BaseContext).Tracker.Listeners.Keys)
- Options.Add(new Option(uri.ToString(), (Options.Count + 1).ToString()));
}
protected override Result HandleImpl(string line)
@@ -55,6 +52,10 @@ protected override Result HandleImpl(string line)
protected override void PrintImpl(System.IO.TextWriter writer)
{
+ Options.Clear();
+ foreach (Uri uri in ((GeneralContext)BaseContext).Tracker.Listeners.Keys)
+ Options.Add(new Option(uri.ToString(), (Options.Count + 1).ToString()));
+
writer.WriteLine("Choose the address to stop monitoring");
base.PrintImpl(writer);
}
@@ -39,6 +39,7 @@ public int Count
{
get { return options.Count; }
}
+
public Option this[int index]
{
get { return options[index]; }
@@ -57,6 +58,11 @@ public void AddRange(IEnumerable<Option> options)
Add(o);
}
+ public void Clear()
+ {
+ options.Clear();
+ }
+
public Option Find (Predicate<Option> predicate)
{
return options.Find(predicate);
View
@@ -86,9 +86,9 @@ private bool Process(string s)
if (s != "__RefreshTheScreen__")
r = context.Handle(s) != Result.ShouldPop;
- if (!r)
+ if (!r && s != "__RefreshTheScreen__")
return r;
-
+
Console.Clear();
context.Print(Console.Out);
Console.Out.WriteLine();

0 comments on commit 79b6cd2

Please sign in to comment.