//private readonly IRepositoryBulkReader BulkReader; //private readonly Lazy<World>[] LazyWorlds = new Lazy<World>[512]; public Context(IObjectFactory factory, IDatabaseQueryManager manager) { var scope = factory.CreateScope(null); scope.RegisterInterfaces(manager.StartQuery(false)); WorldRepository = scope.Resolve<IPersistableRepository<World>>(); FortuneRepository = scope.Resolve<IQueryableRepository<Fortune>>(); //BulkReader = scope.BulkRead(ChunkedMemoryStream.Static()); }
public ChangeBrushEventHandler( IQueryableRepository <Artist> artistRepository, IPersistableRepository <Brush> brushRepository) { this.artistRepository = artistRepository; this.brushRepository = brushRepository; }
public void RegisterRepository(IPersistableRepository repository) { if (!PersistableRepositories.Contains(repository)) { PersistableRepositories.Add(repository); } }
public KadaEvents( IPersistableRepository <Kada> kade, IPersistableRepository <SlikeKade> slikeKade) { this.Kade = kade; this.SlikeKade = slikeKade; }
/// <summary> /// Update changed aggregate root. /// Aggregate is modified in place. /// </summary> /// <typeparam name="TRoot">aggregate type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="data">changed aggregate</param> public static void Update <TRoot>(this IPersistableRepository <TRoot> repository, TRoot data) where TRoot : IAggregateRoot { Contract.Requires(repository != null); repository.Update(new[] { data }); }
public MouseActionEventHandler( IRepository <Brush> brushRepository, IPersistableRepository <Segment> segmentRepository) { this.brushRepository = brushRepository; this.segmentRepository = segmentRepository; }
/// <summary> /// Persist aggregate roots. Bulk persistance. /// Inserted aggregates will return new identifiers. /// Aggregate roots will be modified in place. /// For update aggregates, old aggregates will be loaded from change tracking or looked up using aggregate identifier. /// </summary> /// <typeparam name="TRoot">aggregate root type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="insert">new aggregates</param> /// <param name="update">collection of changed aggregates</param> /// <param name="delete">remove aggregates</param> /// <returns>created identifiers</returns> public static string[] Persist <TRoot>( this IPersistableRepository <TRoot> repository, IEnumerable <TRoot> insert, IEnumerable <TRoot> update, IEnumerable <TRoot> delete) where TRoot : IAggregateRoot { Contract.Requires(repository != null); if (insert != null && insert.Any() || update != null && update.Any() || delete != null && delete.Any()) { return (repository.Persist( insert, update != null ? (from u in update let ct = u as IChangeTracking <TRoot> select new KeyValuePair <TRoot, TRoot>(ct != null ? ct.GetOriginalValue() : default(TRoot), u)) .ToList() : null, delete)); } return(new string[0]); }
/// <summary> /// Insert aggregate root. /// Return new identifier. /// Aggregate is modified in place. /// </summary> /// <typeparam name="TRoot">aggregate type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="data">new aggregate</param> /// <returns>assigned identifier</returns> public static string Insert <TRoot>(this IPersistableRepository <TRoot> repository, TRoot data) where TRoot : IAggregateRoot { Contract.Requires(repository != null); Contract.Requires(data != null); return(repository.Insert(new[] { data })[0]); }
/// <summary> /// Update changed aggregate root. /// Aggregate is modified in place. /// </summary> /// <typeparam name="TRoot">aggregate type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="data">changed aggregate</param> public static void Update <TRoot>(this IPersistableRepository <TRoot> repository, TRoot data) where TRoot : IAggregateRoot { Contract.Requires(repository != null); var ct = data as IChangeTracking <TRoot>; repository.Persist(null, new[] { new KeyValuePair <TRoot, TRoot>(ct != null ? ct.GetOriginalValue() : default(TRoot), data) }, null); }
public static Task Update <T>(this IPersistableRepository <T> repository, T oldValue, T newValue) where T : class, IAggregateRoot { if (repository == null) { throw new ArgumentNullException("repository can't be null"); } return(repository.Persist(null, new[] { new KeyValuePair <T, T>(oldValue, newValue) }, null)); }
public static Task <string> Insert <T>(this IPersistableRepository <T> repository, T data) where T : class, IAggregateRoot { if (repository == null) { throw new ArgumentNullException("repository can't be null"); } return(repository.Insert(new[] { data }).ContinueWith(t => t.Result.First())); }
public static Task Delete <T>(this IPersistableRepository <T> repository, T data) where T : class, IAggregateRoot { if (repository == null) { throw new ArgumentNullException("repository can't be null"); } return(repository.Delete(new[] { data })); }
//private readonly IRepositoryBulkReader BulkReader; //private readonly Lazy<World>[] LazyWorlds = new Lazy<World>[512]; public Context(IObjectFactory factory, IDatabaseQueryManager manager) { var scope = factory.CreateScope(null); scope.RegisterInterfaces(manager.StartQuery(false)); WorldRepository = scope.Resolve <IPersistableRepository <World> >(); FortuneRepository = scope.Resolve <IQueryableRepository <Fortune> >(); //BulkReader = scope.BulkRead(ChunkedMemoryStream.Static()); }
/// <summary> /// Update changed aggregate root. /// Aggregate is modified in place. /// </summary> /// <typeparam name="TRoot">aggregate type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="oldValue">old aggregate instance</param> /// <param name="newValue">new aggregate instance</param> public static void Update <TRoot>(this IPersistableRepository <TRoot> repository, TRoot oldValue, TRoot newValue) where TRoot : IAggregateRoot { Contract.Requires(repository != null); Contract.Requires(oldValue != null); Contract.Requires(newValue != null); repository.Persist(null, new[] { new KeyValuePair <TRoot, TRoot>(oldValue, newValue) }, null); }
public static Task Update <T>(this IPersistableRepository <T> repository, IEnumerable <T> data) where T : class, IAggregateRoot { if (repository == null) { throw new ArgumentNullException("repository can't be null"); } return(repository.Persist(null, data, null)); }
/// <summary> /// Delete aggregate roots. /// </summary> /// <typeparam name="TRoot">aggregate type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="data">aggregates to delete</param> public static void Delete <TRoot>(this IPersistableRepository <TRoot> repository, IEnumerable <TRoot> data) where TRoot : IAggregateRoot { Contract.Requires(repository != null); if (data != null && data.Any()) { repository.Persist(null, null, data); } }
public Context(IServiceProvider service) { Stream = ChunkedMemoryStream.Static(); Writer = Stream.GetWriter(); var dqm = service.Resolve<IDatabaseQueryManager>(); var factory = service.Resolve<IObjectFactory>().CreateInnerFactory(); factory.RegisterInterfaces(dqm.StartQuery(false)); Repository = factory.Resolve<IPersistableRepository<World>>(); BulkReader = factory.BulkRead(ChunkedMemoryStream.Static()); }
/// <summary> /// Insert new aggregate roots. /// Aggregates are modified in place. /// </summary> /// <typeparam name="TRoot">aggregate type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="data">new aggregates</param> /// <returns>created indentifiers</returns> public static string[] Insert <TRoot>(this IPersistableRepository <TRoot> repository, IEnumerable <TRoot> data) where TRoot : IAggregateRoot { Contract.Requires(repository != null); if (data != null && data.Any()) { return(repository.Persist(data, null, null)); } return(new string[0]); }
public Context(IServiceProvider service) { Stream = ChunkedMemoryStream.Static(); Writer = Stream.GetWriter(); var dqm = service.Resolve <IDatabaseQueryManager>(); var factory = service.Resolve <IObjectFactory>().CreateInnerFactory(); factory.RegisterInterfaces(dqm.StartQuery(false)); Repository = factory.Resolve <IPersistableRepository <World> >(); BulkReader = factory.BulkRead(ChunkedMemoryStream.Static()); }
/// <summary> /// Delete aggregate root defined by provided identifier. /// Deleted aggregate is returned. /// </summary> /// <typeparam name="TRoot">aggregate type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="uri">aggregate identifier</param> /// <returns>deleted aggregate root</returns> public static TRoot Delete <TRoot>(this IPersistableRepository <TRoot> repository, string uri) where TRoot : IAggregateRoot { Contract.Requires(repository != null); Contract.Requires(uri != null); var oldValue = repository.Find(uri); if (oldValue == null) { throw new ArgumentException(string.Format("Can't find {0} with URI: {1}", typeof(TRoot).FullName, uri)); } repository.Delete(new[] { oldValue }); return(oldValue); }
public static Task <string[]> Persist <T>( this IPersistableRepository <T> repository, IEnumerable <T> insert, IEnumerable <T> update, IEnumerable <T> delete) where T : class, IAggregateRoot { if (repository == null) { throw new ArgumentNullException("repository can't be null"); } return (repository.Persist( insert, update != null ? update.Select(it => new KeyValuePair <T, T>(default(T), it)) : null, delete)); }
public static Task Delete <T>(this IPersistableRepository <T> repository, string uri) where T : class, IAggregateRoot { if (repository == null) { throw new ArgumentNullException("repository can't be null"); } var oldValue = repository.Find(uri); return(oldValue.ContinueWith(t => { if (t.Result == null) { throw new ArgumentException(string.Format("Can't find {0} with URI: {1}", typeof(T).FullName, uri)); } repository.Delete(new[] { t.Result }).Wait(); })); }
public CrudController( IPersistableRepository <TRoot> repository, ICollectionView collectionView, Func <TRoot> getCurrent, Action <TRoot> setCurrent, Action <bool> stateChanged) { this.Repository = repository; this.CollectionView = collectionView; this.GetCurrent = getCurrent; this.SetCurrent = setCurrent; this.StateChanged = stateChanged; Bindings.Add(new CommandBinding(GlobalCommands.New, CreateNew, CanCreateNew)); Bindings.Add(new CommandBinding(GlobalCommands.Edit, EditCurrent, CanEditOrDeleteCurrent)); Bindings.Add(new CommandBinding(GlobalCommands.Delete, DeleteCurrent, CanEditOrDeleteCurrent)); Bindings.Add(new CommandBinding(GlobalCommands.Save, SaveChanges, IsInEdit)); Bindings.Add(new CommandBinding(GlobalCommands.Cancel, CancelChanges, IsInEdit)); App.Current.MainWindow.CommandBindings.AddRange(Bindings); }
//TODO: remove!? /// <summary> /// Change aggregate root defined by identifier using provided action. /// </summary> /// <typeparam name="TRoot">aggregate type</typeparam> /// <param name="repository">persistable repository</param> /// <param name="uri">aggregate identifier</param> /// <param name="update">change method</param> /// <returns>found and changed aggregate</returns> public static TRoot Update <TRoot>(this IPersistableRepository <TRoot> repository, string uri, Action <TRoot> update) where TRoot : IAggregateRoot { Contract.Requires(repository != null); Contract.Requires(uri != null); Contract.Requires(update != null); var found = repository.Find(uri); if (found == null) { throw new ArgumentException(string.Format("Can't find {0} with URI: {1}", typeof(TRoot).FullName, uri)); } var ct = found as IChangeTracking <TRoot>; var original = ct != null ? ct.GetOriginalValue() : found is ICloneable ? (TRoot)((ICloneable)found).Clone() : default(TRoot); update(found); repository.Persist(null, new[] { new KeyValuePair <TRoot, TRoot>(original, found) }, null); return(found); }
public SigurnostEvents(IPersistableRepository <Korisnik> korisnici) { this.Korisnici = korisnici; }
public ModerirajService(IServiceLocator locator) { this.Locator = locator; this.Kade = locator.Resolve <IPersistableRepository <Kada> >(); this.KadaIzvorPodataka = locator.Resolve <IQueryableRepository <KadaIzvorPodataka> >(); }
public RegisterArtist(IPersistableRepository <Artist> artistRepository) { this.artistRepository = artistRepository; }
public static void Insert <T>(this IPersistableRepository <T> repository, T item) where T : IAggregateRoot { repository.Save(new[] { item }, null, null); }
public MarkDoneHandler(IPersistableRepository <Task> repository) { this.Repository = repository; }
public static void Delete <T>(this IPersistableRepository <T> repository, T item) where T : IAggregateRoot { repository.Save(null, null, new[] { item }); }