AOPAttribute

 


using System;
using SharpRush.AOP.Support;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Services;
using System.Security.Permissions;

namespace SharpRush.AOP
{
    
/// <summary>
    
/// AOPAttribute 的摘要说明。
    
/// </summary>

    [AttributeUsage(AttributeTargets.Class)]
    [SecurityPermissionAttribute(SecurityAction.Demand, Flags
=SecurityPermissionFlag.Infrastructure)]
    
public abstract class AOPAttribute:ProxyAttribute
    
{
        AOPAttribute _current;
        
/// <summary>
        
/// 
        
/// </summary>

        public AOPAttribute()
        
{
            _current
=this;
        }


        
/// <summary>
        
/// 
        
/// </summary>
        
/// <param name="type"></param>
        
/// <returns></returns>

        public override MarshalByRefObject CreateInstance(Type type)
        
{
            MarshalByRefObject refObj
= base.CreateInstance(type);
            RealProxy realProxy 
= new AOPProxy(_current,type,refObj);
            MarshalByRefObject retobj 
= realProxy.GetTransparentProxy() as MarshalByRefObject;
            
return retobj;
        }


        
/// <summary>
        
/// 
        
/// </summary>
        
/// <param name="msg"></param>

        public virtual void PreProcess(IMessage msg)
        
{
        }


        
/// <summary>
        
/// 
        
/// </summary>
        
/// <param name="msg"></param>

        public virtual void PostProcess(IMessage msg)
        
{
        }

    }

}

posted @ 2005-08-16 16:26  Martin XJ  阅读(373)  评论(0编辑  收藏  举报