diff Source/Aspects/NoInterceptionAttribute.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/Aspects/NoInterceptionAttribute.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,44 @@
+using System;
+
+using BLToolkit.TypeBuilder.Builders;
+
+namespace BLToolkit.Aspects
+{
+	[AttributeUsage(
+		AttributeTargets.Class |
+		AttributeTargets.Interface |
+		AttributeTargets.Property |
+		AttributeTargets.Method,
+		AllowMultiple=true)]
+	public class NoInterceptionAttribute : InterceptorAttribute
+	{
+		public NoInterceptionAttribute()
+			: base(null, 0)
+		{
+		}
+
+		public NoInterceptionAttribute(Type interceptorType, InterceptType interceptType)
+			: base(interceptorType, interceptType)
+		{
+		}
+
+		public override IAbstractTypeBuilder TypeBuilder
+		{
+			get { return new NoInterceptionAspectBuilder(InterceptorType, InterceptType); }
+		}
+
+		private class NoInterceptionAspectBuilder : Builders.InterceptorAspectBuilder
+		{
+			public NoInterceptionAspectBuilder(Type interceptorType, InterceptType interceptType)
+				: base(interceptorType, interceptType, null, TypeBuilderConsts.Priority.Normal, false)
+			{
+			}
+
+			public override void Build(BuildContext context)
+			{
+				if (context.Step == BuildStep.Begin || context.Step == BuildStep.End)
+					base.Build(context);
+			}
+		}
+	}
+}