Exemplo n.º 1
0
        private MethodsForWeaving SelectMethods()
        {
            LogInfo(string.Format("Searching for Methods and Properties in assembly ({0}).", ModuleDefinition.Name));

            MethodsForWeaving result = new MethodsForWeaving();

            foreach (TypeDefinition type in ModuleDefinition.Types)
            {
                foreach (MethodDefinition method in type.Methods)
                {
                    if (ShouldWeaveMethod(method))
                    {
                        result.Add(method);
                    }

                    method.RemoveAttribute(CacheAttributeName);
                    method.RemoveAttribute(NoCacheAttributeName);
                }

                foreach (PropertyDefinition property in type.Properties)
                {
                    if (ShouldWeaveProperty(property))
                    {
                        result.Add(property);
                    }

                    property.RemoveAttribute(CacheAttributeName);
                    property.RemoveAttribute(NoCacheAttributeName);
                }

                type.RemoveAttribute(CacheAttributeName);
            }

            return(result);
        }
Exemplo n.º 2
0
        public void Execute()
        {
            LogDebugOutput = DefineConstants.Any(x => x.ToLower() == "debug");
            MethodCacheEnabledByDefault   = true;
            PropertyCacheEnabledByDefault = true;

            ReadConfiguration();

            MethodsForWeaving methodToWeave = SelectMethods();

            WeaveMethods(methodToWeave.Methods);
            WeaveProperties(methodToWeave.Properties);

            RemoveReference();
        }
Exemplo n.º 3
0
        private MethodsForWeaving SelectMethods()
        {
            LogInfo(string.Format("Searching for Methods and Properties in assembly ({0}).", ModuleDefinition.Name));

            MethodsForWeaving result = new MethodsForWeaving();

            foreach (TypeDefinition type in ModuleDefinition.Types)
            {
                foreach (MethodDefinition method in type.Methods)
                {
                    if (ShouldWeaveMethod(method))
                    {
                        // Store Cache attribute, method attribute takes precedence over class attributes
                        CustomAttribute attribute =
                            method.CustomAttributes.SingleOrDefault(x => x.Constructor.DeclaringType.Name == CacheAttributeName) ??
                            method.DeclaringType.CustomAttributes.SingleOrDefault(
                                x => x.Constructor.DeclaringType.Name == CacheAttributeName);

                        result.Add(method, attribute);
                    }

                    method.RemoveAttribute(CacheAttributeName);
                    method.RemoveAttribute(NoCacheAttributeName);
                }

                foreach (PropertyDefinition property in type.Properties)
                {
                    if (ShouldWeaveProperty(property))
                    {
                        // Store Cache attribute, property attribute takes precedence over class attributes
                        CustomAttribute attribute =
                            property.CustomAttributes.SingleOrDefault(x => x.Constructor.DeclaringType.Name == CacheAttributeName) ??
                            property.DeclaringType.CustomAttributes.SingleOrDefault(
                                x => x.Constructor.DeclaringType.Name == CacheAttributeName);

                        result.Add(property, attribute);
                    }

                    property.RemoveAttribute(CacheAttributeName);
                    property.RemoveAttribute(NoCacheAttributeName);
                }

                type.RemoveAttribute(CacheAttributeName);
            }

            return(result);
        }
Exemplo n.º 4
0
        public void Execute()
        {
            LogDebugOutput = DefineConstants.Any(x => x.ToLower() == "debug");

            References = new References()
            {
                AssemblyResolver = AssemblyResolver, ModuleDefinition = ModuleDefinition
            };
            References.LoadReferences();

            MethodCacheEnabledByDefault   = true;
            PropertyCacheEnabledByDefault = true;

            ReadConfiguration();

            MethodsForWeaving methodToWeave = SelectMethods();

            WeaveMethods(methodToWeave.Methods);
            WeaveProperties(methodToWeave.Properties);

            RemoveReference();
        }
Exemplo n.º 5
0
        private MethodsForWeaving SelectMethods()
        {
            LogInfo(string.Format("Searching for Methods and Properties in assembly ({0}).", ModuleDefinition.Name));

            MethodsForWeaving result = new MethodsForWeaving();

            foreach (TypeDefinition type in ModuleDefinition.Types)
            {
                foreach (MethodDefinition method in type.Methods)
                {
                    if (ShouldWeaveMethod(method))
                    {
                        result.Add(method);
                    }

                    method.RemoveAttribute(CacheAttributeName);
                    method.RemoveAttribute(NoCacheAttributeName);
                }

                foreach (PropertyDefinition property in type.Properties)
                {
                    if (ShouldWeaveProperty(property))
                    {
                        result.Add(property);
                    }

                    property.RemoveAttribute(CacheAttributeName);
                    property.RemoveAttribute(NoCacheAttributeName);
                }

                type.RemoveAttribute(CacheAttributeName);
            }

            return result;
        }