Example #1
0
        public static TContent ContentAs <TDocument, TContent>(this ILookupInResult <TDocument> result, Expression <Func <TDocument, TContent> > path)
        {
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            if (result == null)
            {
                ThrowHelper.ThrowArgumentNullException(nameof(result));
            }
            if (path == null)
            {
                ThrowHelper.ThrowArgumentNullException(nameof(path));
            }
            // ReSharper restore ConditionIsAlwaysTrueOrFalse

            var pathString = SubDocumentPathExpressionVisitor.GetPath(result, path);
            var index      = result.IndexOf(pathString);

            if (index < 0)
            {
                ThrowHelper.ThrowArgumentException(nameof(path), $"Path '{pathString}' is not found.");
            }

            return(result.ContentAs <TContent>(index));
        }
 public T?ContentAs <T>(int index) => _inner.ContentAs <T>(index);
Example #3
0
 public T ContentAs <T>() => _lookupInResult.ContentAs <T>(_specIndex);