private static void ValidateSaveable <T>( Rule rule, T current, OperationType op, object context, ICollection <RuleResult> results) where T : ISaveable { var saveContext = (ZzaSaveContext)context; var dataProvider = saveContext.DataProvider; ICollection <string> emsg = new List <string>(); if (op.IsAdded()) { current.StoreId = saveContext.UserStoreId; emsg = current.CanAdd(emsg); results.AddErrors(current, rule, emsg); } else { emsg = (op.IsUpdated()) ? current.CanUpdate(emsg) : current.CanDelete(emsg); var existing = (ISaveable)dataProvider.GetExisting(current); emsg = ExistingEntityGuard(current, existing, saveContext.UserStoreId, emsg); results.AddErrors(current, rule, emsg); } }