コード例 #1
0
        public async Task Able_to_load_json_resources()
        {
            var value = await _contentSet.GetAsJson <JsonStruct>("Content")
                        .ConfigureAwait(false);

            value.ShouldNotBeNull();
        }
コード例 #2
0
        public static IEnumerable <T> GetJsonAsList <T>(this IContentSet contentSet, string name,
                                                        Func <T, bool>?predicate = null, JsonSerializerOptions?serializerOptions = null)
        {
            IEnumerable <T> value = contentSet.GetAsJson <IEnumerable <T> >(name, serializerOptions);

            if (predicate != null)
            {
                value = value.Where(predicate);
            }
            return(value);
        }
コード例 #3
0
        private static async Task <T> GetJsonAsListEntryInternal <T>(this IContentSet contentSet,
                                                                     string name,
                                                                     Func <T, bool> predicate,
                                                                     JsonSerializerOptions?serializerOptions = null)
        {
            IEnumerable <T> collection = await contentSet.GetAsJson <IEnumerable <T> >(name, serializerOptions)
                                         .ConfigureAwait(false);

            T result = collection.FirstOrDefault(predicate);

            return(result);
        }
コード例 #4
0
        public static T GetJsonAsListEntry <T>(this IContentSet contentSet,
                                               string name,
                                               Func <T, bool> predicate,
                                               JsonSerializerOptions?serializerOptions = null)
        {
            if (predicate is null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            IEnumerable <T> collection = contentSet.GetAsJson <IEnumerable <T> >(name, serializerOptions);
            T result = collection.FirstOrDefault(predicate);

            return(result);
        }