Exemplo n.º 1
0
 public T value()
 {
     Bomb.unless(isAlive(), () => "tried to access GC'd value of a weakReference");
     return((T)reference.Target);
 }
Exemplo n.º 2
0
 public static T penultimate <T>(IList <T> ts)
 {
     Bomb.unless(ts.Count >= 2, () => "no penultimate in " + toShortString(ts));
     return(ts[ts.Count - 2]);
 }
Exemplo n.º 3
0
 public static T the <T>(IList <T> ts)
 {
     Bomb.unless(ts.Count == 1, () => "ts does not have exactly 1 element.  has: " + ts.Count + " elements.\n" + toShortString(ts));
     return(ts[0]);
 }
Exemplo n.º 4
0
 static void requireNonEmpty <T>(IList <T> ts)
 {
     Bomb.when(Bomb.ifNull(ts, () => "null ts!").Count < 1, () => "empty list passed to requireNonEmpty");
 }
Exemplo n.º 5
0
 long bytesUsed()
 {
     Bomb.when(started, () => "eek! in the middle of an operation");
     return(totalMemoryUsed);
 }
Exemplo n.º 6
0
 public static long bytesUsed(string s)
 {
     Bomb.unless(memory, () => "can't ask for bytes used, not recording memory data.");
     return(get(s).bytesUsed());
 }