示例#1
0
        /// <summary>
        /// Generates variations of the search text based on known namespaces.
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private IEnumerable <string> AddScopedNamespaces(string text)
        {
            yield return(text);

            foreach (string ns in ImportedNamespaces.Select(ns => ns + "." + text))
            {
                yield return(ns);
            }
        }
示例#2
0
        public Type[] MatchTypes(string name, int gen)
        {
            if (gen > 0)
            {
                name += "`" + gen;
            }

            if (TypesUtil.PRIMITIVE_TYPES.ContainsKey(name))
            {
                return new[] { TypesUtil.PRIMITIVE_TYPES[name] }
            }
            ;
            var t1 = KnownTypes.Where(i => i.FullName == name).ToArray();

            if (t1.Length == 1)
            {
                return(t1);
            }
            if (t1.Length > 1)
            {
                throw new Exception("pink sparrow");
            }

            var fullNames = ImportedNamespaces.Select(i => i.Name + "." + name).Distinct().ToList();

            if (!string.IsNullOrEmpty(_currentNamespace))
            {
                fullNames.Add(_currentNamespace + "." + name);
            }
            var types = (from fullname in fullNames.Distinct()
                         join type in KnownTypes
                         on fullname equals type.FullName
                         select type).ToArray();

            return(types);
        }