/// <summary>
 /// Converting the data values retrieved from the rangecells to string values.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 private string[][] ToStringArray(System.Array data)
 {
     try
     {
         string[][] sArray = new string[data.GetUpperBound(0)][];
         for (int i = data.GetLowerBound(0); i <= data.GetUpperBound(0); ++i)
         {
             sArray[i - 1] = new string[data.GetUpperBound(1)];
             for (int j = data.GetLowerBound(1); j <= data.GetUpperBound(1); ++j)
             {
                 if (data.GetValue(i, j) == null)
                 {
                     sArray[i - 1][j - 1] = "-----";
                 }
                 else
                 {
                     sArray[i - 1][j - 1] = data.GetValue(i, j).ToString();
                 }
             }
         }
         return(sArray);
     }
     catch
     {
         throw (new Exception("Exception: Conversion to string array"));
     }
 }
Exemplo n.º 2
0
            public override void WriteToKernel(CallContext CallContext, int i)
            {
                //
                // Get count and size of individual array elements
                //

                long ElementCount = 1;

                for (int d = 0; d < m_Value.Rank; d++)
                {
                    ElementCount *= (m_Value.GetUpperBound(d) - m_Value.GetLowerBound(d) + 1);
                }

                //
                // Allocate memory buffer on target hardware using the appropriate type
                //

                OpenCLNet.MemFlags MemFlags;
                if (m_ForRead && !m_ForWrite)
                {
                    MemFlags = OpenCLNet.MemFlags.READ_ONLY;
                }
                else if (!m_ForRead && m_ForWrite)
                {
                    MemFlags = OpenCLNet.MemFlags.WRITE_ONLY;
                }
                else
                {
                    m_ForRead = m_ForWrite = true;
                    MemFlags  = OpenCLNet.MemFlags.READ_WRITE;
                }

                EnqueueWrite(CallContext, i, ElementCount, MemFlags);
            }
Exemplo n.º 3
0
 // The test guarantees that `a` is a 2-D array. Verifies that the intrinsics don't kick in.
 static void test3(System.Array a)
 {
     Console.WriteLine(a.Rank);
     Console.WriteLine(a.GetLength(0));
     Console.WriteLine(a.GetLength(1));
     Console.WriteLine(a.GetLowerBound(0));
     Console.WriteLine(a.GetUpperBound(0));
     Console.WriteLine(a.GetLowerBound(1));
     Console.WriteLine(a.GetUpperBound(1));
 }
Exemplo n.º 4
0
        static int test9(System.Array a)
        {
            int sum = 0;

            for (int i = a.GetLowerBound(0); i <= a.GetUpperBound(0); i++)
            {
                for (int j = a.GetLowerBound(1); j <= a.GetUpperBound(1); j++)
                {
                    sum += (int)a.GetValue(i, j);
                }
            }
            return(sum);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Read the data from the excel file and return a tuble of tasts and row numbers
        /// </summary>
        /// <param name="ExSheet"></param>
        /// <param name="startingIndex"></param>
        /// <param name="endingIndex"></param>
        /// <returns></returns>
        private Tuple <string, string>[] dataFromFile(Excel.Worksheet ExSheet, int startingIndex, int endingIndex)
        {
            Excel.Range eventRange    = ExSheet.get_Range("B" + startingIndex, "B" + endingIndex);
            Excel.Range buildingRange = ExSheet.get_Range("E" + startingIndex, "E" + endingIndex);

            System.Array eventArray    = (System.Array)eventRange.Cells.Value2;
            System.Array buildingArray = (System.Array)buildingRange.Cells.Value2;

            Tuple <string, string>[] data = new Tuple <string, string> [eventArray.Length];

            int dataCount = 0;

            for (int i = 1; i <= eventArray.GetUpperBound(0); i++)
            {
                if (eventArray.GetValue(i, 1) != null || buildingArray.GetValue(i, 1) != null)
                {
                    data[dataCount] = new Tuple <string, string>(eventArray.GetValue(i, 1).ToString(), buildingArray.GetValue(i, 1).ToString());
                    dataCount++;
                }
            }

            eventRange    = null;
            buildingRange = null;
            return(data = data.Where(x => x != null).ToArray());
        }
Exemplo n.º 6
0
        public static string ArrayToDescriptor(Array array, 
            TypeRegistry treg,
            Type type = null,
            string th = null)
        {
            if (type==null)
                 type = array.GetType();

              if (array.LongLength>MAX_ELM_COUNT)
                throw new SlimSerializationException(StringConsts.SLIM_ARRAYS_OVER_MAX_ELM_ERROR.Args(array.LongLength, MAX_ELM_COUNT));

              if (type==typeof(object[]))//special case for object[], because this type is very often used in Glue and other places
               return "$1|"+array.Length.ToString();

              if (th==null)
                 th = treg.GetTypeHandle(type);

               var ar = array.Rank;
               if (ar>MAX_DIM_COUNT)
                throw new SlimSerializationException(StringConsts.SLIM_ARRAYS_OVER_MAX_DIMS_ERROR.Args(ar, MAX_DIM_COUNT));

               var descr = new StringBuilder(th);
               descr.Append('|');//separator char

               for(int i=0; i<ar; i++)
               {
                  descr.Append(array.GetLowerBound(i));
                  descr.Append('~');
                  descr.Append(array.GetUpperBound(i));
                  if (i<ar-1)
                   descr.Append(',');
               }

              return descr.ToString();
        }
 public void CopyTo(Array array, int index)
 {
     if (this.isDisposed)
     {
         throw new ObjectDisposedException(name);
     }
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     if ((index < array.GetLowerBound(0)) || (index > array.GetUpperBound(0)))
     {
         throw new ArgumentOutOfRangeException("index");
     }
     int num = array.Length - index;
     int num2 = 0;
     ArrayList list = new ArrayList();
     ManagementObjectEnumerator enumerator = this.GetEnumerator();
     while (enumerator.MoveNext())
     {
         ManagementBaseObject current = enumerator.Current;
         list.Add(current);
         num2++;
         if (num2 > num)
         {
             throw new ArgumentException(null, "index");
         }
     }
     list.CopyTo(array, index);
 }
Exemplo n.º 8
0
           public static string ArrayToDescriptor(Array array, Type type, VarIntStr typeHandle)
           {
              if (array.LongLength>MAX_ELM_COUNT)
                throw new SlimSerializationException(StringConsts.SLIM_ARRAYS_OVER_MAX_ELM_ERROR.Args(array.LongLength, MAX_ELM_COUNT)); 
              
              if (type==typeof(object[]))//special case for object[], because this type is very often used in Glue and other places
               return "$2|"+array.Length.ToString();


              var th = typeHandle.StringValue ?? 
                      ( typeHandle.IntValue < TypeRegistry.STR_HNDL_POOL.Length ? 
                                TypeRegistry.STR_HNDL_POOL[typeHandle.IntValue] : 
                                '$'+typeHandle.IntValue.ToString() 
                      );

               var ar = array.Rank;
               if (ar>MAX_DIM_COUNT)
                throw new SlimSerializationException(StringConsts.SLIM_ARRAYS_OVER_MAX_DIMS_ERROR.Args(ar, MAX_DIM_COUNT));


               var descr = new StringBuilder();
               descr.Append( th );
               descr.Append('|');//separator char

               for(int i=0; i<ar; i++)
               {
                  descr.Append(array.GetLowerBound(i));
                  descr.Append('~');
                  descr.Append(array.GetUpperBound(i));
                  if (i<ar-1)
                   descr.Append(',');
               }
                      
              return descr.ToString();
           }
Exemplo n.º 9
0
	// Copy the contents of an array.
	public static Array CopyArray(Array arySrc, Array aryDest)
			{
				if(arySrc != null)
				{
					// Check that the arrays have the same rank and dimensions.
					int rank = arySrc.Rank;
					if(rank != aryDest.Rank)
					{
						ThrowExceptionInternal
							(new InvalidCastException
								(S._("VB_MismatchedRanks")));
					}
					for(int dim = 0; dim < rank; ++dim)
					{
						if(arySrc.GetUpperBound(dim) !=
						   aryDest.GetUpperBound(dim))
						{
							ThrowExceptionInternal
								(new ArrayTypeMismatchException
									(S._("VB_MismatchedDimensions")));
						}
					}
					Array.Copy(arySrc, aryDest, arySrc.Length);
				}
				return aryDest;
			}
Exemplo n.º 10
0
        //-------------------------------------------------------------------//
        /// <summary>
        ///     Converts COM like 2dim array where one dimension is of length 1 to regular array.
        /// </summary>
        /// <param name="a">COM array</param>
        /// <returns>regular array</returns>
        public static object[] Com2DArray2Array(Array a)
        {
            if (a == null)
                return null;

            object[] converted = null;
            switch (a.Rank)
            {
                case 1:
                    converted = new object[a.GetLength(0)];
                    for (var i = a.GetLowerBound(0); i <= a.GetUpperBound(0); i++)
                    {
                        converted[i] = a.GetValue(i);
                    }
                    break;
                case 2:
                {
                    var d1 = a.GetLength(0);
                    var d2 = a.GetLength(1);
                    var len = (d1 > d2) ? d1 : d2;
                    converted = new object[len];
                    var dim = (d1 > d2) ? 0 : 1;
                    for (var i = a.GetLowerBound(dim); i <= a.GetUpperBound(dim); i++)
                    {
                        converted[i - a.GetLowerBound(dim)] = a.GetValue((d1 == 1 ? a.GetLowerBound(0) : i),
                            (d2 == 1 ? a.GetLowerBound(1) : i));
                    }
                }
                    break;
            }

            return converted;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Asserts that each element in the first array is equal to its corresponding element in the second array.
 /// </summary>
 public static void AssertAllArrayElementsAreEqual(Array first, Array second, IComparer comparer = null)
 {
     Assert.True(first.Length == second.Length, "The two arrays are not even the same size.");
     for (int g = first.GetLowerBound(0); g < first.GetUpperBound(0); g++)
     {
         AssertArrayElementsAreEqual(first, second, g, comparer);
     }
 }
Exemplo n.º 12
0
 private static void ArrayRankInfo(String name, Array a) {
    Console.WriteLine("Number of dimensions in \"{0}\" array (of type {1}): ",
       name, a.GetType().ToString(), a.Rank);
    for (int r = 0; r < a.Rank; r++) {
       Console.WriteLine("Rank: {0}, LowerBound = {1},  UpperBound = {2}",
          r, a.GetLowerBound(r), a.GetUpperBound(r));
    }
    Console.WriteLine();
 }
 static bool IsEnd(Array array, Int32[] indexer)
 {
   for (var i = 0; i < array.Rank; ++i)
   {
     if (indexer[i] > array.GetUpperBound(i))
       return true;
   }
   return false;
 }
Exemplo n.º 14
0
 /// <summary>
 /// A Helper method to quickly convert an array object to a string array
 /// </summary>
 /// <param name="array"></param>
 /// <returns></returns>
 private string[,] covertToArray(System.Array array)
 {
     string[,] values = new string[array.GetUpperBound(0), array.GetUpperBound(1)];
     for (int i = 0; i < array.GetUpperBound(0); i++)
     {
         for (int j = 0; j < array.GetUpperBound(1); j++)
         {
             if (array.GetValue(i + 1, j + 1) == null)
             {
                 values[i, j] = "";
             }
             else
             {
                 values[i, j] = array.GetValue(i + 1, j + 1).ToString();
             }
         }
     }
     return(values);
 }
Exemplo n.º 15
0
        // General case: non-constant arguments to GetLength()/GetLowerBound()/GetUpperBound()
        static void test4(System.Array a)
        {
            int rank = a.Rank;

            Console.WriteLine(rank);
            for (int i = 0; i < rank; i++)
            {
                Console.WriteLine(a.GetLength(i));
                Console.WriteLine(a.GetLowerBound(i));
                Console.WriteLine(a.GetUpperBound(i));
            }
        }
Exemplo n.º 16
0
        ConvertToStringArray(System.Array values)
        {
            string[] newArray = new string[values.Length];
            int      index    = 0;

            for (int i = values.GetLowerBound(0); i < values.GetUpperBound(0); i++)
            {
                for (int j = values.GetLowerBound(1); j < values.GetUpperBound(1); j++)
                {
                    if (values.GetValue(i, j) == null)
                    {
                        newArray[index] = "";
                    }
                    else
                    {
                        newArray[index] = values.GetValue(i, j).ToString();
                    }
                    index++;
                }
            }
            return(newArray);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Инициализирующий конструктор.
 /// </summary>
 /// <param name="arr">Массив, индексы которого перебираются.</param>
 public ArrayIndexEnumerator(Array arr)
 {
  rank = arr.Rank;
  az = new int[rank, 2];
  index = new int[rank];
  for(int a = 0; a < rank; a++)
  {
   az[a, 0] = arr.GetLowerBound(a);
   index[a] = az[a, 0];
   az[a, 1] = arr.GetUpperBound(a);
  }
  index[rank-1]--;
 }
Exemplo n.º 18
0
        public static void ForEach(
            this System.Array array,
            Action <int[]> action)
        {
            var Rank = array.Rank;
            var Ends = new int[Rank];

            for (int i = 0; i < Rank; i++)
            {
                Ends[i] = array.GetUpperBound(i) + 1;
            }
            array.ForEach(Ends, action);
        }
Exemplo n.º 19
0
        private void LoadStrat()
        {
            //Get strategies filelist
            DirectoryInfo dir = new DirectoryInfo(Application.StartupPath + "\\strateg");

            StratFiles = (Array)dir.GetFiles("*." + Clp.RecFileExt).Clone();
            RndGen     = new Random(DateTime.Now.Second);
            if (StratFiles.GetLength(0) > 0)
            {
                OwnStrat            = null;   //((FileInfo)(StratFiles.GetValue(RndGen.Next(StratFiles.GetUpperBound(0)+1)))).FullName;
                CPUStrat            = ((FileInfo)(StratFiles.GetValue(RndGen.Next(StratFiles.GetUpperBound(0) + 1)))).FullName;
                ClpCPU.StrategyFile = CPUStrat;
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// The following implementation is based on 
 /// stackoverflow.com/questions/9914230/iterate-through-an-array-of-arbitrary-dimension/9914326#9914326
 /// </summary>
 /// <param name="array"></param>
 /// <param name="previousIndicesArray"></param>
 /// <returns></returns>
 public int[] determineNextIndicesArray(Array array, int[] previousIndicesArray)
 {
     int spaceDimension = array.Rank;
     int[] nextIndicesArray = new int[spaceDimension];
     previousIndicesArray.CopyTo(nextIndicesArray, 0);
     for (int dimIdx = spaceDimension - 1; dimIdx >= 0; --dimIdx)
     {
         nextIndicesArray[dimIdx]++;
         if (nextIndicesArray[dimIdx] <= array.GetUpperBound(dimIdx))
             return nextIndicesArray;
         nextIndicesArray[dimIdx] = array.GetLowerBound(dimIdx);
     }
     return null;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Convert a list into a human-readable string representation. The 
        /// representation used is: (0 to 2) {1, 2, 3}
        /// </summary>
        /// <param name="data">The array to process</param>
        /// <returns>A string containing the array data.</returns>
        public static string ASCIIfy(Array data)
        {
            if ( data == null )
                return "()";

            StringBuilder sb = new StringBuilder("(");

            sb.Append( String.Format( ResStrings.GetString( "ArrayLimits" ),
                                   data.GetLowerBound( 0 ),
                                   data.GetUpperBound( 0 ) ) );
            sb.Append( ASCIIfy((IList)data) );
            sb.Append( ")" );

            return sb.ToString();
        }
Exemplo n.º 22
0
 static public int GetUpperBound(IntPtr l)
 {
     try {
         System.Array self = (System.Array)checkSelf(l);
         System.Int32 a1;
         checkType(l, 2, out a1);
         var ret = self.GetUpperBound(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 23
0
 static int GetUpperBound(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         System.Array obj  = (System.Array)ToLua.CheckObject(L, 1, typeof(System.Array));
         int          arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         int          o    = obj.GetUpperBound(arg0);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 24
0
        private static void SetupLoopData(Array arr, out int rank, out int[] dimensions, out int[] lowerBounds,
                                          out int[] upperBounds)
        {
            rank = arr.Rank;
            dimensions = new int[rank];
            lowerBounds = new int[rank];
            upperBounds = new int[rank];

            for (int dimension = 0; dimension < rank; dimension++)
            {
                lowerBounds[dimension] = arr.GetLowerBound(dimension);
                upperBounds[dimension] = arr.GetUpperBound(dimension);

                //setup start values
                dimensions[dimension] = lowerBounds[dimension];
            }
        }
 public void CopyTo(Array array, int index)
 {
     IWbemQualifierSetFreeThreaded typeQualifierSet;
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     if ((index < array.GetLowerBound(0)) || (index > array.GetUpperBound(0)))
     {
         throw new ArgumentOutOfRangeException("index");
     }
     string[] pNames = null;
     try
     {
         typeQualifierSet = this.GetTypeQualifierSet();
     }
     catch (ManagementException exception)
     {
         if ((this.qualifierSetType != QualifierType.PropertyQualifier) || (exception.ErrorCode != ManagementStatus.SystemProperty))
         {
             throw;
         }
         return;
     }
     int errorCode = typeQualifierSet.GetNames_(0, out pNames);
     if (errorCode < 0)
     {
         if ((errorCode & 0xfffff000L) == 0x80041000L)
         {
             ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode);
         }
         else
         {
             Marshal.ThrowExceptionForHR(errorCode);
         }
     }
     if ((index + pNames.Length) > array.Length)
     {
         throw new ArgumentException(null, "index");
     }
     foreach (string str in pNames)
     {
         array.SetValue(new QualifierData(this.parent, this.propertyOrMethodName, str, this.qualifierSetType), index++);
     }
 }
Exemplo n.º 26
0
    public static object GetArraySlice( Array inputarray, int sliceindex )
    {
        int numoutputdimensions = inputarray.Rank - 1;
            int[] newdimensions = new int[ numoutputdimensions ];
            for( int i = 1; i < numoutputdimensions + 1; i++ )
            {
                newdimensions[ i - 1 ] = inputarray.GetUpperBound( i ) + 1;
            }
            Array newarray = Array.CreateInstance( inputarray.GetType().GetElementType(), newdimensions );

            int[]traverseinputindex = new int[ numoutputdimensions + 1 ];
            int[]traverseoutputindex = new int[ numoutputdimensions ];
            traverseinputindex[0] = sliceindex;
            bool bDone = false;
            while( !bDone )
            {
                newarray.SetValue( inputarray.GetValue( traverseinputindex ), traverseoutputindex );
                bool bUpdatedtraverseindex = false;
                for( int i = numoutputdimensions - 1; i >= 0 && !bUpdatedtraverseindex; i-- )
                {
                    traverseinputindex[i + 1]++;
                    traverseoutputindex[i]++;
                    if( traverseoutputindex[i] >= newdimensions[i] )
                    {
                        if( i == 0 )
                        {
                            bDone = true;
                        }
                        else
                        {
                            traverseinputindex[i + 1] = 0;
                            traverseoutputindex[i ] = 0;
                        }
                    }
                    else
                    {
                        bUpdatedtraverseindex = true;
                    }
                }
            }

            return newarray;
    }
Exemplo n.º 27
0
    public void WriteSystemArray(System.Array param, ES2Type type)
    {
        if (settings.encrypt)
        {
            WriteEncryptedSystemArray(param, type);
            return;
        }

        writer.Write(param.Rank);
        for (int i = 0; i < param.Rank; i++)
        {
            writer.Write(param.GetUpperBound(i));
        }

        // Write each object of array sequentially.
        foreach (System.Object obj in param)
        {
            Write(obj, type);
        }
    }
Exemplo n.º 28
0
        /// <summary>
        /// This method return how many entries we need to copy over
        /// We start from the bottom of the excel sheet and look for the first null, or when date != the date in cell
        /// </summary>
        /// <param name="ExSheet"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        private int numberOfRows(Excel.Worksheet ExSheet, string date)
        {
            Excel.Range last = ExSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing);

            int lastRow = ExSheet.UsedRange.Rows.Count;

            Excel.Range range = ExSheet.get_Range("B2", "B" + lastRow);

            int numberOfRows = 0;

            if (range.Rows.Count != 1)
            {
                //Export to array
                System.Array array = (System.Array)range.Cells.Value2;

                for (int i = array.GetUpperBound(0);
                     i >= array.GetLowerBound(0); i--)
                {
                    //This finds all number of columns that happen today.
                    if ((array.GetValue(i, 1) != null) && (array.GetValue(i, 1) is double) &&
                        (DateTime.FromOADate(double.Parse((string)array.GetValue(i, 1).ToString().Trim())).ToString("M/dd/yy").Equals(date)))
                    {
                        numberOfRows++;
                    }
                }
            }
            else
            {
                //We just have one element in the array so we check if its in the time period.
                if ((range.Value2 != null) && (range.Value2 is double) &&
                    (DateTime.FromOADate(double.Parse((string)range.Value2.ToString().Trim())).ToString("M/dd/yy").Equals(date)))
                {
                    numberOfRows++;
                }
            }

            last  = null;
            range = null;

            return(numberOfRows);
        }
Exemplo n.º 29
0
        private static bool TryGetRankDiff(Array x, Array y, out RankDiff rankDiff)
        {
            if (x.Length != y.Length || x.Rank != y.Rank)
            {
                rankDiff = new RankDiff(x, y);
                return true;
            }

            for (var i = 0; i < x.Rank; i++)
            {
                if (x.GetLowerBound(i) != y.GetLowerBound(i) ||
                    x.GetUpperBound(i) != y.GetUpperBound(i))
                {
                    rankDiff = new RankDiff(x, y);
                    return true;
                }
            }

            rankDiff = null;
            return false;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Returns the number of elements, rows, or columns in an array. Implements the optional
        /// parameter for number of rows for columns
        /// <pre>
        /// Example:
        /// VFPToolkit.arrays.ALen(MyArr, 1);
        /// </pre>
        /// </summary>
        public static int ALen(System.Array aArray, int nArrayAttribute)
        {
            //switch based on the value of nArrayAttribute
            switch (nArrayAttribute)
            {
            case 1:
            {
                //Return the number of rows in the array
                //return (aArray.Length / aArray.Rank);
                return(aArray.GetUpperBound(0) + 1);
            }

            case 2:
            {
                //Return the number of columns
                return(aArray.Rank);
            }

            default:
            {
                return(aArray.Length);
            }
            }
        }
Exemplo n.º 31
0
        private bool LoadArray(ref System.Array AnArray, short CanonDT, ref string wrTxt)
        {
            int ii;
            int loc;
            int Wlen;
            int start;

            try
            {
                start = 1;
                Wlen  = wrTxt.Length;
                for (ii = AnArray.GetLowerBound(0); (ii <= AnArray.GetUpperBound(0)); ii++)
                {
                    loc = (wrTxt.IndexOf(",", (start - 1)) + 1);
                    if ((ii < AnArray.GetUpperBound(0)))
                    {
                        if ((loc == 0))
                        {
                            MessageBox.Show("Write Value: Incorrect Number of Items for Array Size?", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return(false);
                        }
                    }
                    else
                    {
                        loc = (Wlen + 1);
                    }
                    switch ((CanonicalDataTypes)CanonDT)
                    {
                    case CanonicalDataTypes.CanonDtByte:
                        AnArray.SetValue(Convert.ToByte(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtChar:
                        AnArray.SetValue(Convert.ToSByte(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtWord:
                        AnArray.SetValue(Convert.ToUInt16(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtShort:
                        AnArray.SetValue(Convert.ToInt16(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtDWord:
                        AnArray.SetValue(Convert.ToUInt32(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtLong:
                        AnArray.SetValue(Convert.ToInt32(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtFloat:
                        AnArray.SetValue(Convert.ToSingle(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtDouble:
                        AnArray.SetValue(Convert.ToDouble(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtBool:
                        AnArray.SetValue(Convert.ToBoolean(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    case CanonicalDataTypes.CanonDtString:
                        AnArray.SetValue(Convert.ToString(wrTxt.Substring((start - 1), (loc - start))), ii);
                        //  End case
                        break;

                    default:
                        MessageBox.Show("Write Value Unknown data type", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);

                        break;
                    }
                    start = (loc + 1);
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(("Write Value generated Exception: " + ex.Message), "SimpleOPCInterface Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
        }
Exemplo n.º 32
0
    public void OnCmd(ref EdmCmd poCmd, ref System.Array ppoData)
    {
        //Handle the hook
        string name = null;

        switch (poCmd.meCmdType)
        {
        case EdmCmdType.EdmCmd_PreState:
            name = "PreState";
            break;

        case EdmCmdType.EdmCmd_PostAdd:
            name = "PostAdd";
            break;

        case EdmCmdType.EdmCmd_PostLock:
            name = "PostLock";
            break;

        case EdmCmdType.EdmCmd_PreUnlock:
            name = "PreUnlock";
            break;

        case EdmCmdType.EdmCmd_PostUnlock:
            name = "PostUnlock";
            break;

        default:
            name = "?";
            break;
        }



        string message = null;

        message = "sasasa";
        int index = 0;

        // index = Information.LBound(ppoData);
        index = ppoData.GetLowerBound(0);
        int last = 0;

        //last = Information.UBound(ppoData);
        last = ppoData.GetUpperBound(0);

        //Append the paths of all files to a message string
        while (index <= last)
        {
            message = message + ((EdmCmdData)(ppoData.GetValue(index))).mbsStrData1 + Environment.NewLine;//Constants.vbLf;
            index   = index + 1;
        }

        //Display a message to the user
        message = "The following files were affected by a " + name + " hook:" + Environment.NewLine /*Constants.vbLf */ + message;

        EdmVault5 vault = default(EdmVault5);

        vault = (EdmVault5)poCmd.mpoVault;
        vault.MsgBox(poCmd.mlParentWnd, message);



        if (poCmd.meCmdType == EdmCmdType.EdmCmd_Menu)
        {
            if (poCmd.mlCmdID == 1)
            {
                System.Windows.Forms.MessageBox.Show("C# Add-in");
            }
        }
    }
        private void SerializeMultidimensionalArray(JsonWriter writer, Array values, JsonArrayContract contract, JsonProperty member, int initialDepth, int[] indices)
        {
            int dimension = indices.Length;
            int[] newIndices = new int[dimension + 1];
            for (int i = 0; i < dimension; i++)
            {
                newIndices[i] = indices[i];
            }

            writer.WriteStartArray();

            for (int i = values.GetLowerBound(dimension); i <= values.GetUpperBound(dimension); i++)
            {
                newIndices[dimension] = i;
                bool isTopLevel = (newIndices.Length == values.Rank);

                if (isTopLevel)
                {
                    object value = values.GetValue(newIndices);

                    try
                    {
                        JsonContract valueContract = contract.FinalItemContract ?? GetContractSafe(value);

                        if (ShouldWriteReference(value, null, valueContract, contract, member))
                        {
                            WriteReference(writer, value);
                        }
                        else
                        {
                            if (CheckForCircularReference(writer, value, null, valueContract, contract, member))
                            {
                                SerializeValue(writer, value, valueContract, null, contract, member);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (IsErrorHandled(values, contract, i, null, writer.ContainerPath, ex))
                        {
                            HandleError(writer, initialDepth + 1);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
                else
                {
                    SerializeMultidimensionalArray(writer, values, contract, member, initialDepth + 1, newIndices);
                }
            }

            writer.WriteEndArray();
        }
Exemplo n.º 34
0
 /// <summary>
 /// To check whether an index is in the range of the given array.
 /// </summary>
 /// <param name="index">Index to check</param>
 /// <param name="arrayToCheck">Array where to check</param>
 /// <returns></returns>
 /// <remarks>
 /// 	Contributed by Mohammad Rahman, http://mohammad-rahman.blogspot.com/
 /// </remarks>
 public static bool IsIndexInArray(this int index, Array arrayToCheck)
 {
     return index.GetArrayIndex().InRange(arrayToCheck.GetLowerBound(0), arrayToCheck.GetUpperBound(0));
 }
Exemplo n.º 35
0
        private int findRegion(int inValue, int newValue, int noDataValue, System.Array inArr, System.Array outArr, List <string> columnrow, List <int>[] nextArray)
        {
            int    permEdges = 0;
            string ccr       = columnrow[0];

            string[] ccrArr = ccr.Split(new char[] { ':' });
            int      clm    = System.Convert.ToInt32(ccrArr[0]);
            int      rw     = System.Convert.ToInt32(ccrArr[1]);
            int      maxC   = outArr.GetUpperBound(0);
            int      maxR   = outArr.GetUpperBound(1);
            int      minCR  = 0;

            for (int i = 0; i < 4; i++)
            {
                int cPlus = clm;
                int rPlus = rw;
                switch (i)
                {
                case 0:
                    cPlus += 1;
                    break;

                case 1:
                    rPlus += 1;
                    break;

                case 2:
                    cPlus -= 1;
                    break;

                default:
                    rPlus -= 1;
                    break;
                }
                int  pVl           = System.Convert.ToInt32(inArr.GetValue(cPlus + 1, rPlus + 1));
                bool inValueCheck  = (pVl == inValue);
                bool rPlusMinCheck = (rPlus < minCR);
                bool rPlusMaxCheck = (rPlus > maxR);
                bool cPlusMinCheck = (cPlus < minCR);
                bool cPlusMaxCheck = (cPlus > maxC);
                if ((rPlusMinCheck || rPlusMaxCheck || cPlusMinCheck || cPlusMaxCheck))
                {
                    if (inValueCheck)
                    {
                        if (rPlusMinCheck)
                        {
                            nextArray[0].Add(cPlus);
                        }
                        else if (rPlusMaxCheck)
                        {
                            nextArray[1].Add(cPlus);
                        }
                        if (cPlusMinCheck)
                        {
                            nextArray[2].Add(rPlus);
                        }
                        if (cPlusMaxCheck)
                        {
                            nextArray[3].Add(rPlus);
                        }
                    }
                }
                else
                {
                    //try
                    //{
                    string cr = cPlus.ToString() + ":" + rPlus.ToString();
                    //Console.WriteLine(cr);
                    int cVl = System.Convert.ToInt32(outArr.GetValue(cPlus, rPlus));
                    if (cVl == noDataValue)
                    {
                        if (inValueCheck)
                        {
                            try
                            {
                                outArr.SetValue(newValue, cPlus, rPlus);
                                if (!columnrow.Contains(cr))
                                {
                                    columnrow.Add(cr);
                                }
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            permEdges++;
                        }
                    }
                    else
                    {
                    }
                    //}
                    //catch (Exception e)
                    //{
                    //    Console.WriteLine(e.ToString());
                    //}
                }
                //try
                //{
                columnrow.Remove(ccr);
                //}
                //catch (Exception e)
                //{
                //    Console.WriteLine(e.ToString());
                //    columnrow.Clear();
                //}
            }
            return(permEdges);
        }
Exemplo n.º 36
0
        /// <summary>
        /// Modifies the specified array by applying the specified function to each element.
        /// </summary>
        /// <param name="a"></param>
        /// <param name="func">object delegate(object o){}</param>
        /// <returns></returns>
        public static void ForEach(Array a, ForEachFunction func)
        {
            long[] ix = new long[a.Rank];
            //Init index
            for (int i = 0; i < ix.Length; i++) ix[i] = a.GetLowerBound(i);

            //Loop through all items
            for (long i = 0; i < a.LongLength; i++)
            {
                a.SetValue(func(a.GetValue(ix)), ix);

                //Increment ix, the index
                for (int j = 0; j < ix.Length; j++)
                {
                    if (ix[j] < a.GetUpperBound(j))
                    {
                        ix[j]++;
                        break; //We're done incrementing.
                    }
                    else
                    {
                        //Ok, reset this one and increment the next.
                        ix[j] = a.GetLowerBound(j);
                        //If this is the last dimension, assert
                        //that we are at the last element
                        if (j == ix.Length - 1)
                        {
                            if (i < a.LongLength - 1) throw new Exception();
                        }
                        continue;
                    }
                }
            }
            return;
        }
Exemplo n.º 37
0
		public void CopyTo(Array array, int index)
		{
			IWbemQualifierSetFreeThreaded typeQualifierSet;
			if (array != null)
			{
				if (index < array.GetLowerBound(0) || index > array.GetUpperBound(0))
				{
					throw new ArgumentOutOfRangeException("index");
				}
				else
				{
					string[] strArrays = null;
					try
					{
						typeQualifierSet = this.GetTypeQualifierSet();
					}
					catch (ManagementException managementException1)
					{
						ManagementException managementException = managementException1;
						if (this.qualifierSetType != QualifierType.PropertyQualifier || managementException.ErrorCode != ManagementStatus.SystemProperty)
						{
							throw;
						}
						else
						{
							return;
						}
					}
					int names_ = typeQualifierSet.GetNames_(0, out strArrays);
					if (names_ < 0)
					{
						if (((long)names_ & (long)-4096) != (long)-2147217408)
						{
							Marshal.ThrowExceptionForHR(names_);
						}
						else
						{
							ManagementException.ThrowWithExtendedInfo((ManagementStatus)names_);
						}
					}
					if (index + (int)strArrays.Length <= array.Length)
					{
						string[] strArrays1 = strArrays;
						for (int i = 0; i < (int)strArrays1.Length; i++)
						{
							string str = strArrays1[i];
							int num = index;
							index = num + 1;
							array.SetValue(new QualifierData(this.parent, this.propertyOrMethodName, str, this.qualifierSetType), num);
						}
					}
					else
					{
						throw new ArgumentException(null, "index");
					}
					return;
				}
			}
			else
			{
				throw new ArgumentNullException("array");
			}
		}
Exemplo n.º 38
0
        /// <summary>
        ///  This method creates a 2d array of all the events for today for the master log
        /// </summary>
        /// <param name="ExSheet"></param>
        /// <returns></returns>
        private string[,] ConvertToStringArray2D(Excel.Worksheet ExSheet)
        {
            int      offset       = 0;
            DateTime startingTime = Convert.ToDateTime(this.startTime.ToString());
            DateTime endingTime   = Convert.ToDateTime(this.endTime.ToString());

            //initialization of all the ranges that we are going to collect.
            Excel.Range last = ExSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing);

            //Delete any empty rows at the end of the range if any (THIS IS DUE TO O
            while ((ExSheet.Cells[last.Row - offset, 1] as Excel.Range).Value2 == null)
            {
                offset++;
            }

            int start = last.Row - offset - this.numberOfRows(ExSheet, this.getLastDate());

            Excel.Range rangeA = ExSheet.get_Range("A" + start, "A" + (last.Row - offset));
            Excel.Range rangeB = ExSheet.get_Range("B" + start, "B" + (last.Row - offset));
            Excel.Range rangeC = ExSheet.get_Range("C" + start, "C" + (last.Row - offset));
            Excel.Range rangeD = ExSheet.get_Range("D" + start, "D" + (last.Row - offset));
            Excel.Range rangeE = ExSheet.get_Range("E" + start, "E" + (last.Row - offset));
            Excel.Range rangeF = ExSheet.get_Range("F" + start, "F" + (last.Row - offset));

            string[,] values = new string[((last.Row - offset) - start) + 1, 6];

            //If the range is not just one element we make arrays out of them
            //And get upper bound is greater than 0 (Avoid the array out of bounds)
            if (rangeA.Rows.Count != 1 && values.GetUpperBound(0) > 0)
            {
                //Convert all the ranges to a 1d array.
                System.Array arrayA = (System.Array)rangeA.Cells.Value2;
                System.Array arrayB = (System.Array)rangeB.Cells.Value2;
                System.Array arrayC = (System.Array)rangeC.Cells.Value2;
                System.Array arrayD = (System.Array)rangeD.Cells.Value2;
                System.Array arrayE = (System.Array)rangeE.Cells.Value2;
                System.Array arrayF = (System.Array)rangeF.Cells.Value2;

                //Add all the values from the arrays to a 2d array of strings,
                int index = 0;
                for (int i = 0; i < arrayA.GetUpperBound(0); i++)
                {
                    //Only going to get the events that are not Crestron Logout and account for R N102
                    if ((arrayA.GetValue(i + 1, 1) != null) && (arrayC.GetValue(i + 1, 1) != null) && !(arrayA.GetValue(i + 1, 1).Equals("Crestron Logout")))
                    {
                        //Check if the event is between the selected times
                        DateTime check = DateTime.ParseExact(arrayC.GetValue(i + 1, 1).ToString().Trim(), "HHmm", null);
                        if ((check.TimeOfDay >= startingTime.TimeOfDay) && (check.TimeOfDay < endingTime.TimeOfDay))
                        {
                            //If we get an AV shutdown. See if we have it in our logout master first
                            if (arrayA.GetValue(i + 1, 1).Equals("AV Shutdown"))
                            {
                                //A string we will use to compare too
                                string buildingandRoomCompareString = arrayD.GetValue(i + 1, 1).ToString() + " " + arrayE.GetValue(i + 1, 1).ToString();

                                //The case of R N102 has special instructions
                                if (arrayD.GetValue(i + 1, 1).Equals("R") && arrayE.GetValue(i + 1, 1).Equals("N102"))
                                {
                                    //If fount in the logout master
                                    if (buildingAndRooms.Contains(buildingandRoomCompareString))
                                    {
                                        int indexOf = buildingAndRooms.IndexOf(buildingandRoomCompareString);
                                        this.ArrayClassRooms[indexOf, 3] = arrayF.GetValue(i + 1, 1).ToString() + @" Lock upper cinema doors (2) with allen key by releasing the crash bar.Pull side stage door shut from the inside.Make sure the stage lights at the front are off.Make sure the projector room is not open.Make sure the cinema lights are off, switched across from the projector room. Make sure the keyboard is on top of all the equipment in the drawer.";
                                    }
                                    //If not add it in normally
                                    else
                                    {
                                        //Tasks type
                                        values[index, 0] = arrayA.GetValue(i + 1, 1).ToString();
                                        //Date
                                        values[index, 1] = DateTime.FromOADate(double.Parse((string)arrayB.GetValue(i + 1, 1).ToString())).ToString("M/dd/yy");
                                        //Time
                                        values[index, 2] = arrayC.GetValue(i + 1, 1).ToString();
                                        //Building
                                        values[index, 3] = arrayD.GetValue(i + 1, 1).ToString();
                                        //Room
                                        values[index, 4] = arrayE.GetValue(i + 1, 1).ToString();

                                        //Comment, add a space if no comment is present
                                        if (arrayF.GetValue(i + 1, 1) == null)
                                        {
                                            values[index, 5] = "";
                                        }
                                        else if (arrayD.GetValue(i + 1, 1).Equals("R") && arrayE.GetValue(i + 1, 1).Equals("N102") && arrayA.GetValue(i + 1, 1).Equals("AV Shutdown"))
                                        {
                                            values[index, 5] = arrayF.GetValue(i + 1, 1).ToString() + @" Lock upper cinema doors (2) with allen key by releasing the crash bar.Pull side stage door shut from the inside.Make sure the stage lights at the front are off.Make sure the projector room is not open.Make sure the cinema lights are off, switched across from the projector room.";
                                        }
                                        else
                                        {
                                            values[index, 5] = arrayF.GetValue(i + 1, 1).ToString();
                                        }
                                        index++;
                                    }
                                }
                                //Any other buildings and rooms that are in the logout master just add the Zone Supers comments
                                else if (buildingAndRooms.Contains(buildingandRoomCompareString))
                                {
                                    int indexOf = buildingAndRooms.IndexOf(buildingandRoomCompareString);
                                    //Account if there is nothing in the Comments
                                    if (arrayF.GetValue(i + 1, 1) != null)
                                    {
                                        this.ArrayClassRooms[indexOf, 3] = arrayF.GetValue(i + 1, 1).ToString();
                                    }
                                    else
                                    {
                                        this.ArrayClassRooms[indexOf, 3] = this.ArrayClassRooms[indexOf, 3];
                                    }
                                }
                                else
                                {
                                    //Tasks type
                                    values[index, 0] = arrayA.GetValue(i + 1, 1).ToString();
                                    //Date
                                    values[index, 1] = DateTime.FromOADate(double.Parse((string)arrayB.GetValue(i + 1, 1).ToString())).ToString("M/dd/yy");
                                    //Time
                                    values[index, 2] = arrayC.GetValue(i + 1, 1).ToString();
                                    //Building
                                    values[index, 3] = arrayD.GetValue(i + 1, 1).ToString();
                                    //Room
                                    values[index, 4] = arrayE.GetValue(i + 1, 1).ToString();

                                    //Comment, add a space if no comment is present
                                    if (arrayF.GetValue(i + 1, 1) == null)
                                    {
                                        values[index, 5] = "";
                                    }
                                    else
                                    {
                                        values[index, 5] = arrayF.GetValue(i + 1, 1).ToString();
                                    }
                                    index++;
                                }
                            }
                            else
                            {
                                //Tasks type
                                values[index, 0] = arrayA.GetValue(i + 1, 1).ToString();
                                //Date
                                values[index, 1] = DateTime.FromOADate(double.Parse((string)arrayB.GetValue(i + 1, 1).ToString())).ToString("M/dd/yy");
                                //Time
                                values[index, 2] = arrayC.GetValue(i + 1, 1).ToString();
                                //Building
                                values[index, 3] = arrayD.GetValue(i + 1, 1).ToString();
                                //Room
                                values[index, 4] = arrayE.GetValue(i + 1, 1).ToString();

                                //Comment, add a space if no comment is present
                                if (arrayF.GetValue(i + 1, 1) == null && arrayA.GetValue(i + 1, 1).ToString().Trim().Equals("Demo"))
                                {
                                    values[index, 5] = "Arrive 10 minutes early. Ensure that the instructor does not require further assistance before you leave.";
                                }
                                else if (arrayF.GetValue(i + 1, 1) != null && arrayA.GetValue(i + 1, 1).ToString().Trim().Equals("Demo"))
                                {
                                    values[index, 5] = arrayF.GetValue(i + 1, 1).ToString() +
                                                       " Arrive 10 minutes early. Ensure that the instructor does not require further assistance before you leave.";
                                }
                                else if (arrayF.GetValue(i + 1, 1) == null)
                                {
                                    values[index, 5] = "";
                                }
                                else
                                {
                                    values[index, 5] = arrayF.GetValue(i + 1, 1).ToString();
                                }
                                index++;
                            }
                        }
                    }
                }
            }
            //Else the array is one element so we add only that one element to output
            //get upper bound is greater than 0 (Avoid the array out of bounds)
            else if (values.GetUpperBound(0) > 0)
            {
                DateTime check = DateTime.ParseExact(rangeC.Cells.Value2.ToString(), "HHmm", null);
                if ((check.TimeOfDay >= startingTime.TimeOfDay) && (check.TimeOfDay <= endingTime.TimeOfDay))
                {
                    values[0, 0] = rangeA.Cells.Value2.ToString();
                    //Date
                    values[0, 1] = DateTime.FromOADate(double.Parse((string)rangeB.Cells.Value2.ToString())).ToString("M/dd/yy");
                    //Time
                    values[0, 2] = rangeC.Cells.Value2.ToString();
                    //Building
                    values[0, 3] = rangeD.Cells.Value2.ToString();
                    //Room
                    values[0, 4] = rangeE.Cells.Value2.ToString();

                    //Comment, add a space if no comment is present
                    if (rangeF.Cells.Value2 == null)
                    {
                        values[0, 5] = "";
                    }
                    else
                    {
                        values[0, 5] = rangeF.Cells.Value2.ToString();
                    }
                }
            }

            //Clean up
            last   = null;
            rangeA = null;
            rangeB = null;
            rangeC = null;
            rangeD = null;
            rangeE = null;
            rangeF = null;

            //Remove all null/empty rows
            string[,] temp = RemoveEmptyRows(values);
            return(temp);
        }
Exemplo n.º 39
0
    /*
     * origin: location start to work with
     * tensorField: entire tensorField working with, i.e. numpy 4d matrix from nrrd
     * internalKeeping: true location without rounding
     * return: a list of locations in image
     */
    List <Vector3Int> traceBrain(Vector3Int origin, System.Array tensorField, Vector3 internalKeeping)
    {
        int xDim = tensorField.GetUpperBound(0);
        int yDim = tensorField.GetUpperBound(1);
        int zDim = tensorField.GetUpperBound(2);

        if (pos.x <= xDim && pos.y <= yDim && pos.z <= zDim)
        {
            List <float> subArr = new List <float>();
            for (int t = 0; t < vecLength; t++)
            {
                long tmp = (long)tensorField.GetValue((int)pos.x, (int)pos.y, (int)pos.z, t);
                subArr.Add((float)(tmp / magnification));
            }

            List <Vector3> vectors = new List <Vector3>();
            list2vector(subArr, vectors);
            //find longest vector
            float   maxMag     = -1;
            Vector3 major      = new Vector3();
            int     maxCounter = 1;
            foreach (Vector3 i in vectors)
            {
                float tmp = i.magnitude;
                if (tmp > maxMag)
                {
                    maxMag     = tmp;
                    major      = i;
                    maxCounter = 1;
                }
                else if (tmp == maxMag)
                {
                    maxCounter += 1;
                }
            }

            // empty voxel
            if (maxMag == 0)
            {
                return(new List <Vector3Int>());
            }

            // no major
            if (maxCounter == 3)
            {
                return(new List <Vector3Int>());
            }
            //Question: how to proceed to next location? What should be the length of each vector?

            //find next location and invoke transBrain recursively
            Vector3 nextVoxel = internalKeeping;
            nextVoxel.x = nextVoxel.x + (float)(major.x * step);
            nextVoxel.y = nextVoxel.y + (float)(major.y * step);
            nextVoxel.z = nextVoxel.z + (float)(major.z * step);
            Vector3Int externalVoxel = new Vector3Int((int)(nextVoxel.x), (int)(nextVoxel.y), (int)(nextVoxel.z));
            //get result from recursion and add current location AT FRONT
            if (externalVoxel.Equals(origin))
            {
                return(traceBrain(externalVoxel, tensorField, nextVoxel));
            }
            else
            {
                var result = traceBrain(externalVoxel, tensorField, nextVoxel);
                result.Insert(0, externalVoxel);
                return(result);
            }
        }
        else
        {
            return(new List <Vector3Int>());
        }
    }
Exemplo n.º 40
0
        private void ImportPipeComponentSheet(Array sheetValues, Worksheet worksheet, List<CellValue> cellValues)
        {
            try
            {
                RaiseMessage(MessageType.Added, "----------------------------------");
                RaiseMessage(MessageType.Added, string.Format("Importing Sheet '{0}'.", worksheet.Name));
                RaiseMessage(MessageType.Added, "----------------------------------");


                int tagNameIndex = cellValues.Where(x => x.ExpectedValue == mTagNumberCellName).FirstOrDefault().Y;
                int lineNumberIndex = cellValues.Where(x => x.ExpectedValue == mLineNumberCellName).FirstOrDefault().Y;
                int pandIdIndex = cellValues.Where(x => x.ExpectedValue == mPandIDCellName).FirstOrDefault().Y;

                int emptyPipesCount = 0;
                int rowCount = sheetValues.GetUpperBound(0);
                int columnCount = sheetValues.GetUpperBound(1);

                int firstRowIndex = cellValues.Where(x => x.ExpectedValue == mPandIDCellName).FirstOrDefault().X + 1;

                //Get Property Names and their column indexes
                Dictionary<string, int> propertyPositions = new Dictionary<string, int>();
                for (int colIndex = pandIdIndex + 1; colIndex <= columnCount; colIndex++)
                {
                    string propertyName = sheetValues.GetValue(firstRowIndex, colIndex) == null ? string.Empty : sheetValues.GetValue(firstRowIndex, colIndex).ToString();

                    if (!string.IsNullOrEmpty(propertyName))
                    {
                        var property = (from x in mExistingPipeComponentProperties where x.Name.ToLower() == propertyName.Trim().ToLower() select x).FirstOrDefault();

                        if (property != null)
                        {
                            if (!propertyPositions.ContainsKey(property.Name))
                            {
                                propertyPositions.Add(property.Name, colIndex);
                            }
                            else
                            {
                                RaiseMessage(MessageType.Warning, string.Format("WorkSheet '{0}': Found duplicate property names '{1}'. Skipping Worksheet.", worksheet.Name, propertyName));
                            }
                        }
                        else
                        {
                            RaiseMessage(MessageType.Error, string.Format("WorkSheet '{0}': Property name '{1}' will be skipped as it does not exist in the Database.", worksheet.Name, propertyName));
                        }
                    }
                }

                for (int rowIndex = firstRowIndex; rowIndex <= rowCount; rowIndex++)
                {
                    PipeComponent newPipeComponent = new PipeComponent();

                    string lineNumber = sheetValues.GetValue(rowIndex, lineNumberIndex) == null ? string.Empty : sheetValues.GetValue(rowIndex, lineNumberIndex).ToString();
                    string tagNumber = sheetValues.GetValue(rowIndex, lineNumberIndex) == null ? string.Empty : sheetValues.GetValue(rowIndex, tagNameIndex).ToString();
                    string drawing = sheetValues.GetValue(rowIndex, pandIdIndex) == null ? string.Empty : sheetValues.GetValue(rowIndex, pandIdIndex).ToString();


                    LineNumberParser lineNumberParser = new LineNumberParser(lineNumber);
                    if (!lineNumberParser.IsValid())
                    {
                        string msg = string.Format("Worksheet {0}, Row {1} :  Pipe Number Format '{2}'.  Reason: {3}", worksheet.Name, rowIndex, tagNumber, lineNumberParser.ErrorMessage);
                        RaiseMessage(MessageType.Error, msg);

                        continue;
                    }

                    TagNumberParser tagNumberParser = new TagNumberParser(tagNumber);
                    if (!tagNumberParser.IsValid())
                    {
                        string msg = string.Format("Worksheet {0}, Row {1} :  Invalid Tag Number Format '{2}'.  Reason: {3}", worksheet.Name, rowIndex, tagNumber, tagNumberParser.ErrorMessage);
                        RaiseMessage(MessageType.Error, msg);
                        continue;
                    }


                    if (GetPipe(worksheet, lineNumberParser, newPipeComponent, rowIndex))
                    {
                        emptyPipesCount++;
                        if (emptyPipesCount == 3)
                        {
                            RaiseMessage(MessageType.Warning, string.Format("WorkSheet '{0}' Line '{1}': Found 3 empty Pipes. Continuing on to next Sheet.", worksheet.Name, rowIndex));
                            break;
                        }

                        continue;
                    }


                    GetDrawing(worksheet, drawing, newPipeComponent, rowIndex);

                    AttachComponentProperties(worksheet, propertyPositions, sheetValues, newPipeComponent, rowIndex);

                    //SAVE
                    SavePipeComponent(worksheet, tagNumberParser, newPipeComponent, rowIndex);
                }

                RaiseMessage(MessageType.Added, string.Format("Finished importing Sheet '{0}'.", worksheet.Name));
            }
            catch (Exception ex)
            {
                RaiseMessage(MessageType.Error, string.Format("Error occured: {0}", ex.Message));
                RaiseMessage(MessageType.Error, string.Format("Error Stack trace: {0}", ex.StackTrace));
            }

            RaiseMessage(MessageType.Added, "Finished Job");
        }
Exemplo n.º 41
0
 private static void WriteArray(MemoryStream stream, Array a, Hashtable ht, ref int hv, Encoding encoding)
 {
     if (a.Rank == 1)
     {
         int len = a.GetLength(0);
         byte[] alen = Encoding.ASCII.GetBytes(len.ToString());
         int lb = a.GetLowerBound(0);
         int ub = a.GetUpperBound(0);
         stream.WriteByte(__a);
         stream.WriteByte(__Colon);
         stream.Write(alen, 0, alen.Length);
         stream.WriteByte(__Colon);
         stream.WriteByte(__LeftB);
         for (int i = lb; i <= ub; i++)
         {
             WriteInteger(stream, Encoding.ASCII.GetBytes(i.ToString()));
             Serialize(stream, a.GetValue(i), ht, ref hv, encoding);
         }
         stream.WriteByte(__RightB);
     }
     else
     {
         WriteArray(stream, a, new int[] { 0 }, ht, ref hv, encoding);
     }
 }
            private void FormatMultidimensionalArray(Builder result, Array array, bool inline)
            {
                Debug.Assert(array.Rank > 1);

                if (array.Length == 0)
                {
                    result.AppendCollectionItemSeparator(isFirst: true, inline: true);
                    result.AppendGroupOpening();
                    result.AppendGroupClosing(inline: true);
                    return;
                }

                int[] indices = new int[array.Rank];
                for (int i = array.Rank - 1; i >= 0; i--)
                {
                    indices[i] = array.GetLowerBound(i);
                }

                int nesting = 0;
                int flatIndex = 0;
                while (true)
                {
                    // increment indices (lower index overflows to higher):
                    int i = indices.Length - 1;
                    while (indices[i] > array.GetUpperBound(i))
                    {
                        indices[i] = array.GetLowerBound(i);
                        result.AppendGroupClosing(inline: inline || nesting != 1);
                        nesting--;

                        i--;
                        if (i < 0)
                        {
                            return;
                        }

                        indices[i]++;
                    }

                    result.AppendCollectionItemSeparator(isFirst: flatIndex == 0, inline: inline || nesting != 1);

                    i = indices.Length - 1;
                    while (i >= 0 && indices[i] == array.GetLowerBound(i))
                    {
                        result.AppendGroupOpening();
                        nesting++;

                        // array isn't empty, so there is always an element following this separator
                        result.AppendCollectionItemSeparator(isFirst: true, inline: inline || nesting != 1);

                        i--;
                    }

                    string name;
                    FormatObjectRecursive(result, array.GetValue(indices), quoteStrings: true, memberFormat: MemberDisplayFormat.InlineValue, name: out name);

                    indices[indices.Length - 1]++;
                    flatIndex++;
                }
            }
 public static bool IsWithinIndex <T>(this T[] @this, int index, int dimension)
 {
     return(@this.GetLowerBound(dimension) <= index && @this.GetUpperBound(dimension) < index);
 }
Exemplo n.º 44
0
 void WriteMultiDimensionalArray(WriteJsonValue m, Array md)
 {
     var r = md.Rank;
     var lb = new int[r];
     var ub = new int[r];
     var mdi = new int[r];
     for (int i = 0; i < r; i++) {
         lb[i] = md.GetLowerBound (i);
         ub[i] = md.GetUpperBound (i) + 1;
     }
     Array.Copy (lb, 0, mdi, 0, r);
     WriteMultiDimensionalArray (m, md, r, lb, ub, mdi, 0);
 }
Exemplo n.º 45
0
        public static int IndexOf([Pure] Array array, object value, int startIndex)
        {
            Contract.Requires(array != null);
            // Contract.Requires(array.Rank == 1);
            Contract.Requires(startIndex >= array.GetLowerBound(0));
            Contract.Requires(startIndex <= array.GetLowerBound(0) + array.Length);
            Contract.Ensures(Contract.Result <int>() == array.GetLowerBound(0) - 1 || (startIndex <= Contract.Result <int>() && Contract.Result <int>() <= array.GetUpperBound(0)));

            return(default(int));
        }
Exemplo n.º 46
0
 ///<summary>
 ///	检测索引是否在数组的范围之内
 ///</summary>
 ///<param name = "source">源数组</param>
 ///<param name = "index">检查的索引</param>
 ///<param name="dimension">检查的维度</param>
 ///<returns><c>true</c> 表示有效,<c>false</c> 表示索引超过范围</returns>
 public static bool WithinIndex(this Array source, int index, int dimension)
 {
     return(source != null && index >= source.GetLowerBound(dimension) && index <= source.GetUpperBound(dimension));
 }
Exemplo n.º 47
0
        /// <summary>
        /// The main form load event all the work will happen here
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LogViewer_Load(object sender, EventArgs e)
        {
            if (this.shiftNumber == 1)
            {
                this.previousBTN.Enabled = false;
            }

            if (this.shiftNumber == this.numberOfShifts)
            {
                this.nextBTN.Text = "Done";
            }

            //Set the labels
            this.startTextBox.Text      = this.startTime;
            this.endTextBox.Text        = this.endTime;
            this.numberOfLogsLabel.Text = this.shiftNumber + " of " + this.numberOfShifts;
            this.dateLabel.Text         = DateTime.Now.ToString("dddd, MMM dd, yyyy");

            //Use a data table to store all the data and then apply it to the datagrid view
            DataTable dt = new DataTable();

            dt.Columns.Add("Task Type");
            dt.Columns.Add("Date");
            dt.Columns.Add("Time");
            dt.Columns.Add("Building");
            dt.Columns.Add("Room");
            dt.Columns.Add("Special Instructions/Comments");

            int Cnum = 0;
            int Rnum = 0;


            //Lock the thread so we don't get a cross thread issue
            if (!done)
            {
                lock (thisLock)
                {
                    if (!done)
                    {
                        //Add all the elements in the range to the datatable
                        for (Rnum = 1; Rnum <= rangeArray.GetUpperBound(0); Rnum++)
                        {
                            DataRow dr = dt.NewRow();
                            for (Cnum = 2; Cnum <= rangeArray.GetUpperBound(1); Cnum++)
                            {
                                DateTime temp;
                                //Reading in null values
                                if (rangeArray.GetValue(Rnum, Cnum) == null)
                                {
                                    dr[Cnum - 2] = "";
                                }
                                //Formatting the time from excel to be correct
                                else if ((Cnum - 1) == 2 && (!DateTime.TryParse((rangeArray.GetValue(Rnum, Cnum).ToString()), out temp)))
                                {
                                    dr[Cnum - 2] = DateTime.FromOADate(double.Parse(rangeArray.GetValue(Rnum, Cnum).ToString())).ToString("M/dd/yyyy");
                                }
                                //everything else
                                else
                                {
                                    dr[Cnum - 2] = rangeArray.GetValue(Rnum, Cnum).ToString().Trim();
                                }
                            }
                            //Add the row to the data table
                            dt.Rows.Add(dr);
                            //Accept the changes
                            dt.AcceptChanges();
                        }
                        done = true;
                    }
                }
            }
            //Remove the data column because we don't need
            dt.Columns.Remove("Date");

            //Set the datagrid data source to the dataTable
            dataGridView1.DataSource = dt;

            //Format the datagrid to look like the excel file
            this.format_DataGirdView();

            //Clear the default selected
            dataGridView1.ClearSelection();
        }
Exemplo n.º 48
0
        public static bool LoadArray(ref System.Array AnArray, int CanonDT, string wrTxt)
        {
            int ii    = 0;
            int loc   = 0;
            int Wlen  = 0;
            int start = 0;

            try
            {
                start = 1;
                Wlen  = wrTxt.Length;
                for (ii = AnArray.GetLowerBound(0); ii <= AnArray.GetUpperBound(0); ii++)
                {
                    loc = wrTxt.IndexOf(",", 0);
                    if (ii < AnArray.GetUpperBound(0))
                    {
                        if (loc == 0)
                        {
                            //MessageBox.Show("Valor escrito: Numero incorrecto de digitos para el tamaño del arreglo?", "Error de argumento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return(false);
                        }
                    }
                    else
                    {
                        loc = Wlen + 1;
                    }

                    switch (CanonDT)
                    {
                    case (int)CanonicalDataTypes.CanonDtByte:
                        AnArray.SetValue(Convert.ToByte((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    case (int)CanonicalDataTypes.CanonDtChar:
                        AnArray.SetValue(Convert.ToSByte((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case


                    case (int)CanonicalDataTypes.CanonDtWord:
                        AnArray.SetValue(Convert.ToUInt16((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    case (int)CanonicalDataTypes.CanonDtShort:
                        AnArray.SetValue(Convert.ToInt16((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    case (int)CanonicalDataTypes.CanonDtDWord:
                        AnArray.SetValue(Convert.ToInt32((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    case (int)CanonicalDataTypes.CanonDtLong:
                        AnArray.SetValue(Convert.ToInt32((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    case (int)CanonicalDataTypes.CanonDtFloat:
                        AnArray.SetValue(Convert.ToSingle((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    case (int)CanonicalDataTypes.CanonDtDouble:
                        AnArray.SetValue(Convert.ToDouble((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    case (int)CanonicalDataTypes.CanonDtBool:
                        AnArray.SetValue(Convert.ToBoolean((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    case (int)CanonicalDataTypes.CanonDtString:
                        AnArray.SetValue(Convert.ToString((wrTxt.Substring(start, loc - start))), ii);
                        break;
                    // End case

                    default:
                        //MessageBox.Show("El tipo de valor que se intenta escribir es desconocido", "Error de argumento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }

                    start = loc + 1;
                }

                return(true);
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Al intentar escribir el vaor se genero la siguiente excepción: " + ex.Message, "Excepción de OPC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
        }
Exemplo n.º 49
0
 private void WriteArray(Array array, Hashtable objectContainer, ref Int32 objectID)
 {
     if (array.Rank > 1) {
         throw new RankException("Only single dimension arrays are supported here.");
     }
     stream.WriteByte(PHPSerializationTag.AssocArray);
     stream.WriteByte(PHPSerializationTag.Colon);
     WriteNumber(array.GetLength(0));
     stream.WriteByte(PHPSerializationTag.Colon);
     stream.WriteByte(PHPSerializationTag.LeftB);
     Int32 lowerBound = array.GetLowerBound(0);
     Int32 upperBound = array.GetUpperBound(0);
     for (Int32 i = lowerBound; i <= upperBound; i++) {
         WriteInteger(i);
         Serialize(array.GetValue(i), objectContainer, ref objectID);
     }
     stream.WriteByte(PHPSerializationTag.RightB);
 }
Exemplo n.º 50
0
		/// <overload>
		/// <para>Copies the <see cref='System.Management.QualifierDataCollection'/> into an array.</para>
		/// </overload>
		/// <summary>
		/// <para> Copies the <see cref='System.Management.QualifierDataCollection'/> into an array.</para>
		/// </summary>
		/// <param name='array'>The array to which to copy the <see cref='System.Management.QualifierDataCollection'/>. </param>
		/// <param name='index'>The index from which to start copying. </param>
		public void CopyTo(Array array, int index)
		{
			if (null == array)
				throw new ArgumentNullException("array");

			if ((index < array.GetLowerBound(0)) || (index > array.GetUpperBound(0)))
				throw new ArgumentOutOfRangeException("index");

			// Get the names of the qualifiers
			string[] qualifierNames = null;
            IWbemQualifierSetFreeThreaded quals;
            try
            {
                quals = GetTypeQualifierSet();
            }
            catch(ManagementException e)
            {
                // There are NO qualifiers on system properties, so we just return
                if(qualifierSetType == QualifierType.PropertyQualifier && e.ErrorCode == ManagementStatus.SystemProperty)
                    return;
                else
                    throw;
            }
			int status = quals.GetNames_(0, out qualifierNames);

			if (status < 0)
			{
				if ((status & 0xfffff000) == 0x80041000)
					ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
				else
					Marshal.ThrowExceptionForHR(status);
			}

			if ((index + qualifierNames.Length) > array.Length)
				throw new ArgumentException(null, "index");

			foreach (string qualifierName in qualifierNames)
				array.SetValue(new QualifierData(parent, propertyOrMethodName, qualifierName, qualifierSetType), index++);

			return;
		}
Exemplo n.º 51
0
		private void WriteGenericArray (BinaryWriter writer, long id, Array array)
		{
			Type elementType = array.GetType().GetElementType();

			// Registers and writes the assembly of the array element type if needed

			if (!elementType.IsArray)
				WriteAssembly (writer, elementType.Assembly);

			// Writes the array

			writer.Write ((byte) BinaryElement.GenericArray);
			writer.Write ((int)id);
			
			// Write the structure of the array

			if (elementType.IsArray) 
				writer.Write ((byte) ArrayStructure.Jagged);
			else if (array.Rank == 1)
				writer.Write ((byte) ArrayStructure.SingleDimensional);
			else
				writer.Write ((byte) ArrayStructure.MultiDimensional);

			// Write the number of dimensions and the length
			// of each dimension

			writer.Write (array.Rank);
			for (int n=0; n<array.Rank; n++)
				writer.Write (array.GetUpperBound (n) + 1);

			// Writes the type
			WriteTypeCode (writer, elementType);
			WriteTypeSpec (writer, elementType);

			// Writes the values. For single-dimension array, a special tag is used
			// to represent multiple consecutive null values. I don't know why this
			// optimization is not used for multidimensional arrays.

			if (array.Rank == 1 && !elementType.IsValueType)
			{
				WriteSingleDimensionArrayElements (writer, array, elementType);
			}
			else
			{
				foreach (object item in array)
					WriteValue (writer, elementType, item);
			}
		}
Exemplo n.º 52
0
 private static void Iterate(Array array, int[] indices, int dimension, Action<int[]> action)
 {
     if (dimension >= indices.Length)
     {
         action(indices);
     }
     else
     {
         var lowerBound = array.GetLowerBound(dimension);
         var upperBound = array.GetUpperBound(dimension);
         for (var index = lowerBound; index <= upperBound; index++)
         {
             indices[dimension] = index;
             Iterate(array, indices, dimension + 1, action);
         }
     }
 }
Exemplo n.º 53
0
 private static void WriteArray(MemoryStream stream, Array a, int[] indices, Hashtable ht, ref int hv, Encoding encoding)
 {
     int n = indices.Length;
     int dimension = n - 1;
     int[] temp = new int[n + 1];
     indices.CopyTo(temp, 0);
     int len = a.GetLength(dimension);
     byte[] alen = Encoding.ASCII.GetBytes(len.ToString());
     int lb = a.GetLowerBound(dimension);
     int ub = a.GetUpperBound(dimension);
     stream.WriteByte(__a);
     stream.WriteByte(__Colon);
     stream.Write(alen, 0, alen.Length);
     stream.WriteByte(__Colon);
     stream.WriteByte(__LeftB);
     for (int i = lb; i <= ub; i++)
     {
         WriteInteger(stream, Encoding.ASCII.GetBytes(i.ToString()));
         if (a.Rank == n)
         {
             indices[n - 1] = i;
             Serialize(stream, a.GetValue(indices), ht, ref hv, encoding);
         }
         else
         {
             temp[n - 1] = i;
             WriteArray(stream, a, temp, ht, ref hv, encoding);
         }
     }
     stream.WriteByte(__RightB);
 }
        private static string[,] ConvertToStringArray2Dimensional(Array values)
        {
            // create a new string array
            var theArray = new string[values.GetUpperBound(0), values.GetUpperBound(1) - 1];

            // string[,] test = new string[11, 2];

            // loop through the 2-D System.Array and populate the 1-D String Array
            for (var i = 1; i <= values.GetUpperBound(0); i++)
            {
                for (var j = 1; j < values.GetUpperBound(1); j++)
                {
                    if (values.GetValue(i, j) == null)
                    {
                        theArray[i - 1, j - 1] = string.Empty;
                    }
                    else
                    {
                        theArray[i - 1, j - 1] = values.GetValue(i, j).ToString();
                    }

                    // if (MainForm.StopGracefully)
                    // return null;
                }
            }

            return theArray;
        }
		/// <summary>
		/// Write a rank of an array in Json format
		/// </summary>
		/// <param name="writer">JsonWriter in use</param>
		/// <param name="serializer">JsonSerializer in use</param>
		/// <param name="array">Array to be written</param>
		/// <param name="currentRank">Current rank "depth"</param>
		/// <param name="assignFromIndexList">List of indexes currently being used to read from the array</param>
		private void WriteRank(JsonWriter writer, JsonSerializer serializer, Array array, int currentRank, int[] assignFromIndexList)
		{
			writer.WriteStartArray();

			var lb = array.GetLowerBound(currentRank);
			var ub = array.GetUpperBound(currentRank);

			// Create a new indices list (one bigger than passed in) and fill with existing values
			var myAssignFromIndex = assignFromIndexList.GetUpperBound(0) + 1;
			var myAssignFromIndexList = new int[myAssignFromIndex + 1];
			Array.Copy(assignFromIndexList, myAssignFromIndexList, assignFromIndexList.Length);

			for (var i = lb; i <= ub; i++)
			{
				// set current index of this current rank
				myAssignFromIndexList[myAssignFromIndex] = i;

				if (currentRank < array.Rank - 1) // There are still more ranks, process them
					WriteRank(writer, serializer, array, currentRank + 1, myAssignFromIndexList);
				else // This is the "bottom" rank, write out values
					serializer.Serialize(writer, array.GetValue(myAssignFromIndexList));
			}

			writer.WriteEndArray();
		}
Exemplo n.º 56
0
        public static bool LoadArray(ref System.Array AnArray, int CanonDT, string wrTxt)
        {
            int ii    = 0;
            int loc   = 0;
            int Wlen  = 0;
            int start = 0;

            try
            {
                start = 1;
                Wlen  = wrTxt.Length;
                for (ii = AnArray.GetLowerBound(0); ii <= AnArray.GetUpperBound(0); ii++)
                {
                    loc = wrTxt.IndexOf(",", 0);
                    if (ii < AnArray.GetUpperBound(0))
                    {
                        if (loc == 0)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        loc = Wlen + 1;
                    }

                    switch (CanonDT)
                    {
                    case (int)CanonicalDataTypes.CanonDtByte:
                        AnArray.SetValue(Convert.ToByte((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtChar:
                        AnArray.SetValue(Convert.ToSByte((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtWord:
                        AnArray.SetValue(Convert.ToUInt16((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtShort:
                        AnArray.SetValue(Convert.ToInt16((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtDWord:
                        AnArray.SetValue(Convert.ToInt32((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtLong:
                        AnArray.SetValue(Convert.ToInt32((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtFloat:
                        AnArray.SetValue(Convert.ToSingle((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtDouble:
                        AnArray.SetValue(Convert.ToDouble((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtBool:
                        AnArray.SetValue(Convert.ToBoolean((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    case (int)CanonicalDataTypes.CanonDtString:
                        AnArray.SetValue(Convert.ToString((wrTxt.Substring(start, loc - start))), ii);
                        break;

                    default:
                        return(false);
                    }

                    start = loc + 1;
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }