Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2008-12-19 04:39:15 +0300
committerMiguel de Icaza <miguel@gnome.org>2008-12-19 04:39:15 +0300
commit93c9bdf26ed3558bee7d2aecc6c2210c8c8baa0e (patch)
tree32d06fcaf9d7d3fb67578553e7fe7d57e7cf3321 /webcompare
parentcd80e8d2cdfc257afa322ee5bec29829095c2790 (diff)
2008-12-18 Miguel de Icaza <miguel@novell.com>
* Global.asax: Trigger an update if the files change on disk. svn path=/trunk/mono-tools/; revision=121827
Diffstat (limited to 'webcompare')
-rw-r--r--webcompare/ChangeLog4
-rw-r--r--webcompare/Global.asax90
-rw-r--r--webcompare/status.aspx18
3 files changed, 65 insertions, 47 deletions
diff --git a/webcompare/ChangeLog b/webcompare/ChangeLog
index c3b0c395..3fb6d768 100644
--- a/webcompare/ChangeLog
+++ b/webcompare/ChangeLog
@@ -1,3 +1,7 @@
+2008-12-18 Miguel de Icaza <miguel@novell.com>
+
+ * Global.asax: Trigger an update if the files change on disk.
+
2008-12-18 Jb Evain <jbevain@novell.com>
* status.aspx: adjust to changes in the public fields names for
diff --git a/webcompare/Global.asax b/webcompare/Global.asax
index 50e07274..0cdc1969 100644
--- a/webcompare/Global.asax
+++ b/webcompare/Global.asax
@@ -8,7 +8,17 @@
<script runat="server" language="c#" >
public class CompareParameters {
- public CompareParameters (NameValueCollection nvc)
+ static Dictionary<CompareParameters,CompareContext> compare_cache = new Dictionary<CompareParameters,CompareContext> ();
+ static Dictionary<CompareParameters,DateTime> timestamp = new Dictionary<CompareParameters,DateTime> ();
+
+ static public bool InCache (CompareParameters cp)
+ {
+ lock (compare_cache){
+ return compare_cache.ContainsKey (cp);
+ }
+ }
+
+ public CompareParameters (NameValueCollection nvc)
{
Assembly = nvc ["assembly"] ?? "mscorlib";
InfoDir = nvc ["reference"] ?? "3.5";
@@ -68,47 +78,63 @@ public class CompareParameters {
}
- public CompareContext MakeCompareContext ()
+ public CompareContext GetCompareContext ()
{
- string info_file = Path.Combine (HttpRuntime.AppDomainAppPath, Path.Combine (Path.Combine ("masterinfos", InfoDir), Assembly) + ".xml");
- string dll_file = Path.Combine (HttpRuntime.AppDomainAppPath, Path.Combine (BinDir, Assembly) + ".dll");
+ CompareContext cc;
- using (var sw = File.AppendText ("/tmp/mylog")){
- sw.WriteLine ("{2} Comparing {0} and {1}", info_file, dll_file, DateTime.Now);
- sw.Flush ();
-
- Console.WriteLine ("Comparing {0} and {1}", info_file, dll_file);
- if (!File.Exists (info_file))
- throw new Exception (String.Format ("File {0} does not exist", info_file));
- if (!File.Exists (dll_file))
- throw new Exception (String.Format ("File {0} does not exist", dll_file));
-
- CompareContext cc = new CompareContext (
- () => new MasterAssembly (info_file),
- () => new CecilAssembly (dll_file));
- cc.ProgressChanged += delegate (object sender, CompareProgressChangedEventArgs a){
- sw.WriteLine (a.Message);
-sw.Flush ();
- };
- ManualResetEvent r = new ManualResetEvent (false);
- cc.Finished += delegate { r.Set (); };
- Console.WriteLine ("Starting Compare");
- cc.Compare ();
- r.WaitOne ();
- cc.Comparison.PropagateCounts ();
-
-
- sw.Flush ();
+ lock (compare_cache){
+ DateTime stamp = new FileInfo (DllFile).LastWriteTimeUtc;
+ if (!compare_cache.TryGetValue (this, out cc) || timestamp [this] != stamp){
+ cc = MakeCompareContext ();
+ compare_cache [this] = cc;
+ timestamp [this] = stamp;
+ }
+ }
return cc;
+ }
+ string DllFile {
+ get {
+ return Path.Combine (HttpRuntime.AppDomainAppPath, Path.Combine (BinDir, Assembly) + ".dll");
}
+ }
+
+ CompareContext MakeCompareContext ()
+ {
+ string info_file = Path.Combine (HttpRuntime.AppDomainAppPath, Path.Combine (Path.Combine ("masterinfos", InfoDir), Assembly) + ".xml");
+ string dll_file = DllFile;
+ using (var sw = File.AppendText ("/tmp/mylog")){
+ sw.WriteLine ("{2} Comparing {0} and {1}", info_file, dll_file, DateTime.Now);
+ sw.Flush ();
+
+ if (!File.Exists (info_file))
+ throw new Exception (String.Format ("File {0} does not exist", info_file));
+ if (!File.Exists (dll_file))
+ throw new Exception (String.Format ("File {0} does not exist", dll_file));
+
+ CompareContext cc = new CompareContext (
+ () => new MasterAssembly (info_file),
+ () => new CecilAssembly (dll_file));
+
+ cc.ProgressChanged += delegate (object sender, CompareProgressChangedEventArgs a){
+ sw.WriteLine (a.Message);
+ sw.Flush ();
+ };
+ ManualResetEvent r = new ManualResetEvent (false);
+ cc.Finished += delegate { r.Set (); };
+ cc.Compare ();
+ r.WaitOne ();
+ cc.Comparison.PropagateCounts ();
+
+ sw.Flush ();
+
+ return cc;
+ }
}
}
-public static Dictionary<CompareParameters,CompareContext> CompareCache = new Dictionary<CompareParameters,CompareContext> ();
-
void Application_Start ()
{
}
diff --git a/webcompare/status.aspx b/webcompare/status.aspx
index d3ee097d..65d10442 100644
--- a/webcompare/status.aspx
+++ b/webcompare/status.aspx
@@ -103,18 +103,6 @@ static string GetStatus (ComparisonNode n)
return n.Name;
}
-CompareContext GetCompareContext (global_asax.CompareParameters cp)
-{
- CompareContext cc;
- if (!global_asax.CompareCache.TryGetValue (cp, out cc)){
- cc = cp.MakeCompareContext ();
- var copy = new Dictionary<global_asax.CompareParameters,CompareContext> (global_asax.CompareCache);
- copy [cp] = cc;
- global_asax.CompareCache = copy;
- }
- return cc;
-}
-
public void ShowPleaseWait ()
{
waitdiv.Visible = true;
@@ -129,12 +117,12 @@ public void ShowPleaseWait ()
public void Page_Load ()
{
var cp = new global_asax.CompareParameters (Page.Request.QueryString);
- if (!global_asax.CompareCache.ContainsKey (cp) && !IsPostBack){
+ if (!global_asax.CompareParameters.InCache (cp) && !IsPostBack){
ShowPleaseWait ();
return;
}
- compare_context = GetCompareContext (cp);
+ compare_context = cp.GetCompareContext ();
var n = compare_context.Comparison;
waitdiv.Visible = false;
@@ -223,7 +211,7 @@ ComparisonNode ComparisonNodeFromTreeNode (TreeNode tn)
if (tn.Parent == null){
// This is needed because the tree loads chunks without calling Page_Load
var cp = new global_asax.CompareParameters (Page.Request.QueryString);
- compare_context = GetCompareContext (cp);
+ compare_context = cp.GetCompareContext ();
return compare_context.Comparison;
}