Share via


2009 Advent Calendar December 14th

But if we're using generics; why not do it for the lock too:

    1:      public class ImportantProvider<T,L> where T : ImportantInterface, new() where L : Lock,new()
   2:      {
   3:          private T _importantObject = new T();
   4:          private L _lock = new L();
   5:   
   6:          public Transaction Transaction
   7:          {
   8:              get
   9:              {
  10:                  return new Transaction(_importantObject, _lock);
  11:              }
  12:          }
  13:      }

But that leads to test code with static fields for verification. And I didn't like that before either... So it is a good idea to back that change out event though the ImportantProvider looks very neat with it IMHO.