Exemplo n.º 1
0
        private SymbolResolution ResolveViaUsings(NameSyntax baseName, NameSyntax name, IUsingsContainer usingsContainer)
        {
            if (!(name is SimpleNameSyntax))
                return default(SymbolResolution);

            if (baseName != null)
            {
                return baseName.Recurse(x => x.Parent)
                    .Select(ns => usingsContainer.UsingStatements
                        .SelectMaybe(u =>
                        {
                            var n = ns + u.Namespace + name;
                            return _map.TryGetValue(n); 
                        })
                        .Select(x => new SymbolResolution(x))
                        .Aggregate(default(SymbolResolution), (l, r) => l & r))
                    .TryFirst(x => x.Status != SymbolResolutionStatus.NotFound)
                    .ValueOrDefault();
            }

            return usingsContainer.UsingStatements
                .SelectMaybe(u =>
                {
                    var n = u.Namespace + name;
                    return _map.TryGetValue(n); 
                })
                .Select(x => new SymbolResolution(x))
                .Aggregate(default(SymbolResolution), (l, r) => l & r);
        }