diff Source/Mapping/TrimmableAttribute.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/Mapping/TrimmableAttribute.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,40 @@
+using System;
+using System.Diagnostics.CodeAnalysis;
+using BLToolkit.Common;
+
+namespace BLToolkit.Mapping
+{
+	[AttributeUsage(
+		AttributeTargets.Property | AttributeTargets.Field |
+		AttributeTargets.Class | AttributeTargets.Interface)]
+	public sealed class TrimmableAttribute : Attribute
+	{
+		public TrimmableAttribute()
+		{
+			_isTrimmable = true;
+		}
+
+		public TrimmableAttribute(bool isTrimmable)
+		{
+			_isTrimmable = isTrimmable;
+		}
+
+		private readonly bool _isTrimmable;
+		public           bool  IsTrimmable
+		{
+			get { return _isTrimmable;  }
+		}
+
+		private static TrimmableAttribute GetDefaultTrimmableAttribute()
+		{
+			return Common.Configuration.TrimOnMapping ? Yes : No;
+		}
+
+		[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
+		public static readonly TrimmableAttribute Yes     = new TrimmableAttribute(true);
+		[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
+		public static readonly TrimmableAttribute No      = new TrimmableAttribute(false);
+		[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
+		public static readonly TrimmableAttribute Default = GetDefaultTrimmableAttribute();
+	}
+}