diff Source/Aspects/MixinAttribute.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/MixinAttribute.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,72 @@
+using System;
+
+using BLToolkit.TypeBuilder.Builders;
+
+namespace BLToolkit.Aspects
+{
+	/// <summary>
+	/// http://www.bltoolkit.net/Doc/Aspects/index.htm
+	/// </summary>
+	[AttributeUsage(AttributeTargets.Class, AllowMultiple=true)]
+	public sealed class MixinAttribute : AbstractTypeBuilderAttribute
+	{
+		public MixinAttribute(
+			Type targetInterface, string memberName, bool throwExceptionIfNull, string exceptionMessage)
+		{
+			_targetInterface      = targetInterface;
+			_memberName           = memberName;
+			_throwExceptionIfNull = throwExceptionIfNull;
+			_exceptionMessage     = exceptionMessage;
+		}
+
+		public MixinAttribute(Type targetInterface, string memberName, bool throwExceptionIfNull)
+			: this(targetInterface, memberName, throwExceptionIfNull, null)
+		{
+		}
+
+		public MixinAttribute(Type targetInterface, string memberName, string exceptionMessage)
+			: this(targetInterface, memberName, true, exceptionMessage)
+		{
+		}
+
+		public MixinAttribute(Type targetInterface, string memberName)
+			: this(targetInterface, memberName, true, null)
+		{
+		}
+
+		private readonly Type _targetInterface;
+		public           Type  TargetInterface
+		{
+			get { return _targetInterface;  }
+		}
+
+		private readonly string _memberName;
+		public           string  MemberName
+		{
+			get { return _memberName;  }
+		}
+
+		private bool _throwExceptionIfNull;
+		public  bool  ThrowExceptionIfNull
+		{
+			get { return _throwExceptionIfNull;  }
+			set { _throwExceptionIfNull = value; }
+		}
+
+		private string _exceptionMessage;
+		public  string  ExceptionMessage
+		{
+			get { return _exceptionMessage;  }
+			set { _exceptionMessage = value; }
+		}
+
+		public override IAbstractTypeBuilder TypeBuilder
+		{
+			get
+			{
+				return new Builders.MixinAspectBuilder(
+					_targetInterface, _memberName, _throwExceptionIfNull, _exceptionMessage);
+			}
+		}
+	}
+}