**** Merged from MCS ****
[mono-project.git] / mcs / class / Microsoft.VisualBasic / Microsoft.VisualBasic / VBFixedArrayAttribute.cs
blob99802fbfc06ecef0d247e80b63163606c43096e8
1 //
2 // VBFixedArrayAttribute.cs
3 //
4 // Author:
5 // Chris J Breisch (cjbreisch@altavista.net)
6 // Rafael Teixeira (rafaelteixeirabr@hotmail.com)
7 // Dennis Hayes (dennish@raytek.com)
8 //
9 // (C) 2002 Chris J Breisch
10 // (C) 2004 Rafael Teixeira
13 * Copyright (c) 2002-2003 Mainsoft Corporation.
14 * Copyright (C) 2004 Novell, Inc (http://www.novell.com)
16 * Permission is hereby granted, free of charge, to any person obtaining a
17 * copy of this software and associated documentation files (the "Software"),
18 * to deal in the Software without restriction, including without limitation
19 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
20 * and/or sell copies of the Software, and to permit persons to whom the
21 * Software is furnished to do so, subject to the following conditions:
23 * The above copyright notice and this permission notice shall be included in
24 * all copies or substantial portions of the Software.
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 * DEALINGS IN THE SOFTWARE.
36 using System;
37 using Microsoft.VisualBasic.CompilerServices;
39 namespace Microsoft.VisualBasic {
40 [AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
41 sealed public class VBFixedArrayAttribute : Attribute {
43 // Declarations
44 private int upperBound1;
45 private int upperBound2;
46 private bool bidimensional;
48 // Constructors
49 public VBFixedArrayAttribute(int UpperBound1) {
50 if (UpperBound1 < 0) {
51 throw new ArgumentException(
52 Utils.GetResourceString("Invalid_VBFixedArray"));
54 upperBound1 = UpperBound1;
55 bidimensional = false;
58 public VBFixedArrayAttribute(int UpperBound1, int UpperBound2) {
59 if (UpperBound1 < 0) {
60 throw new ArgumentException(
61 Utils.GetResourceString("Invalid_VBFixedArray"));
63 if (UpperBound2 < 0) {
64 throw new ArgumentException(
65 Utils.GetResourceString("Invalid_VBFixedArray"));
67 upperBound1 = UpperBound1;
68 upperBound2 = UpperBound2;
69 bidimensional = true;
72 // Properties
73 public int Length {
74 get {
75 if (bidimensional)
76 return (upperBound1+1)*(upperBound2+1);
77 return upperBound1+1;
81 public int[] Bounds {
82 get {
83 if (bidimensional)
84 return new int[] { upperBound1, upperBound2 };
85 return new int[] { upperBound1 };