Q:

C# - reason for declaring an instance of (not implementing) an interface

My boss, recently gave me some C# .NET code he wants me to incorporate in an  n-tiered MVC application I am building. He wants me to fill in the missing code. Here is a middle-tier class file (shown below)
 public class UnitOfWork : IUnitOfWork
 {
     private readonly JRES_Context _context;               

     public UnitOfWork(JRES_Context context)
     {
         _context = context;            

         table1_UOW = new table1Repository(_context);            

         table2_UOW = new table2Repository(_context);            

     }                    

     public Iinterface1 table1_UOW { get; private set; }

     public Iinterface2 table2_UOW { get; private set; }

     public int Complete()
     {
         return _context.SaveChanges();
     }

     public void Dispose()
     {
         _context.Dispose();
     }
 }

One things puzzles me: why are 2 previously-defined interfaces declared? Isn't the purpose of the interface to IMPLEMENT it (and thereby enforce behavior inside the object that implements it)? I wondered if there was another good purpose (the interfaces define some 'Get' methods used on the UI layer) - or maybe there is a better way to code this. 

A:

table1_UOW for example is a property with type Iinterface1, you do not need to implement that in order to work with that interface in this class.
Presumably they are implemented elsewhere in the solution, those properties need setting to an instance that implements the interface otherwise there will be an exception at runtime when accessing members on them, these properties could be set manually in the calling code, or using an IoC container.

