Exemplo n.º 1
0
 // ReSharper disable UnusedMember.Local
 private void ChildFlushAndEvictDeletedObjectGeneric <TK, TP>(object objectToDelete)
 // ReSharper restore UnusedMember.Local
     where TK : RepositorySuperBase
     where TP : IUnitOfWork
 {
     using (var ctx = UnitOfWorkContextManager <TP> .Get())
     {
         var repository = Activator.CreateInstance(typeof(TK), new object[] { ctx.UnitOfWork }) as TK;
         if (repository == null)
         {
             return;
         }
         repository.ForceRemoveChildObject(objectToDelete);
         ctx.Complete();
     }
 }
Exemplo n.º 2
0
 private static UnitOfWorkContextManager <T> Get(string label, bool createTransaction)
 {
     lock (_lock)
     {
         var contextId = GetContextId(label);
         UnitOfWorkContextManager <T> mgr;
         if (ApplicationContext.LocalContext.Contains(contextId))
         {
             mgr = (UnitOfWorkContextManager <T>)(ApplicationContext.LocalContext[contextId]);
         }
         else
         {
             mgr = new UnitOfWorkContextManager <T>(label, createTransaction);
             ApplicationContext.LocalContext[contextId] = mgr;
         }
         mgr.AddRef();
         return(mgr);
     }
 }