TimeSeriesLibrary.TSLibrary.ConvertBlobToListAll C# (CSharp) Method

ConvertBlobToListAll() public method

This method creates a List of TimeSeriesValue objects from the given BLOB (byte array) of time series values. The method converts the entire BLOB into the list. The sibling method ConvertBlobToListLimited can convert a selected portion of the BLOB into the list.
public ConvertBlobToListAll ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, Byte blobData, List &dateValueList, int compressionCode ) : int
timeStepUnit TSDateCalculator TSDateCalculator.TimeStepUnitCode value for Minute,Hour,Day,Week,Month, Year, or Irregular
timeStepQuantity short The number of the given unit that defines the time step. /// For instance, if the time step is 6 hours long, then this value is 6. If timeStepUnit is /// Irregular, then this value is ignored.
timeStepCount int the number of time steps that are stored in the blob
blobStartDate System.DateTime The DateTime value of the first time step in the BLOB. If /// timeStepUnit is Irregular, then this value is ignored.
blobData Byte The BLOB (byte array) that this method will convert
dateValueList List The List of TimeSeriesValues that this method will create from the BLOB.
compressionCode int a generation number that indicates what compression technique to use
return int
        public int ConvertBlobToListAll(
            TSDateCalculator.TimeStepUnitCode timeStepUnit, short timeStepQuantity,
            int timeStepCount, DateTime blobStartDate,
            Byte[] blobData, ref List<TimeSeriesValue> dateValueList, int compressionCode)
        {
            // The private method ConvertBlobToList() will do all the real work here.
            // This private method takes parameters for limiting a portion of the List to be
            // written to the BLOB.  The values below are dummies that will be passed to
            // the private method, which it will ignore.
            int nReqValues = 0;
            DateTime reqStartDate = blobStartDate;
            DateTime reqEndDate = blobStartDate;

            // Let the private core method do all the real work.
            // We pass it the 'applyLimits' value of false, to tell it to ignore the 'req' limit values.
            return ConvertBlobToList(timeStepUnit, timeStepQuantity,
                        timeStepCount, blobStartDate, false,
                        nReqValues, reqStartDate, reqEndDate,
                        blobData, ref dateValueList, compressionCode);
        }

Usage Example

        // The series of tests below is for ConvertBlobToListAll and ConvertListToBlob.
        // The tests take advantage of the fact that the methods are designed so that
        // the series that is put into the BLOB must be identical to the series that
        // comes out of the BLOB.
        // This method is re-used by the actual test methods that follow.
        public void ConvertBlobAll(List<TimeSeriesValue> inList,
                TSDateCalculator.TimeStepUnitCode timeStepUnit, short timeStepQuantity,
                DateTime blobStartDate)
        {
            TSLibrary tsLib = new TSLibrary();
            List<TimeSeriesValue> outList = new List<TimeSeriesValue>();
            int compressionCode;

            byte[] blobData = tsLib.ConvertListToBlobWithChecksum(timeStepUnit, timeStepQuantity,
                                inList.Count, inList.First().Date, inList.Last().Date, inList,
                                new TSTrace { TraceNumber=1 }, out compressionCode);

            int ret = tsLib.ConvertBlobToListAll(timeStepUnit, timeStepQuantity,
                            inList.Count, blobStartDate, blobData, ref outList, compressionCode);

            // The return value of the function must match the number of items in the original list
            Assert.AreEqual(ret, inList.Count);
            // the count in both lists must match
            Assert.AreEqual(outList.Count, inList.Count);

            // now check each item in the two lists
            Boolean AreEqual = true;
            for (int i = 0; i < ret; i++)
            {
                if (outList[i].ValueEquals(inList[i]) == false)
                    AreEqual = false;
            }

            Assert.IsTrue(AreEqual);
        }