Exemplo n.º 1
0
        static void HandleModule(HandleModuleArgs args)
        {
            if (args.ModuleDefinition.HasTypes)
            {
                var postCompilationAssembly = Assembly.GetAssembly(Globals.TypeReferences.AttributeBase);
                if (postCompilationAssembly == null)
                {
                    Globals.Loggers.Global.Fatal("PostCompilation Assembly was not found in references.");
                    return;
                }

                var methodAttributeNames = postCompilationAssembly.GetTypes().
                    Where(t => Globals.TypeReferences.MethodAttributeBase.IsAssignableFrom(t) &&
                        t.FullName != Globals.TypeReferences.MethodAttributeBase.FullName).
                    Select(t => t.FullName).ToArray();
                var classAttributeNames = postCompilationAssembly.GetTypes().
                    Where(t => Globals.TypeReferences.ClassAttributeBase.IsAssignableFrom(t) &&
                        t.FullName != Globals.TypeReferences.ClassAttributeBase.FullName).
                    Select(t => t.FullName).ToArray();

                if (methodAttributeNames.Length == 0 || classAttributeNames.Length == 0)
                {
                    Globals.Loggers.Global.Warn("MethodAttributeBase and ClassAttributeBase inheritors were not found.");
                    return;
                }

                Globals.Loggers.File.Debug("Inheritors of MethodAttributeBase were found: {0} types.", methodAttributeNames.Length);
                Globals.Loggers.File.Debug("Inheritors of ClassAttributeBase were found: {0} types.", classAttributeNames.Length);

                Globals.Loggers.File.Trace("Handling types.");
                foreach (var typeDef in args.ModuleDefinition.Types)
                {
                    var handleTypeArgs = new HandleTypeArgs
                    {
                        TypeDefinition = typeDef,
                        MethodAttributeNames = methodAttributeNames,
                        ClassAttributeNames = classAttributeNames
                    };
                    HandleType(handleTypeArgs);
                }
            }
            else
            {
                Globals.Loggers.File.Warn("Module does not has types.");
            }
        }
Exemplo n.º 2
0
        static void HandleModule(HandleModuleArgs args)
        {
            if (args.ModuleDefinition.HasTypes)
            {
                var postCompilationAssembly = Assembly.GetAssembly(Globals.TypeReferences.AttributeBase);
                if (postCompilationAssembly == null)
                {
                    Globals.Loggers.Global.Fatal("PostCompilation Assembly was not found in references.");
                    return;
                }

                var methodAttributeNames = postCompilationAssembly.GetTypes().
                                           Where(t => Globals.TypeReferences.MethodAttributeBase.IsAssignableFrom(t) &&
                                                 t.FullName != Globals.TypeReferences.MethodAttributeBase.FullName).
                                           Select(t => t.FullName).ToArray();
                var classAttributeNames = postCompilationAssembly.GetTypes().
                                          Where(t => Globals.TypeReferences.ClassAttributeBase.IsAssignableFrom(t) &&
                                                t.FullName != Globals.TypeReferences.ClassAttributeBase.FullName).
                                          Select(t => t.FullName).ToArray();

                if (methodAttributeNames.Length == 0 || classAttributeNames.Length == 0)
                {
                    Globals.Loggers.Global.Warn("MethodAttributeBase and ClassAttributeBase inheritors were not found.");
                    return;
                }

                Globals.Loggers.File.Debug("Inheritors of MethodAttributeBase were found: {0} types.", methodAttributeNames.Length);
                Globals.Loggers.File.Debug("Inheritors of ClassAttributeBase were found: {0} types.", classAttributeNames.Length);

                Globals.Loggers.File.Trace("Handling types.");
                foreach (var typeDef in args.ModuleDefinition.Types)
                {
                    var handleTypeArgs = new HandleTypeArgs
                    {
                        TypeDefinition       = typeDef,
                        MethodAttributeNames = methodAttributeNames,
                        ClassAttributeNames  = classAttributeNames
                    };
                    HandleType(handleTypeArgs);
                }
            }
            else
            {
                Globals.Loggers.File.Warn("Module does not has types.");
            }
        }
Exemplo n.º 3
0
        static void HandleType(HandleTypeArgs args)
        {
            Globals.Loggers.File.Trace("Handling {0} type.", args.TypeDefinition.FullName);
            if (args.TypeDefinition.HasMethods)
            {
                if (args.TypeDefinition.HasCustomAttributes)
                {
                    Globals.Loggers.File.Trace("Handling type custom attributes.");
                    for (var i = 0; i < args.TypeDefinition.CustomAttributes.Count; i++)
                    {
                        var handleArgs = new HandleClassAttributeArgs
                        {
                            ClassAttributeNames = args.ClassAttributeNames,
                            CustomAttribute     = args.TypeDefinition.CustomAttributes[i],
                            TypeDefinition      = args.TypeDefinition
                        };

                        if (HandleTypeAttribute(handleArgs))
                        {
                            i--;
                        }
                    }
                }
                else
                {
                    Globals.Loggers.File.Trace("Type does not has custom attributes.");
                }

                Globals.Loggers.File.Trace("Handling methods.");
                for (var i = 0; i < args.TypeDefinition.Methods.Count; i++)
                {
                    var handleArgs = new HandleMethodArgs
                    {
                        MethodAttributeNames = args.MethodAttributeNames,
                        MethodDefinition     = args.TypeDefinition.Methods[i]
                    };
                    HandleMethod(handleArgs);
                }
            }
            else
            {
                Globals.Loggers.File.Trace("Type does not has methods.");
            }
        }
Exemplo n.º 4
0
        static void HandleType(HandleTypeArgs args)
        {
            Globals.Loggers.File.Trace("Handling {0} type.", args.TypeDefinition.FullName);
            if (args.TypeDefinition.HasMethods)
            {
                if (args.TypeDefinition.HasCustomAttributes)
                {
                    Globals.Loggers.File.Trace("Handling type custom attributes.");
                    for (var i = 0; i < args.TypeDefinition.CustomAttributes.Count; i++ )
                    {
                        var handleArgs = new HandleClassAttributeArgs
                        {
                            ClassAttributeNames = args.ClassAttributeNames,
                            CustomAttribute = args.TypeDefinition.CustomAttributes[i],
                            TypeDefinition = args.TypeDefinition
                        };

                        if (HandleTypeAttribute(handleArgs))
                        {
                            i--;
                        }
                    }
                }
                else
                {
                    Globals.Loggers.File.Trace("Type does not has custom attributes.");
                }

                Globals.Loggers.File.Trace("Handling methods.");
                for (var i = 0; i < args.TypeDefinition.Methods.Count; i++)
                {
                    var handleArgs = new HandleMethodArgs
                    {
                        MethodAttributeNames = args.MethodAttributeNames,
                        MethodDefinition = args.TypeDefinition.Methods[i]
                    };
                    HandleMethod(handleArgs);
                }
            }
            else
            {
                Globals.Loggers.File.Trace("Type does not has methods.");
            }
        }