Showing the changes to Source/Libraries/GSF.Core/Interop/VBArrayDescriptor.cs (1 of 628 files). Show all
Unified · Split
| @@ -0,0 +1,423 @@ | ||
| 1 | +//******************************************************************************************************* | |
| 2 | +// VBArrayDescriptor.cs - Gbtc | |
| 3 | +// | |
| 4 | +// Tennessee Valley Authority, 2011 | |
| 5 | +// No copyright is claimed pursuant to 17 USC � 105. All Other Rights Reserved. | |
| 6 | +// | |
| 7 | +// This software is made freely available under the TVA Open Source Agreement (see below). | |
| 8 | +// Code in this file licensed to GSF under one or more contributor license agreements listed below. | |
| 9 | +// | |
| 10 | +// Code Modification History: | |
| 11 | +// ----------------------------------------------------------------------------------------------------- | |
| 12 | +// 03/07/2007 - Pinal C. Patel | |
| 13 | +// Original version of source code generated. | |
| 14 | +// Generated original version of source code. | |
| 15 | +// 09/10/2008 - J. Ritchie Carroll | |
| 16 | +// Converted to C#. | |
| 17 | +// 11/04/2008 - Pinal C. Patel | |
| 18 | +// Edited code comments. | |
| 19 | +// 09/14/2009 - Stephen C. Wills | |
| 20 | +// Added new header and license agreement. | |
| 21 | +// 11/23/2011 - J. Ritchie Carroll | |
| 22 | +// Updated to support new ISupportBinaryImage buffer optimizations. | |
| 23 | +// | |
| 24 | +//******************************************************************************************************* | |
| 25 | + | |
| 26 | +#region [ TVA Open Source Agreement ] | |
| 27 | +/* | |
| 28 | + | |
| 29 | + THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE,REPRODUCTION, DISTRIBUTION, | |
| 30 | + MODIFICATION AND REDISTRIBUTION OF CERTAIN COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE | |
| 31 | + TENNESSEE VALLEY AUTHORITY, A CORPORATE AGENCY AND INSTRUMENTALITY OF THE UNITED STATES GOVERNMENT | |
| 32 | + ("GOVERNMENT AGENCY"). GOVERNMENT AGENCY IS AN INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT | |
| 33 | + DISTRIBUTIONS OR REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES, DISTRIBUTES, | |
| 34 | + MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED HEREIN, OR ANY PART THEREOF, IS, BY THAT | |
| 35 | + ACTION, ACCEPTING IN FULL THE RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT. | |
| 36 | + | |
| 37 | + Original Software Designation: openPDC | |
| 38 | + Original Software Title: The GSF Open Source Phasor Data Concentrator | |
| 39 | + User Registration Requested. Please Visit https://naspi.tva.com/Registration/ | |
| 40 | + Point of Contact for Original Software: J. Ritchie Carroll <mailto:jrcarrol@tva.gov> | |
| 41 | + | |
| 42 | + 1. DEFINITIONS | |
| 43 | + | |
| 44 | + A. "Contributor" means Government Agency, as the developer of the Original Software, and any entity | |
| 45 | + that makes a Modification. | |
| 46 | + | |
| 47 | + B. "Covered Patents" mean patent claims licensable by a Contributor that are necessarily infringed by | |
| 48 | + the use or sale of its Modification alone or when combined with the Subject Software. | |
| 49 | + | |
| 50 | + C. "Display" means the showing of a copy of the Subject Software, either directly or by means of an | |
| 51 | + image, or any other device. | |
| 52 | + | |
| 53 | + D. "Distribution" means conveyance or transfer of the Subject Software, regardless of means, to | |
| 54 | + another. | |
| 55 | + | |
| 56 | + E. "Larger Work" means computer software that combines Subject Software, or portions thereof, with | |
| 57 | + software separate from the Subject Software that is not governed by the terms of this Agreement. | |
| 58 | + | |
| 59 | + F. "Modification" means any alteration of, including addition to or deletion from, the substance or | |
| 60 | + structure of either the Original Software or Subject Software, and includes derivative works, as that | |
| 61 | + term is defined in the Copyright Statute, 17 USC � 101. However, the act of including Subject Software | |
| 62 | + as part of a Larger Work does not in and of itself constitute a Modification. | |
| 63 | + | |
| 64 | + G. "Original Software" means the computer software first released under this Agreement by Government | |
| 65 | + Agency entitled openPDC, including source code, object code and accompanying documentation, if any. | |
| 66 | + | |
| 67 | + H. "Recipient" means anyone who acquires the Subject Software under this Agreement, including all | |
| 68 | + Contributors. | |
| 69 | + | |
| 70 | + I. "Redistribution" means Distribution of the Subject Software after a Modification has been made. | |
| 71 | + | |
| 72 | + J. "Reproduction" means the making of a counterpart, image or copy of the Subject Software. | |
| 73 | + | |
| 74 | + K. "Sale" means the exchange of the Subject Software for money or equivalent value. | |
| 75 | + | |
| 76 | + L. "Subject Software" means the Original Software, Modifications, or any respective parts thereof. | |
| 77 | + | |
| 78 | + M. "Use" means the application or employment of the Subject Software for any purpose. | |
| 79 | + | |
| 80 | + 2. GRANT OF RIGHTS | |
| 81 | + | |
| 82 | + A. Under Non-Patent Rights: Subject to the terms and conditions of this Agreement, each Contributor, | |
| 83 | + with respect to its own contribution to the Subject Software, hereby grants to each Recipient a | |
| 84 | + non-exclusive, world-wide, royalty-free license to engage in the following activities pertaining to | |
| 85 | + the Subject Software: | |
| 86 | + | |
| 87 | + 1. Use | |
| 88 | + | |
| 89 | + 2. Distribution | |
| 90 | + | |
| 91 | + 3. Reproduction | |
| 92 | + | |
| 93 | + 4. Modification | |
| 94 | + | |
| 95 | + 5. Redistribution | |
| 96 | + | |
| 97 | + 6. Display | |
| 98 | + | |
| 99 | + B. Under Patent Rights: Subject to the terms and conditions of this Agreement, each Contributor, with | |
| 100 | + respect to its own contribution to the Subject Software, hereby grants to each Recipient under Covered | |
| 101 | + Patents a non-exclusive, world-wide, royalty-free license to engage in the following activities | |
| 102 | + pertaining to the Subject Software: | |
| 103 | + | |
| 104 | + 1. Use | |
| 105 | + | |
| 106 | + 2. Distribution | |
| 107 | + | |
| 108 | + 3. Reproduction | |
| 109 | + | |
| 110 | + 4. Sale | |
| 111 | + | |
| 112 | + 5. Offer for Sale | |
| 113 | + | |
| 114 | + C. The rights granted under Paragraph B. also apply to the combination of a Contributor's Modification | |
| 115 | + and the Subject Software if, at the time the Modification is added by the Contributor, the addition of | |
| 116 | + such Modification causes the combination to be covered by the Covered Patents. It does not apply to | |
| 117 | + any other combinations that include a Modification. | |
| 118 | + | |
| 119 | + D. The rights granted in Paragraphs A. and B. allow the Recipient to sublicense those same rights. | |
| 120 | + Such sublicense must be under the same terms and conditions of this Agreement. | |
| 121 | + | |
| 122 | + 3. OBLIGATIONS OF RECIPIENT | |
| 123 | + | |
| 124 | + A. Distribution or Redistribution of the Subject Software must be made under this Agreement except for | |
| 125 | + additions covered under paragraph 3H. | |
| 126 | + | |
| 127 | + 1. Whenever a Recipient distributes or redistributes the Subject Software, a copy of this Agreement | |
| 128 | + must be included with each copy of the Subject Software; and | |
| 129 | + | |
| 130 | + 2. If Recipient distributes or redistributes the Subject Software in any form other than source code, | |
| 131 | + Recipient must also make the source code freely available, and must provide with each copy of the | |
| 132 | + Subject Software information on how to obtain the source code in a reasonable manner on or through a | |
| 133 | + medium customarily used for software exchange. | |
| 134 | + | |
| 135 | + B. Each Recipient must ensure that the following copyright notice appears prominently in the Subject | |
| 136 | + Software: | |
| 137 | + | |
| 138 | + No copyright is claimed pursuant to 17 USC � 105. All Other Rights Reserved. | |
| 139 | + | |
| 140 | + C. Each Contributor must characterize its alteration of the Subject Software as a Modification and | |
| 141 | + must identify itself as the originator of its Modification in a manner that reasonably allows | |
| 142 | + subsequent Recipients to identify the originator of the Modification. In fulfillment of these | |
| 143 | + requirements, Contributor must include a file (e.g., a change log file) that describes the alterations | |
| 144 | + made and the date of the alterations, identifies Contributor as originator of the alterations, and | |
| 145 | + consents to characterization of the alterations as a Modification, for example, by including a | |
| 146 | + statement that the Modification is derived, directly or indirectly, from Original Software provided by | |
| 147 | + Government Agency. Once consent is granted, it may not thereafter be revoked. | |
| 148 | + | |
| 149 | + D. A Contributor may add its own copyright notice to the Subject Software. Once a copyright notice has | |
| 150 | + been added to the Subject Software, a Recipient may not remove it without the express permission of | |
| 151 | + the Contributor who added the notice. | |
| 152 | + | |
| 153 | + E. A Recipient may not make any representation in the Subject Software or in any promotional, | |
| 154 | + advertising or other material that may be construed as an endorsement by Government Agency or by any | |
| 155 | + prior Recipient of any product or service provided by Recipient, or that may seek to obtain commercial | |
| 156 | + advantage by the fact of Government Agency's or a prior Recipient's participation in this Agreement. | |
| 157 | + | |
| 158 | + F. In an effort to track usage and maintain accurate records of the Subject Software, each Recipient, | |
| 159 | + upon receipt of the Subject Software, is requested to register with Government Agency by visiting the | |
| 160 | + following website: https://naspi.tva.com/Registration/. Recipient's name and personal information | |
| 161 | + shall be used for statistical purposes only. Once a Recipient makes a Modification available, it is | |
| 162 | + requested that the Recipient inform Government Agency at the web site provided above how to access the | |
| 163 | + Modification. | |
| 164 | + | |
| 165 | + G. Each Contributor represents that that its Modification does not violate any existing agreements, | |
| 166 | + regulations, statutes or rules, and further that Contributor has sufficient rights to grant the rights | |
| 167 | + conveyed by this Agreement. | |
| 168 | + | |
| 169 | + H. A Recipient may choose to offer, and to charge a fee for, warranty, support, indemnity and/or | |
| 170 | + liability obligations to one or more other Recipients of the Subject Software. A Recipient may do so, | |
| 171 | + however, only on its own behalf and not on behalf of Government Agency or any other Recipient. Such a | |
| 172 | + Recipient must make it absolutely clear that any such warranty, support, indemnity and/or liability | |
| 173 | + obligation is offered by that Recipient alone. Further, such Recipient agrees to indemnify Government | |
| 174 | + Agency and every other Recipient for any liability incurred by them as a result of warranty, support, | |
| 175 | + indemnity and/or liability offered by such Recipient. | |
| 176 | + | |
| 177 | + I. A Recipient may create a Larger Work by combining Subject Software with separate software not | |
| 178 | + governed by the terms of this agreement and distribute the Larger Work as a single product. In such | |
| 179 | + case, the Recipient must make sure Subject Software, or portions thereof, included in the Larger Work | |
| 180 | + is subject to this Agreement. | |
| 181 | + | |
| 182 | + J. Notwithstanding any provisions contained herein, Recipient is hereby put on notice that export of | |
| 183 | + any goods or technical data from the United States may require some form of export license from the | |
| 184 | + U.S. Government. Failure to obtain necessary export licenses may result in criminal liability under | |
| 185 | + U.S. laws. Government Agency neither represents that a license shall not be required nor that, if | |
| 186 | + required, it shall be issued. Nothing granted herein provides any such export license. | |
| 187 | + | |
| 188 | + 4. DISCLAIMER OF WARRANTIES AND LIABILITIES; WAIVER AND INDEMNIFICATION | |
| 189 | + | |
| 190 | + A. No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER | |
| 191 | + EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT | |
| 192 | + SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| 193 | + PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR | |
| 194 | + FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS | |
| 195 | + AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR | |
| 196 | + RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS | |
| 197 | + RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND | |
| 198 | + LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT | |
| 199 | + "AS IS." | |
| 200 | + | |
| 201 | + B. Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST GOVERNMENT AGENCY, ITS | |
| 202 | + AGENTS, EMPLOYEES, CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE | |
| 203 | + OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM | |
| 204 | + SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE | |
| 205 | + SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS GOVERNMENT AGENCY, ITS AGENTS, | |
| 206 | + EMPLOYEES, CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY | |
| 207 | + LAW. THE FOREGOING RELEASE AND INDEMNIFICATION SHALL APPLY EVEN IF THE LIABILITIES, DEMANDS, DAMAGES, | |
| 208 | + EXPENSES OR LOSSES ARE CAUSED, OCCASIONED, OR CONTRIBUTED TO BY THE NEGLIGENCE, SOLE OR CONCURRENT, OF | |
| 209 | + GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE | |
| 210 | + IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. | |
| 211 | + | |
| 212 | + 5. GENERAL TERMS | |
| 213 | + | |
| 214 | + A. Termination: This Agreement and the rights granted hereunder will terminate automatically if a | |
| 215 | + Recipient fails to comply with these terms and conditions, and fails to cure such noncompliance within | |
| 216 | + thirty (30) days of becoming aware of such noncompliance. Upon termination, a Recipient agrees to | |
| 217 | + immediately cease use and distribution of the Subject Software. All sublicenses to the Subject | |
| 218 | + Software properly granted by the breaching Recipient shall survive any such termination of this | |
| 219 | + Agreement. | |
| 220 | + | |
| 221 | + B. Severability: If any provision of this Agreement is invalid or unenforceable under applicable law, | |
| 222 | + it shall not affect the validity or enforceability of the remainder of the terms of this Agreement. | |
| 223 | + | |
| 224 | + C. Applicable Law: This Agreement shall be subject to United States federal law only for all purposes, | |
| 225 | + including, but not limited to, determining the validity of this Agreement, the meaning of its | |
| 226 | + provisions and the rights, obligations and remedies of the parties. | |
| 227 | + | |
| 228 | + D. Entire Understanding: This Agreement constitutes the entire understanding and agreement of the | |
| 229 | + parties relating to release of the Subject Software and may not be superseded, modified or amended | |
| 230 | + except by further written agreement duly executed by the parties. | |
| 231 | + | |
| 232 | + E. Binding Authority: By accepting and using the Subject Software under this Agreement, a Recipient | |
| 233 | + affirms its authority to bind the Recipient to all terms and conditions of this Agreement and that | |
| 234 | + Recipient hereby agrees to all terms and conditions herein. | |
| 235 | + | |
| 236 | + F. Point of Contact: Any Recipient contact with Government Agency is to be directed to the designated | |
| 237 | + representative as follows: J. Ritchie Carroll <mailto:jrcarrol@tva.gov>. | |
| 238 | + | |
| 239 | +*/ | |
| 240 | +#endregion | |
| 241 | + | |
| 242 | +#region [ Contributor License Agreements ] | |
| 243 | + | |
| 244 | +//****************************************************************************************************** | |
| 245 | +// | |
| 246 | +// Copyright � 2011, Grid Protection Alliance. All Rights Reserved. | |
| 247 | +// | |
| 248 | +// The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may | |
| 249 | +// not use this file except in compliance with the License. You may obtain a copy of the License at: | |
| 250 | +// | |
| 251 | +// http://www.opensource.org/licenses/eclipse-1.0.php | |
| 252 | +// | |
| 253 | +// Unless agreed to in writing, the subject software distributed under the License is distributed on an | |
| 254 | +// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the | |
| 255 | +// License for the specific language governing permissions and limitations. | |
| 256 | +// | |
| 257 | +//****************************************************************************************************** | |
| 258 | + | |
| 259 | +#endregion | |
| 260 | + | |
| 261 | +using GSF.Parsing; | |
| 262 | +using System; | |
| 263 | +using System.Collections.Generic; | |
| 264 | + | |
| 265 | +namespace GSF.Interop | |
| 266 | +{ | |
| 267 | + /// <summary> | |
| 268 | + /// Represents an old style Visual Basic array descriptor. | |
| 269 | + /// </summary> | |
| 270 | + /// <remarks> | |
| 271 | + /// This class is used to mimic the binary array descriptor used when an array is serialized | |
| 272 | + /// into a file using older Visual Basic applications (VB 6 and prior), this way old VB apps | |
| 273 | + /// can still deserialize an array stored in a file written by a .NET application and vice versa. | |
| 274 | + /// </remarks> | |
| 275 | + public class VBArrayDescriptor : ISupportBinaryImage | |
| 276 | + { | |
| 277 | + #region [ Members ] | |
| 278 | + | |
| 279 | + // Nested Types | |
| 280 | + private class DimensionDescriptor | |
| 281 | + { | |
| 282 | + public const int BinaryLength = 8; | |
| 283 | + | |
| 284 | + public int Length; | |
| 285 | + public int LowerBound; | |
| 286 | + | |
| 287 | + public DimensionDescriptor(int length, int lowerBound) | |
| 288 | + { | |
| 289 | + Length = length; | |
| 290 | + LowerBound = lowerBound; | |
| 291 | + } | |
| 292 | + } | |
| 293 | + | |
| 294 | + // Fields | |
| 295 | + private List<DimensionDescriptor> m_arrayDimensionDescriptors; | |
| 296 | + | |
| 297 | + #endregion | |
| 298 | + | |
| 299 | + #region [ Constructors ] | |
| 300 | + | |
| 301 | + /// <summary> | |
| 302 | + /// Initializes a new instance of the <see cref="VBArrayDescriptor"/> class. | |
| 303 | + /// </summary> | |
| 304 | + /// <param name="arrayLengths">Length of array per dimension.</param> | |
| 305 | + /// <param name="arrayLowerBounds">Lower bound of array per dimension.</param> | |
| 306 | + public VBArrayDescriptor(int[] arrayLengths, int[] arrayLowerBounds) | |
| 307 | + { | |
| 308 | + if (arrayLengths.Length == arrayLowerBounds.Length) | |
| 309 | + { | |
| 310 | + m_arrayDimensionDescriptors = new List<DimensionDescriptor>(); | |
| 311 | + | |
| 312 | + for (int i = 0; i < arrayLengths.Length; i++) | |
| 313 | + { | |
| 314 | + m_arrayDimensionDescriptors.Add(new DimensionDescriptor(arrayLengths[i], arrayLowerBounds[i])); | |
| 315 | + } | |
| 316 | + } | |
| 317 | + else | |
| 318 | + { | |
| 319 | + throw new ArgumentException("Number of lengths and lower bounds must be the same"); | |
| 320 | + } | |
| 321 | + } | |
| 322 | + | |
| 323 | + #endregion | |
| 324 | + | |
| 325 | + #region [ Properties ] | |
| 326 | + | |
| 327 | + /// <summary> | |
| 328 | + /// Gets the length of serialized <see cref="VBArrayDescriptor"/>. | |
| 329 | + /// </summary> | |
| 330 | + public int BinaryLength | |
| 331 | + { | |
| 332 | + get | |
| 333 | + { | |
| 334 | + return 2 + 8 * m_arrayDimensionDescriptors.Count; | |
| 335 | + } | |
| 336 | + } | |
| 337 | + | |
| 338 | + #endregion | |
| 339 | + | |
| 340 | + #region [ Methods ] | |
| 341 | + | |
| 342 | + /// <summary> | |
| 343 | + /// Generates binary image of the object and copies it into the given buffer, for <see cref="ISupportBinaryImage.BinaryLength"/> bytes. | |
| 344 | + /// </summary> | |
| 345 | + /// <param name="buffer">Buffer used to hold generated binary image of the source object.</param> | |
| 346 | + /// <param name="startIndex">0-based starting index in the <paramref name="buffer"/> to start writing.</param> | |
| 347 | + /// <returns>The number of bytes written to the <paramref name="buffer"/>.</returns> | |
| 348 | + /// <exception cref="ArgumentNullException"><paramref name="buffer"/> is null.</exception> | |
| 349 | + /// <exception cref="ArgumentOutOfRangeException"> | |
| 350 | + /// <paramref name="startIndex"/> or <see cref="ISupportBinaryImage.BinaryLength"/> is less than 0 -or- | |
| 351 | + /// <paramref name="startIndex"/> and <see cref="ISupportBinaryImage.BinaryLength"/> will exceed <paramref name="buffer"/> length. | |
| 352 | + /// </exception> | |
| 353 | + public int GenerateBinaryImage(byte[] buffer, int startIndex) | |
| 354 | + { | |
| 355 | + int length = BinaryLength; | |
| 356 | + buffer.ValidateParameters(startIndex, length); | |
| 357 | + | |
| 358 | + Buffer.BlockCopy(BitConverter.GetBytes(m_arrayDimensionDescriptors.Count), 0, buffer, startIndex, 2); | |
| 359 | + | |
| 360 | + for (int i = 0; i < m_arrayDimensionDescriptors.Count; i++) | |
| 361 | + { | |
| 362 | + Buffer.BlockCopy(BitConverter.GetBytes(m_arrayDimensionDescriptors[i].Length), 0, buffer, (i * DimensionDescriptor.BinaryLength) + 2, 4); | |
| 363 | + Buffer.BlockCopy(BitConverter.GetBytes(m_arrayDimensionDescriptors[i].LowerBound), 0, buffer, (i * DimensionDescriptor.BinaryLength) + 6, 4); | |
| 364 | + } | |
| 365 | + | |
| 366 | + return length; | |
| 367 | + } | |
| 368 | + | |
| 369 | + // Currently not supporting initialization from binary image | |
| 370 | + int ISupportBinaryImage.ParseBinaryImage(byte[] buffer, int startIndex, int length) | |
| 371 | + { | |
| 372 | + throw new NotImplementedException(); | |
| 373 | + } | |
| 374 | + | |
| 375 | + #endregion | |
| 376 | + | |
| 377 | + #region [ Static ] | |
| 378 | + | |
| 379 | + /// <summary> | |
| 380 | + /// Returns a <see cref="VBArrayDescriptor"/> object for a one dimensional array with zero-based index. | |
| 381 | + /// </summary> | |
| 382 | + /// <param name="arrayLength">Length of the array.</param> | |
| 383 | + /// <returns>A <see cref="VBArrayDescriptor"/> object.</returns> | |
| 384 | + public static VBArrayDescriptor ZeroBasedOneDimensionalArray(int arrayLength) | |
| 385 | + { | |
| 386 | + return new VBArrayDescriptor(new int[] { arrayLength }, new int[] { 0 }); | |
| 387 | + } | |
| 388 | + | |
| 389 | + /// <summary> | |
| 390 | + /// Returns a <see cref="VBArrayDescriptor"/> object for a one dimensional array with one-based index. | |
| 391 | + /// </summary> | |
| 392 | + /// <param name="arrayLength">Length of the array.</param> | |
| 393 | + /// <returns>A <see cref="VBArrayDescriptor"/> object.</returns> | |
| 394 | + public static VBArrayDescriptor OneBasedOneDimensionalArray(int arrayLength) | |
| 395 | + { | |
| 396 | + return new VBArrayDescriptor(new int[] { arrayLength }, new int[] { 1 }); | |
| 397 | + } | |
| 398 | + | |
| 399 | + /// <summary> | |
| 400 | + /// Returns a <see cref="VBArrayDescriptor"/> object for a two dimensional array with zero-based index. | |
| 401 | + /// </summary> | |
| 402 | + /// <param name="dimensionOneLength">Length of array in dimension one.</param> | |
| 403 | + /// <param name="dimensionTwoLength">Length of array in dimension two.</param> | |
| 404 | + /// <returns>A <see cref="VBArrayDescriptor"/> object.</returns> | |
| 405 | + public static VBArrayDescriptor ZeroBasedTwoDimensionalArray(int dimensionOneLength, int dimensionTwoLength) | |
| 406 | + { | |
| 407 | + return new VBArrayDescriptor(new int[] { dimensionOneLength, dimensionTwoLength }, new int[] { 0, 0 }); | |
| 408 | + } | |
| 409 | + | |
| 410 | + /// <summary> | |
| 411 | + /// Returns a <see cref="VBArrayDescriptor"/> object for a two dimensional array with one-based index. | |
| 412 | + /// </summary> | |
| 413 | + /// <param name="dimensionOneLength">Length of array in dimension one.</param> | |
| 414 | + /// <param name="dimensionTwoLength">Length of array in dimension two.</param> | |
| 415 | + /// <returns>A <see cref="VBArrayDescriptor"/> object.</returns> | |
| 416 | + public static VBArrayDescriptor OneBasedTwoDimensionalArray(int dimensionOneLength, int dimensionTwoLength) | |
| 417 | + { | |
| 418 | + return new VBArrayDescriptor(new int[] { dimensionOneLength, dimensionTwoLength }, new int[] { 1, 1 }); | |
| 419 | + } | |
| 420 | + | |
| 421 | + #endregion | |
| 422 | + } | |
| 423 | +} | |