diff Source/DataAccess/IndexAttribute.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/DataAccess/IndexAttribute.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,50 @@
+using System;
+
+using BLToolkit.Common;
+using BLToolkit.Properties;
+
+namespace BLToolkit.DataAccess
+{
+	[AttributeUsage(AttributeTargets.Method), CLSCompliant(false)]
+	public class IndexAttribute : Attribute
+	{
+		public IndexAttribute(params string[] names)
+		{
+			if (null == names)
+				throw new ArgumentNullException("names");
+
+			if (names.Length == 0)
+				throw new ArgumentException(Resources.MapIndex_EmptyNames, "names");
+
+			_fields = NameOrIndexParameter.FromStringArray(names);
+		}
+
+		public IndexAttribute(params int[] indices)
+		{
+			if (null == indices)
+				throw new ArgumentNullException("indices");
+
+			if (indices.Length == 0)
+				throw new ArgumentException(Resources.MapIndex_EmptyIndices, "indices");
+
+			_fields = NameOrIndexParameter.FromIndexArray(indices);
+		}
+
+		public IndexAttribute(params NameOrIndexParameter[] fields)
+		{
+			if (null == fields)
+				throw new ArgumentNullException("fields");
+
+			if (fields.Length == 0)
+				throw new ArgumentException(Resources.MapIndex_EmptyFields, "fields");
+			
+			_fields = fields;
+		}
+
+		private readonly NameOrIndexParameter[] _fields;
+		public           NameOrIndexParameter[]  Fields
+		{
+			get { return _fields; }
+		}
+	}
+}