Ejemplo n.º 1
0
 public Impl()
 {
     Entities             = new Dictionary <Type, StructuralDataType>();
     Enumerations         = new Dictionary <Type, PrimitiveDataType>();
     _findEntityDataTypes = new FindEntityDataTypes(this);
     _derivationVisitor   = new TypeSlimDerivationVisitor();
 }
        /// <summary>
        /// Visits the expression to rewrite types.
        /// </summary>
        /// <param name="node">Expression to visit.</param>
        /// <returns>Expression with types rewritten.</returns>
        public override Expression Visit(Expression node)
        {
#if !USE_SLIM
            //
            // NB: In .NET Core, DynamicExpression is an extension node, causing reduction upon calling Visit. We don't want this reduction
            //     to take place, because it introduces an opaque Constant node containing a call site object for which we can't substitute
            //     types. As such, we need to type check here and dispatch ourselves.
            //

            if (node is DynamicExpression d)
            {
                return(VisitDynamic(d));
            }
#endif

            var res = base.Visit(node);

            if (res != null)
            {
#if USE_SLIM
                var derivationVisitor = new TypeSlimDerivationVisitor();
                var resType           = derivationVisitor.Visit(res);
                var newType           = resType != null?VisitType(resType) : null;
#else
                var newType = VisitType(res.Type);
                var resType = res.Type;
#endif

                if (newType != resType)
                {
                    res = ConvertExpression(node, res, newType);
                }
            }

            return(res);
        }
Ejemplo n.º 3
0
        public static TypeSlim GetTypeSlim(this ExpressionSlim e)
        {
            var t = new TypeSlimDerivationVisitor().Visit(e);

            return(t);
        }