private Type GenerateProxyType(string objectName, IConfigurableListableObjectFactory objectFactory)
        {
            ProxyFactory proxyFactory = new ProxyFactory();
            proxyFactory.ProxyTargetAttributes = true;
            proxyFactory.Interfaces = Type.EmptyTypes;
            proxyFactory.TargetSource = new ObjectFactoryTargetSource(objectName, objectFactory);
            SpringObjectMethodInterceptor methodInterceptor = new SpringObjectMethodInterceptor(objectFactory);
            proxyFactory.AddAdvice(methodInterceptor);

            //TODO check type of object isn't infrastructure type.

            InheritanceAopProxyTypeBuilder iaptb = new InheritanceAopProxyTypeBuilder(proxyFactory);
            //iaptb.ProxyDeclaredMembersOnly = true; // make configurable.
            return iaptb.BuildProxyType();
        }
        private void EnhanceConfigurationClasses(IConfigurableListableObjectFactory objectFactory)
        {
            string[] objectNames = objectFactory.GetObjectDefinitionNames();

            foreach (string t in objectNames)
            {
                IObjectDefinition objDef = objectFactory.GetObjectDefinition(t);

                if (((AbstractObjectDefinition)objDef).HasObjectType)
                {
                    if (Attribute.GetCustomAttribute(objDef.ObjectType, typeof(ConfigurationAttribute)) != null)
                    {

                        ProxyFactory proxyFactory = new ProxyFactory();
                        proxyFactory.ProxyTargetAttributes = true;
                        proxyFactory.Interfaces = Type.EmptyTypes;
                        proxyFactory.TargetSource = new ObjectFactoryTargetSource(t, objectFactory);
                        SpringObjectMethodInterceptor methodInterceptor = new SpringObjectMethodInterceptor(objectFactory);
                        proxyFactory.AddAdvice(methodInterceptor);

                        //TODO check type of object isn't infrastructure type.

                        InheritanceAopProxyTypeBuilder iaptb = new InheritanceAopProxyTypeBuilder(proxyFactory);
                        //iaptb.ProxyDeclaredMembersOnly = true; // make configurable.
                        ((IConfigurableObjectDefinition)objDef).ObjectType = iaptb.BuildProxyType();

                        objDef.ConstructorArgumentValues.AddIndexedArgumentValue(objDef.ConstructorArgumentValues.ArgumentCount, proxyFactory);

                    }
                }
            }
        }