A data element package contains the serialized file data elements made up of storage index, storage manifest, cell manifest, revision manifest, and object group or object data, or both.
Inheritance: StreamObject
示例#1
0
        public MSOneStorePackage Parse(DataElementPackage dataElementPackage)
        {
            MSOneStorePackage package = new MSOneStorePackage();

            storageIndexDataElements     = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.StorageIndexDataElementData).ToArray();
            storageManifestDataElements  = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.StorageManifestDataElementData).ToArray();
            cellManifestDataElements     = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.CellManifestDataElementData).ToArray();
            revisionManifestDataElements = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.RevisionManifestDataElementData).ToArray();
            objectGroupDataElements      = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.ObjectGroupDataElementData).ToArray();
            objectBlOBElements           = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.ObjectDataBLOBDataElementData).ToArray();

            package.StorageIndex    = storageIndexDataElements[0].Data as StorageIndexDataElementData;
            package.StorageManifest = storageManifestDataElements[0].Data as StorageManifestDataElementData;

            // Parse Header Cell
            CellID headerCellID = package.StorageManifest.StorageManifestRootDeclareList[0].CellID;
            StorageIndexCellMapping headerCellStorageIndexCellMapping = package.FindStorageIndexCellMapping(headerCellID);

            storageIndexHashTab.Add(headerCellID);

            if (headerCellStorageIndexCellMapping != null)
            {
                package.HeaderCellCellManifest = this.FindCellManifest(headerCellStorageIndexCellMapping.CellMappingExtendedGUID);
                StorageIndexRevisionMapping headerCellRevisionManifestMapping =
                    package.FindStorageIndexRevisionMapping(package.HeaderCellCellManifest.CellManifestCurrentRevision.CellManifestCurrentRevisionExtendedGUID);
                package.HeaderCellRevisionManifest = this.FindRevisionManifestDataElement(headerCellRevisionManifestMapping.RevisionMappingExtendedGUID);
                package.HeaderCell = this.ParseHeaderCell(package.HeaderCellRevisionManifest);

                // Parse Data root
                CellID dataRootCellID = package.StorageManifest.StorageManifestRootDeclareList[1].CellID;
                storageIndexHashTab.Add(dataRootCellID);
                package.DataRoot = this.ParseObjectGroup(dataRootCellID, package);
                // Parse other data
                foreach (StorageIndexCellMapping storageIndexCellMapping in package.StorageIndex.StorageIndexCellMappingList)
                {
                    if (storageIndexHashTab.Contains(storageIndexCellMapping.CellID) == false)
                    {
                        package.OtherFileNodeList.AddRange(this.ParseObjectGroup(storageIndexCellMapping.CellID, package));
                        storageIndexHashTab.Add(storageIndexCellMapping.CellID);
                    }
                }
            }
            return(package);
        }
        /// <summary>
        /// This method is used to test Data Element Package related adapter requirements.
        /// </summary> 
        /// <param name="instance">Specify the instance which need to be verified.</param> 
        /// <param name="site">Specify the ITestSite instance.</param>
        public void VerifyDataElementPackage(DataElementPackage instance, ITestSite site)
        {
            // If the instance is not null and there are no parsing errors, then the Data Element Package related adapter requirements can be directly captured.
            if (null == instance)
            {
                site.Assert.Fail("The instance of type DataElementPackage is null due to parsing error or type casting error.");
            }

            // Directly capture requirement MS-FSSHTTPB_R239, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     239,
                     @"[In Data Element Package] A data element package contains the serialized file data elements made up of storage index (section 2.2.1.12.2), storage manifest (section 2.2.1.12.3), cell manifest (section 2.2.1.12.4), revision manifest (section 2.2.1.12.5), and object group (section 2.2.1.12.6) or object data (section 2.2.1.12.6.4), or both.");

            // Verify the stream object header related requirements.
            this.ExpectStreamObjectHeaderStart(instance.StreamObjectHeaderStart, instance.GetType(), site);

            bool isVerifyR240 = instance.StreamObjectHeaderStart is StreamObjectHeaderStart16bit;
            site.Assert.IsTrue(
                            isVerifyR240,
                            "Actual stream object header type is {0}, which should be 16-bit stream object header for the requirement MS-FSSHTTPB_R240.",
                            instance.StreamObjectHeaderStart.GetType().Name);

            // Capture requirement MS-FSSHTTPB_R240, if the above assertion was validated.
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     240,
                     @"[In Data Element Package] Data Element Package Start (2 bytes): A 16-bit stream object header (section 2.2.1.5.1) that specifies a data element package start.");

            // Directly capture requirement MS-FSSHTTPB_R241, if the reserved value equals to 0.
            site.CaptureRequirementIfAreEqual<uint>(
                     0,
                     instance.Reserved,
                     "MS-FSSHTTPB",
                     241,
                     @"[In Data Element Package] Reserved (1 byte): A reserved field that MUST be set to zero.");

            if (instance.DataElements != null && instance.DataElements.Count != 0)
            {
                // Directly capture requirement MS-FSSHTTPB_R243, if there are no parsing errors. 
                site.CaptureRequirement(
                         "MS-FSSHTTPB",
                         243,
                         @"[In Data Element Package] Data Element (variable): An optional array of data elements (section 2.2.1.12.1) that specifies the serialized file data elements.");
            }

            // Verify the stream object header end related requirements.
            this.ExpectStreamObjectHeaderEnd(instance.StreamObjectHeaderEnd, instance.GetType(), site);
            this.ExpectCompoundObject(instance.StreamObjectHeaderStart, site);

            bool isVerifyR245 = instance.StreamObjectHeaderStart is StreamObjectHeaderStart16bit;
            site.Assert.IsTrue(
                            isVerifyR245,
                            "Actual stream object header end type is {0}, which should be 8-bit stream object end header for the requirement MS-FSSHTTPB_R245.",
                            instance.StreamObjectHeaderEnd.GetType().Name);

            // Directly capture requirement MS-FSSHTTPB_R245, if the above assertion was validated.
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     245,
                     @"[In Data Element Package] Data Element Package End (1 byte): An 8-bit stream object header (section 2.2.1.5.3) that specifies a data element package end.");
        }