make forcing evaluation of lazyness explicit

This commit is contained in:
Chris Forbes
2011-03-07 19:53:39 +13:00
parent ae58da10bf
commit 7cf07f5765
2 changed files with 18 additions and 13 deletions

View File

@@ -10,9 +10,9 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Windows.Forms;
using System.Linq;
using System.IO; using System.IO;
using System.Linq;
using System.Windows.Forms;
using OpenRA.FileFormats; using OpenRA.FileFormats;
namespace OpenRA.Editor namespace OpenRA.Editor
@@ -47,10 +47,10 @@ namespace OpenRA.Editor
{ {
var map = new Map(path); var map = new Map(path);
// Touch the lazy bits to initialize them // Touch the lazy bits to initialize them
var foo = map.Actors.Value.Count; map.Actors.Force();
foo = map.Smudges.Value.Count; map.Smudges.Force();
var bar = map.MapResources.Value[0,0]; map.MapTiles.Force();
var baz = map.MapTiles.Value[0,0]; map.MapResources.Force();
map.Save(path); map.Save(path);
} }
} }

View File

@@ -37,6 +37,11 @@ namespace OpenRA.FileFormats
return value; return value;
} }
} }
public void Force()
{
var ignored = Value;
}
} }
public static class Lazy public static class Lazy