Пример #1
0
        // Resolve the type we are casting to
        private static Type GetDestType(string[] destTypeParts, IServiceProvider services)
        {
            ExpressionContext context = services.GetService(typeof(ExpressionContext)) as ExpressionContext;

            Type t = null;

            // Try to find a builtin type with the name
            if (destTypeParts.Length == 1)
            {
                t = ExpressionImports.GetBuiltinType(destTypeParts[0]);
            }

            if ((t != null))
            {
                return(t);
            }

            // Try to find the type in an import
            t = context.Imports.FindType(destTypeParts);

            if ((t != null))
            {
                return(t);
            }

            return(null);
        }