示例#1
0
 public T value()
 {
     Bomb.unless(isAlive(), () => "tried to access GC'd value of a weakReference");
     return((T)reference.Target);
 }
示例#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]);
 }
示例#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]);
 }
示例#4
0
 static void requireNonEmpty <T>(IList <T> ts)
 {
     Bomb.when(Bomb.ifNull(ts, () => "null ts!").Count < 1, () => "empty list passed to requireNonEmpty");
 }
示例#5
0
 long bytesUsed()
 {
     Bomb.when(started, () => "eek! in the middle of an operation");
     return(totalMemoryUsed);
 }
示例#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());
 }