Пример #1
0
        private static void FindTypeAttributes <T>(ShadowAssemblyType shadowAssembly, System.Type type,
                                                   List <AttributeResult <T> > attributesFound) where T : Attribute
        {
            try
            {
                var typeAttributes =
                    type
                    .GetCustomAttributes(true)
                    .Where(
                        attr =>
                        attr.GetType().FullName == typeof(T).FullName)
                    .ToList();

                if (typeAttributes.Count > 0)
                {
                    var attribute = typeAttributes.Cast <T>().First();
                    var info      = new AttributeResult <T>(shadowAssembly, type, attribute);
                    attributesFound.Add(info);
                }
            }
            catch (Exception err1)
            {
                "CryoAOP -> Warning! First chance exception ocurred while searching for Mixin Methods. \r\n{0}"
                .Warn(err1);
            }
        }
Пример #2
0
        private static void FindMethodAttributes <T>(ShadowAssemblyType shadowAssembly, System.Type type,
                                                     List <AttributeResult <T> > attributesFound) where T : Attribute
        {
            try
            {
                var methods =
                    type.GetMethods(
                        BindingFlags.Public
                        | BindingFlags.NonPublic
                        | BindingFlags.Static
                        | BindingFlags.Instance);

                foreach (var method in methods)
                {
                    try
                    {
                        var methodAttributes =
                            method
                            .GetCustomAttributes(true)
                            .Where(
                                attr =>
                                attr.GetType().FullName == typeof(T).FullName)
                            .ToList();

                        if (methodAttributes.Count > 0)
                        {
                            var attribute = methodAttributes.Cast <T>().First();
                            var info      = new AttributeResult <T>(shadowAssembly, type, method, attribute);
                            attributesFound.Add(info);
                        }
                    }
                    catch (Exception err)
                    {
                        "CryoAOP -> Warning! First chance exception ocurred while searching for Mixin Methods. \r\n{0}"
                        .Warn(err);
                    }
                }
            }
            catch (Exception err2)
            {
                "CryoAOP -> Warning! First chance exception ocurred while searching for Mixin Methods. \r\n{0}"
                .Warn(err2);
            }
        }