Пример #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);
        }
Пример #2
0
        internal ExpressionImports Clone()
        {
            ExpressionImports copy = new ExpressionImports();

            copy.MyRootImport  = MyRootImport.Clone() as NamespaceImport;
            copy.MyOwnerImport = MyOwnerImport;

            return(copy);
        }
        public ICollection <string> GetIdentifiers(ExpressionContext context)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
            ExpressionImports           ei   = context.Imports;

            foreach (string identifier in MyIdentifiers.Values)
            {
                // Skip names registered as namespaces
                if (ei.HasNamespace(identifier) == true)
                {
                    continue;
                }
                else if (context.Variables.ContainsKey(identifier) == true)
                {
                    // Identifier is a variable
                    continue;
                }

                // Get only the unique values
                dict[identifier] = null;
            }

            return(dict.Keys);
        }