Esempio n. 1
0
        private bool resolveTypeFromCache(IOutputWriter cache, Dictionary <string, string[]> usingsMap, Dictionary <string, UsingAlias[]> usingAliasesMap, PartialType type)
        {
            // Cannot do this since expressions might start with System.
            //if (type.Type.StartsWith("System."))
            //    continue;
            var typeToMatch  = type.Type.Replace("[]", "");
            var matchingType = _expression.Resolve(type, typeToMatch);

            if (matchingType == null)
            {
                matchingType = cache.VariableTypeFromSignature(type.Parent + "." + type.Type);
            }
            var usings = getUsings(usingsMap, type);

            if (matchingType == null)
            {
                matchingType = matchToAliases(cache, type.File.File, typeToMatch, usingAliasesMap);
            }
            if (matchingType == null)
            {
                matchingType = getMatchingType(cache, typeToMatch, usings);
                if (matchingType == null)
                {
                    matchingType = cache.FirstMatchingTypeFromName(typeToMatch);
                }
            }
            if (matchingType != null)
            {
                type.Resolve(type.Type.Replace(typeToMatch, matchingType));
            }
            return(matchingType != null);
        }
Esempio n. 2
0
        private string matchToAliases(IOutputWriter cache, string file, string type, Dictionary <string, UsingAlias[]> usingAliasesMap)
        {
            UsingAlias[] aliases;
            if (!usingAliasesMap.TryGetValue(file, out aliases))
            {
                return(null);
            }
            var match = aliases.FirstOrDefault(x => x.Name == type);

            if (match != null)
            {
                if (cache.ContainsType(match.Parent))
                {
                    return(match.Parent);
                }
                var firstMatch = cache.FirstMatchingTypeFromName(match.Parent);
                if (firstMatch != null)
                {
                    return(firstMatch);
                }
                return(match.Parent);
            }
            return(null);
        }
Esempio n. 3
0
 private bool resolveTypeFromCache(IOutputWriter cache, Dictionary<string, string[]> usingsMap, Dictionary<string, UsingAlias[]> usingAliasesMap, PartialType type)
 {
     // Cannot do this since expressions might start with System.
     //if (type.Type.StartsWith("System."))
     //    continue;
     var typeToMatch = type.Type.Replace("[]", "");
     var matchingType = _expression.Resolve(type, typeToMatch);
     if (matchingType == null)
         matchingType = cache.VariableTypeFromSignature(type.Parent + "." + type.Type);
     var usings = getUsings(usingsMap, type);
     if (matchingType == null)
     {
         matchingType = matchToAliases(cache, type.File.File, typeToMatch, usingAliasesMap);
     }
     if (matchingType == null)
     {
         matchingType = getMatchingType(cache, typeToMatch, usings);
         if (matchingType == null)
             matchingType = cache.FirstMatchingTypeFromName(typeToMatch);
     }
     if (matchingType != null)
         type.Resolve(type.Type.Replace(typeToMatch, matchingType));
     return matchingType != null;
 }
Esempio n. 4
0
 private string matchToAliases(IOutputWriter cache, string file, string type, Dictionary<string,UsingAlias[]> usingAliasesMap)
 {
     UsingAlias[] aliases;
     if (!usingAliasesMap.TryGetValue(file, out aliases))
         return null;
     var match = aliases.FirstOrDefault(x => x.Name == type);
     if (match != null) {
         if (cache.ContainsType(match.Parent))
             return match.Parent;
         var firstMatch = cache.FirstMatchingTypeFromName(match.Parent);
         if (firstMatch != null)
             return firstMatch;
         return match.Parent;
     }
     return null;
 }