public virtual void Insert(PythonNode inserted, int index) { if (InsertStrategy == null) { throw new TransformationNotApplicableExpection(); } Children = InsertStrategy.Insert(this, inserted, index); }
public virtual T Save(T entity) { return(On <T> .Value(entity) .When(entity.HasId()) .Then(() => { UpdateStrategy.Save(entity); }) .Else() .Then(() => { InsertStrategy.Save(entity); }) .Result()); }
public static IObservable <Unit> FromCacheObservable <TObject, TKey>(this ISourceCache <TObject, TKey> cache, string cacheKey, IEqualityComparer <TObject> comparer, InsertStrategy strategy = InsertStrategy.EditDiff) { return(Observable.Create <Unit>(observer => { return BlobCache.LocalMachine.GetObject <List <TObject> >(cacheKey) .Catch(Observable.Return(new List <TObject>())) .Do(objects => { if (strategy == InsertStrategy.EditDiff) { cache.EditDiff(objects, comparer); } else { cache.AddOrUpdate(objects); } observer.OnNext(Unit.Default); observer.OnCompleted(); }) .Subscribe(); })); }
public static async Task FromCache <TObject, TKey>(this ISourceCache <TObject, TKey> cache, string cacheKey, IEqualityComparer <TObject> comparer, InsertStrategy strategy = InsertStrategy.EditDiff) { var list = await BlobCache.LocalMachine.GetObject <List <TObject> >(cacheKey) .Catch(Observable.Return(new List <TObject>())); if (strategy == InsertStrategy.EditDiff) { cache.EditDiff(list, comparer); } else { cache.AddOrUpdate(list); } }