コード例 #1
0
            protected override ConstantExpression VisitConstant(ConstantExpression expression)
            {
                var queryable = AsQueryableOrNull(expression.Value);

                if (!(queryable is null))
                {
                    var typeInfo = _typeInfoProvider.Get(queryable.ElementType);
                    var queryableResourceDescriptor = new QueryableResourceDescriptor(typeInfo);
                    return(new ConstantExpression(queryableResourceDescriptor));
                }

                var constantQueryArgument = expression.Value as ConstantQueryArgument;

                if (!(constantQueryArgument is null))
                {
                    var newConstantQueryArgument = new ConstantQueryArgument(constantQueryArgument);
                    var properties = newConstantQueryArgument.Properties ?? Enumerable.Empty <Property>();
                    foreach (var property in properties)
                    {
                        var value = AsQueryableOrNull(property.Value);
                        if (!(value is null))
                        {
                            var typeInfo = _typeInfoProvider.Get(value.ElementType);
                            var queryableResourceDescriptor = new QueryableResourceDescriptor(typeInfo);
                            property.Value = queryableResourceDescriptor;
                        }
                    }

                    return(new ConstantExpression(newConstantQueryArgument, expression.Type));
                }

                return(base.VisitConstant(expression));
            }
コード例 #2
0
        public virtual TypeInfo Get(Type type, bool?includePropertyInfosOverride = null, bool?setMemberDeclaringTypesOverride = null)
        {
            if (type is null)
            {
                return(null);
            }

            if (_referenceTracker.TryGetValue(type, out TypeInfo typeInfo))
            {
                return(typeInfo);
            }

            if (!(_parent is null))
            {
                return(_parent.Get(type, includePropertyInfosOverride, setMemberDeclaringTypesOverride));
            }

            var context = this;

            if ((includePropertyInfosOverride.HasValue && includePropertyInfosOverride != IncludePropertyInfos) ||
                (setMemberDeclaringTypesOverride.HasValue && setMemberDeclaringTypesOverride != SetMemberDeclaringTypes))
            {
                context = new TypeInfoProvider(
                    includePropertyInfosOverride ?? IncludePropertyInfos,
                    setMemberDeclaringTypesOverride ?? SetMemberDeclaringTypes,
                    this);
            }

            return(new TypeInfo(type, context));
        }
コード例 #3
0
 public static TypeInfo GetTypeInfo(this ITypeInfoProvider typeInfoProvider, Type type)
 => typeInfoProvider?.Get(type);