⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aspectattribute.cs

📁 应用AOP
💻 CS
字号:
//
// Write by Peopleyl 2007-04-13
//
using System;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Activation;

namespace Aspect.AopBase
{
	[Serializable,AttributeUsage(AttributeTargets.Class|AttributeTargets.Method)]
	public abstract class AspectAttribute:Attribute,IContextAttribute,IContextProperty
	{	
		#region Attribute Member		
		public override bool Equals(object obj)
		{	
			IContextProperty contextProperty = obj as IContextProperty;
			if(contextProperty != null)
			{
				return Name.Equals(contextProperty.Name);
			}
			return false;
		}
		
		public override int GetHashCode()
		{
			return Name.GetHashCode();
		}
		#endregion

		#region IContextProperty Member
		
		public virtual string Name
		{
			get
			{
				return "Aop";
			}
		}

		public virtual bool IsNewContextOK(Context context)
		{
			return true;
		}

		public virtual void Freeze(Context newContext)
		{
			return;
		}

		#endregion

		#region IContextAttribute Member
		
		public void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
		{
			if (ctorMsg == null)
			{
				throw new ArgumentNullException("ctorMsg");
			}
			ctorMsg.ContextProperties.Add(GetContextProperty(Name));
		}
		
		public virtual bool IsContextOK(Context context, IConstructionCallMessage ctorCallMsg)
		{
			if(context == null)
				throw new ArgumentNullException("context");

			if(ctorCallMsg == null)
				throw new ArgumentNullException("ctorCallMsg");

			if(!ctorCallMsg.ActivationType.IsContextful)
				return true;

			object obj = context.GetProperty(Name);
			if((obj != null) && this.Equals(obj))
				return true;

			return false;
		}

		public abstract AspectProperty GetContextProperty(string aopName);

		#endregion

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -