Ejemplo n.º 1
0
        public UserDataSource(ISingleObjectStorage <IDatabaseUser> storage, ITimeService timeService)
            : base(storage, null)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));

            this.timeService = timeService;
        }
Ejemplo n.º 2
0
        public UserDataSource(ISingleObjectStorage <IDatabaseUser> storage, IUserApi userApi)
        {
            Ensure.Argument.IsNotNull(storage, nameof(storage));
            Ensure.Argument.IsNotNull(userApi, nameof(userApi));

            this.storage = storage;
            this.userApi = userApi;
        }
Ejemplo n.º 3
0
        public PreferencesDataSource(ISingleObjectStorage <IDatabasePreferences> storage)
        {
            Ensure.Argument.IsNotNull(storage, nameof(storage));

            this.storage = storage;

            currentPreferencesSubject = new ReplaySubject <IDatabasePreferences>(1);

            Current = currentPreferencesSubject.AsObservable();
            Get().Do(currentPreferencesSubject.OnNext);
        }
Ejemplo n.º 4
0
        public PreferencesDataSource(ISingleObjectStorage <IDatabasePreferences> storage)
        {
            Ensure.Argument.IsNotNull(storage, nameof(storage));

            this.storage = storage;

            currentPreferencesSubject = new BehaviorSubject <IDatabasePreferences>(Preferences.DefaultPreferences);

            Current = currentPreferencesSubject.AsObservable();

            // right after login/signup the database does not contain the preferences and retreiving
            // it will fail we can ignore this error because it will be immediately fetched and until
            // then the default preferences will be used
            initializationDisposable = Get().Subscribe(currentPreferencesSubject.OnNext, (Exception _) => { });
        }
Ejemplo n.º 5
0
        protected SingletonDataSource(ISingleObjectStorage <TDatabase> storage, TThreadsafe defaultCurrentValue)
            : base(storage)
        {
            Ensure.Argument.IsNotNull(storage, nameof(storage));

            this.storage = storage;

            currentSubject = new Subject <TThreadsafe>();

            var initialValueObservable = storage.Single()
                                         .Select(Convert)
                                         .Catch((Exception _) => Observable.Return(defaultCurrentValue))
                                         .FirstAsync();

            var connectableCurrent = initialValueObservable.Concat(currentSubject).Replay(1);

            connectableCurrent.Connect();

            Current = connectableCurrent;
        }
Ejemplo n.º 6
0
 public PreferencesDataSource(ISingleObjectStorage <IDatabasePreferences> storage)
     : base(storage, Preferences.DefaultPreferences)
 {
 }
Ejemplo n.º 7
0
 public UserDataSource(ISingleObjectStorage <IDatabaseUser> storage)
     : base(storage, null)
 {
 }
 public TestSingletonSource(ISingleObjectStorage <IDatabaseTestModel> storage, IThreadSafeTestModel defaultCurrentValue) : base(storage, defaultCurrentValue)
 {
 }
Ejemplo n.º 9
0
        public UserDataSource(ISingleObjectStorage <IDatabaseUser> storage)
        {
            Ensure.Argument.IsNotNull(storage, nameof(storage));

            this.storage = storage;
        }