コード例 #1
0
        private void ApplyEvents(IEnumerable <IEvent <TKey, TAggregate> > events, Action <IEnumerable <TAggregate> > apply)
        {
            var aggregates = new List <TAggregate>();

            foreach (var @event in events)
            {
                var aggregate = _sourceCache.Lookup(@event.EventStreamId);

                if (!aggregate.HasValue)
                {
                    var @new = new TAggregate
                    {
                        Id            = @event.EventStreamId,
                        DoStoreEvents = _configuration.DoStoreEvents
                    };

                    @new.Apply(@event);

                    aggregates.Add(@new);
                }
                else
                {
                    aggregate.Value.Apply(@event);

                    aggregates.Add(aggregate.Value);
                }
            }

            apply(aggregates);
        }
コード例 #2
0
        public void Handle(ApplicationMsgs.RoleCreated @event)
        {
            var policy = _policies.Lookup(@event.PolicyId);

            if (policy.HasValue && !_roles.ContainsKey(@event.RoleId))
            {
                var role = new RoleDTO(@event);
                _roles.Add(@event.RoleId, role);
                policy.Value.Roles.AddOrUpdate(role);
            }
        }
コード例 #3
0
        public void AddToFavorites(int cakeId, CakeDto cake)
        {
            var hasCake = _favouriteCakes.Lookup(cakeId);

            if (!hasCake.HasValue)
            {
                _favouriteCakes.AddOrUpdate(cake);
            }
        }
コード例 #4
0
        public SearchInfo Get(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentException("message", nameof(key));
            }

            var optional = _cache.Lookup(key);

            return(optional.HasValue ? optional.Value : null);
        }
コード例 #5
0
        /// <inheritdoc/>
        public GeofenceRegion Get(string id)
        {
            var optional = _store.Lookup(id);

            if (optional.HasValue)
            {
                return(optional.Value);
            }

            return(GeofenceRegion.Default);
        }
コード例 #6
0
        public Session GetSession(string id)
        {
            lock (_sessions) {
                var session = _sessions.Lookup(id).ValueOrDefault();
                if (session == null)
                {
                    _sessions.AddOrUpdate(session = new Session(id));
                }

                return(session);
            }
        }
コード例 #7
0
ファイル: AppModel.cs プロジェクト: Totopolis/Kamban
        private BoxViewModel GetBox(string uri)
        {
            var o = BoxesCache.Lookup(uri);

            return(o.ValueOr(() =>
            {
                var box = shell.Container.Resolve <BoxViewModel>();
                box.Uri = uri;
                BoxesCache.AddOrUpdate(box);
                return box;
            }));
        }
コード例 #8
0
        public TViewModel?TryGet(string key)
        {
            var viewModel = _sourceCache.Lookup(key);

            if (viewModel.HasValue)
            {
                return(viewModel.Value);
            }
            else
            {
                return(null);
            }
        }
コード例 #9
0
        public static bool TryLookup <TValue, TKey>(this SourceCache <TValue, TKey> cache, TKey key,
                                                    [MaybeNullWhen(false)] out TValue value)
        {
            var option = cache.Lookup(key);

            if (option.HasValue)
            {
                value = option.Value;
                return(true);
            }

            value = default;
            return(false);
        }
コード例 #10
0
        private void ApplyEvent(IEvent <TKey, TAggregate> @event)
        {
            var aggregate = _sourceCache.Lookup(@event.EventStreamId);

            if (!aggregate.HasValue)
            {
                var @new = new TAggregate
                {
                    Id = @event.EventStreamId
                };

                @new.Apply(@event);

                _sourceCache.AddOrUpdate(@new);
            }
            else
            {
                aggregate.Value.Apply(@event);

                _sourceCache.AddOrUpdate(aggregate.Value);
            }
        }
コード例 #11
0
        private SteamConnectService()
        {
            mCurrent = this;

            SteamApps    = new SourceCache <SteamApp, uint>(t => t.AppId);
            DownloadApps = new SourceCache <SteamApp, uint>(t => t.AppId);

            DownloadApps
            .Connect()
            .Subscribe(_ =>
            {
                foreach (var app in DownloadApps.Items)
                {
                    var optional = SteamApps.Lookup(app.AppId);
                    if (optional.HasValue)
                    {
                        var value             = optional.Value;
                        value.InstalledDir    = app.InstalledDir;
                        value.State           = app.State;
                        value.SizeOnDisk      = app.SizeOnDisk;
                        value.LastOwner       = app.LastOwner;
                        value.BytesToDownload = app.BytesToDownload;
                        value.BytesDownloaded = app.BytesDownloaded;
                        value.BytesToStage    = app.BytesToStage;
                        value.BytesStaged     = app.BytesStaged;
                        value.LastUpdated     = app.LastUpdated;
                    }
                }
            });

            this.WhenValueChanged(x => x.IsWatchSteamDownloading, false)
            .Subscribe(x =>
            {
                if (x)
                {
                    InitializeDownloadGameList();
                    if (OperatingSystem2.IsLinux)
                    {
                        IPlatformService.Instance.TryGetSystemUserPassword();
                    }
                    SteamTool.StartWatchSteamDownloading(app =>
                    {
                        var optional = DownloadApps.Lookup(app.AppId);
                        if (!optional.HasValue)
                        {
                            DownloadApps.AddOrUpdate(app);
                        }
                        else
                        {
                            var current             = optional.Value;
                            current.InstalledDir    = app.InstalledDir;
                            current.State           = app.State;
                            current.SizeOnDisk      = app.SizeOnDisk;
                            current.LastOwner       = app.LastOwner;
                            current.BytesToDownload = app.BytesToDownload;
                            current.BytesDownloaded = app.BytesDownloaded;
                            current.BytesToStage    = app.BytesToStage;
                            current.BytesStaged     = app.BytesStaged;
                            current.LastUpdated     = app.LastUpdated;
                        }

                        if (WatchDownloadingSteamAppIds.Contains(app.AppId))
                        {
                            if (app.IsDownloading)
                            {
                                app.IsWatchDownloading = true;
                            }
                            else
                            {
                                WatchDownloadingSteamAppIds.Remove(app.AppId);
                                if (!WatchDownloadingSteamAppIds.Any())
                                {
                                    WatchDownloadingComplete();
                                }
                            }
                        }
                    }, appid =>
                    {
                        DownloadApps.RemoveKey(appid);
                    });
                }
                else
                {
                    SteamTool.StopWatchSteamDownloading();
                }
            });
        }
コード例 #12
0
ファイル: MainVM.cs プロジェクト: hutterm/WindowRestorer
 public Optional <ProcessWindow> LookupWindow(IntPtr handle) => _windows.Lookup(handle);
コード例 #13
0
        /// <inheritdoc/>
        public GeofenceRegion Get(string id)
        {
            var lookup = _sourceCache.Lookup(id);

            return(lookup.HasValue ? lookup.Value : GeofenceRegion.Default);
        }
コード例 #14
0
 public Optional <TValue> Lookup(TKey key)
 => _cache.Lookup(key);
コード例 #15
0
 public Optional <IFileReference> Lookup(int key)
 {
     return(_cache.Lookup(key.ToString()));
 }
コード例 #16
0
 public Optional <ExplicitConnection> Get(Guid id)
 {
     return(_connectionSoureCache.Lookup(id));
 }
コード例 #17
0
 /// <inheritdoc />
 public Optional <Device> Lookup(string key)
 => _controllers?.Lookup(key) ?? throw new ObjectDisposedException(nameof(Devices));