Ejemplo n.º 1
0
        public static async ValueTask <IEntryState <TId, TData> > GetEntryAsync <TId, TData>(this IEntryStateStorage <TId, TData> entryStorage,
                                                                                             IEntryState <TId, TData> comparand,
                                                                                             CancellationToken cancellation = default)
            where TData : class
        {
            if (entryStorage == null)
            {
                throw new ArgumentNullException(nameof(entryStorage));
            }
            if (comparand == null)
            {
                throw new ArgumentNullException(nameof(comparand));
            }

            var entries = await entryStorage.GetEntriesAsync(DataPropertyHelper.BuildPredicate(comparand), cancellation);

            return(entries.FirstOrDefault());
        }
Ejemplo n.º 2
0
        public static async ValueTask <IEntryState <TId, TData> > GetEntryAsync <TId, TData>(this IEntryStateStorage <TId, TData> entryStorage,
                                                                                             Expression <Func <IEntryState <TId, TData>, bool> > predicate,
                                                                                             CancellationToken cancellation = default)
            where TData : class
        {
            if (entryStorage == null)
            {
                throw new ArgumentNullException(nameof(entryStorage));
            }
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            var entries = await entryStorage.GetEntriesAsync(predicate, cancellation);

            return(entries.FirstOrDefault());
        }