示例#1
0
        public void Build(DependencyModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            // Classes
            Parallel.ForEach(model.SolutionSymbols.Where(s => s.TypeKind == TypeKind.Class), typeSymbol =>
            {
                CheckBaseTypeReference(model, typeSymbol);
                CheckInterfaces(model, typeSymbol);
                CheckMethods(model, typeSymbol);
                CheckProperties(model, typeSymbol);
                CheckFields(model, typeSymbol);
                CheckEvents(model, typeSymbol);
            });

            // Stucts
            Parallel.ForEach(model.SolutionSymbols.Where(s => s.TypeKind == TypeKind.Struct || s.TypeKind == TypeKind.Structure), structSymbol =>
            {
                CheckBaseTypeReference(model, structSymbol);
                CheckInterfaces(model, structSymbol);
                CheckMethods(model, structSymbol);
                CheckProperties(model, structSymbol);
                CheckFields(model, structSymbol);
                CheckEvents(model, structSymbol);
            });

            // Interfaces
            Parallel.ForEach(model.SolutionSymbols.Where(s => s.TypeKind == TypeKind.Interface), interfaceSymbol =>
            {
                CheckBaseTypeReference(model, interfaceSymbol);
                CheckInterfaces(model, interfaceSymbol);
                CheckMethods(model, interfaceSymbol);
                CheckProperties(model, interfaceSymbol);
                CheckEvents(model, interfaceSymbol);
            });

            // Delegates
            Parallel.ForEach(model.SolutionSymbols.Where(s => s.TypeKind == TypeKind.Delegate), delegateSymbol =>
            {
                if (delegateSymbol.DelegateInvokeMethod != null)
                {
                    CheckMethod(model, delegateSymbol, delegateSymbol.DelegateInvokeMethod);
                }
            });
        }
示例#2
0
        private static void ProcessMemberSymbols <T>(DependencyModel model, INamedTypeSymbol symbol, Func <T, ITypeSymbol> getType, Func <ReferenceEndpoint, ReferenceEndpoint, ReferenceDefinition> factory) where T : ISymbol
        {
            var symbols = symbol.GetMembers().OfType <T>();

            if (symbols.Any())
            {
                Parallel.ForEach(symbols, memberSymbol =>
                {
                    var memberType = getType(memberSymbol) as INamedTypeSymbol; // Only named types are considered
                    if (memberType != null)
                    {
                        foreach (var type in memberType.ResolveGeneralizedType())
                        {
                            AddReference(model, symbol, type, factory);
                        }
                    }
                });
            }
        }
示例#3
0
 private void CheckMethods(DependencyModel model, INamedTypeSymbol symbol)
 {
     Parallel.ForEach(symbol.GetMembers().OfType <IMethodSymbol>(), methodSymbol => CheckMethod(model, symbol, methodSymbol));
 }
示例#4
0
 private void CheckEvents(DependencyModel model, INamedTypeSymbol symbol)
 {
     ProcessMemberSymbols <IEventSymbol>(model, symbol, s => s.Type, (f, t) => new EventReference(f, t));
 }
示例#5
0
 private void CheckFields(DependencyModel model, INamedTypeSymbol symbol)
 {
     ProcessMemberSymbols <IFieldSymbol>(model, symbol, s => s.Type, (f, t) => new FieldReference(f, t));
 }
示例#6
0
 private void CheckProperties(DependencyModel model, INamedTypeSymbol symbol)
 {
     ProcessMemberSymbols <IPropertySymbol>(model, symbol, s => s.Type, (f, t) => new PropertyReference(f, t));
 }