コード例 #1
0
        private void performMutation(DataElement obj, uint newCount)
        {
            int startIdx = obj.parent.IndexOf(obj) + 1;
            var value    = obj.Value.Clone();

            value.ClearElementPositions();
            var mutatedValue = new Variant(value);

            for (int i = 0; i < newCount; ++i)
            {
                string newName = obj.name + "_" + i;

                // Make sure we pick a unique name
                while (obj.parent.ContainsKey(newName))
                {
                    newName += "_" + i;
                }

                DataElement newElem = Activator.CreateInstance(obj.GetType(), new object[] { newName }) as DataElement;
                newElem.MutatedValue  = mutatedValue;
                newElem.mutationFlags = DataElement.MUTATE_DEFAULT | DataElement.MUTATE_OVERRIDE_TYPE_TRANSFORM;

                obj.parent.Insert(startIdx + i, newElem);
            }
        }
コード例 #2
0
        private void performMutation(DataElement obj, uint newCount)
        {
            int startIdx = obj.parent.IndexOf(obj) + 1;
            var value    = new Peach.Core.IO.BitStream();
            var src      = obj.Value;

            src.CopyTo(value);
            src.SeekBits(0, System.IO.SeekOrigin.Begin);
            value.SeekBits(0, System.IO.SeekOrigin.Begin);
            var mutatedValue = new Variant(value);

            for (int i = 0; i < newCount; ++i)
            {
                string newName = obj.name + "_" + i;

                // Make sure we pick a unique name
                while (obj.parent.ContainsKey(newName))
                {
                    newName += "_" + i;
                }

                DataElement newElem = Activator.CreateInstance(obj.GetType(), new object[] { newName }) as DataElement;
                newElem.MutatedValue  = mutatedValue;
                newElem.mutationFlags = MutateOverride.Default | MutateOverride.TypeTransform;

                obj.parent.Insert(startIdx + i, newElem);
            }
        }
コード例 #3
0
        /// <summary>
        /// Convert the contents of the Matlab data element to a sequence of Single values.
        /// </summary>
        /// <param name="element">Data element.</param>
        /// <returns>Contents of the elements, converted to Single.</returns>
        public static IEnumerable <float> GetDataAsSingle(DataElement element)
        {
            switch (element)
            {
            case MiNum <sbyte> sbyteElement:
                return(sbyteElement.Data.Select(Convert.ToSingle));

            case MiNum <byte> byteElement:
                return(byteElement.Data.Select(Convert.ToSingle));

            case MiNum <int> intElement:
                return(intElement.Data.Select(Convert.ToSingle));

            case MiNum <uint> uintElement:
                return(uintElement.Data.Select(Convert.ToSingle));

            case MiNum <short> shortElement:
                return(shortElement.Data.Select(Convert.ToSingle));

            case MiNum <ushort> ushortElement:
                return(ushortElement.Data.Select(Convert.ToSingle));

            case MiNum <long> longElement:
                return(longElement.Data.Select(Convert.ToSingle));

            case MiNum <ulong> ulongElement:
                return(ulongElement.Data.Select(Convert.ToSingle));

            case MiNum <float> floatElement:
                return(floatElement.Data);

            case MiNum <double> doubleElement:
                return(doubleElement.Data.Select(Convert.ToSingle));
            }
            throw new HandlerException(
                      $"Expected data element that would be convertible to float, found {element.GetType()}.");
        }
コード例 #4
0
        /// <summary>
        /// Convert the contents of the Matlab data element to a sequence of Single values.
        /// </summary>
        /// <param name="element">Data element.</param>
        /// <returns>Contents of the elements, converted to Single.</returns>
        public static float[] GetDataAsSingle(DataElement element)
        {
            switch (element)
            {
            case MiNum <sbyte> sbyteElement:
                return(SbyteToSingle(sbyteElement.Data));

            case MiNum <byte> byteElement:
                return(ByteToSingle(byteElement.Data));

            case MiNum <int> intElement:
                return(IntToSingle(intElement.Data));

            case MiNum <uint> uintElement:
                return(UintToSingle(uintElement.Data));

            case MiNum <short> shortElement:
                return(ShortToSingle(shortElement.Data));

            case MiNum <ushort> ushortElement:
                return(UshortToSingle(ushortElement.Data));

            case MiNum <long> longElement:
                return(LongToSingle(longElement.Data));

            case MiNum <ulong> ulongElement:
                return(UlongToSingle(ulongElement.Data));

            case MiNum <float> floatElement:
                return(floatElement.Data);

            case MiNum <double> doubleElement:
                return(DoubleToSingle(doubleElement.Data));
            }
            throw new HandlerException(
                      $"Expected data element that would be convertible to float, found {element.GetType()}.");
        }
コード例 #5
0
        /// <summary>
        /// This method is used to test Data Element Fragment Data Elements related adapter requirements.
        /// </summary>
        /// <param name="instance">Specify the instance which need to be verified.</param> 
        /// <param name="site">Specify the ITestSite instance.</param>
        private void VerifyFragmentDataElement(DataElement instance, ITestSite site)
        {
            // Verify the stream object header related requirements.
            this.ExpectStreamObjectHeaderStart(instance.StreamObjectHeaderStart, instance.GetType(), site);

            // Directly capture requirement MS-FSSHTTPB_R336, if the stream object header is StreamObjectHeaderEnd16bit.
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderStart16bit),
                     instance.StreamObjectHeaderStart.GetType(),
                     "MS-FSSHTTPB",
                     336,
                     @"[In Data Element Fragment Data Elements] Data Element Start (2 bytes): A 16-bit stream object header (section 2.2.1.5.1) that specifies a data element start.");

            // Directly capture requirement MS-FSSHTTPB_R337, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     337,
                     @"[In Data Element Fragment Data Elements] Data Element Extended GUID (variable): An extended GUID (section 2.2.1.7) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R338, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     338,
                     @"[In Data Element Fragment Data Elements] Serial Number (variable): A serial number (section 2.2.1.9) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R339, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     339,
                     @"[In Data Element Fragment Data Elements] Data Element Type (variable): A compact unsigned 64-bit integer (section 2.2.1.1) that specifies the value of the object data BLOB data element type (section 2.2.1.12.8).");

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

            // Directly capture requirement MS-FSSHTTPB_R345, if there are no parsing errors. 
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderEnd8bit),
                     instance.StreamObjectHeaderEnd.GetType(),
                     "MS-FSSHTTPB",
                     345,
                     @"[In Data Element Fragment Data Elements] Data Element End (1 byte): An 8-bit stream object header (section 2.2.1.5.3) that specifies a data element end.");
        }
コード例 #6
0
        /// <summary>
        /// This method is used to test Object Data BLOB Data Elements related adapter requirements.
        /// </summary>
        /// <param name="instance">Specify the instance which need to be verified.</param> 
        /// <param name="site">Specify the ITestSite instance.</param>
        private void VerifyObjectDataBLOBDataElement(DataElement instance, ITestSite site)
        {
            // If the instance is not null and there are no parsing errors, then the DataElementFragment related adapter requirements can be directly captured.
            if (null == instance)
            {
                site.Assert.Fail("The instance of type DataElementFragment is null due to parsing error or type casting error.");
            }

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

            // Directly capture requirement MS-FSSHTTPB_R346, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     346,
                     @"[In Object Data BLOB Data Elements] Data Element Start (2 bytes): A 16-bit stream object header (section 2.2.1.5.1) that specifies a data element start.");

            // Directly capture requirement MS-FSSHTTPB_R347, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     347,
                     @"[In Object Data BLOB Data Elements] Data Element Extended GUID (variable): An extended GUID (section 2.2.1.7) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R348, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     348,
                     @"[In Object Data BLOB Data Elements] Serial Number (variable): A serial number (section 2.2.1.9) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R349, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     349,
                     @"[In Object Data BLOB Data Elements] Data Element Type (variable): A compact unsigned 64-bit integer (section 2.2.1.1) that specifies the value of the object data BLOB data element type.");

            // Directly capture requirement MS-FSSHTTPB_R350, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     350,
                     @"[In Object Data BLOB Data Elements] Object Data BLOB (variable): A 16-bit or 32-bit stream object header that specifies an object data BLOB.");

            // Directly capture requirement MS-FSSHTTPB_R351, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     351,
                     @"[In Object Data BLOB Data Elements] Data (variable): A byte stream that specifies the binary data opaque to this protocol[MS-FSSHTTPB].");

            // Directly capture requirement MS-FSSHTTPB_R352, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     352,
                     @"[In Object Data BLOB Data Elements] Data Element End (1 byte): An 8-bit stream object header (section 2.2.1.5.3) that specifies a data element end.");

            // Verify the stream object header end related requirements.
            this.ExpectStreamObjectHeaderEnd(instance.StreamObjectHeaderEnd, instance.GetType(), site);
            this.ExpectCompoundObject(instance.StreamObjectHeaderStart, site);
        }
コード例 #7
0
        /// <summary>
        /// This method is used to test Object Group Data Elements related adapter requirements.
        /// </summary>
        /// <param name="instance">Specify the instance which need to be verified.</param> 
        /// <param name="site">Specify the ITestSite instance.</param>
        private void VerifyObjectGroupDataElement(DataElement instance, ITestSite site)
        {
            // Verify the stream object header related requirements.
            this.ExpectStreamObjectHeaderStart(instance.StreamObjectHeaderStart, instance.GetType(), site);

            // Capture requirement MS-FSSHTTPB_R302, if the stream object header is StreamObjectHeaderStart16bit.
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderStart16bit),
                     instance.StreamObjectHeaderStart.GetType(),
                     "MS-FSSHTTPB",
                     302,
                     @"[In Object Group Data Elements] Data Element Start (2 bytes): A 16-bit stream object header (section 2.2.1.5.1) that specifies a data element start.");

            // Directly capture requirement MS-FSSHTTPB_R303, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     303,
                     @"[In Object Group Data Elements] Data Element Extended GUID (variable): An extended GUID (section 2.2.1.7) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R304, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     304,
                     @"[In Object Group Data Elements] Serial Number (variable): A serial number (section 2.2.1.9) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R305, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     305,
                     @"[In Object Group Data Elements] Data Element Type (variable): A compact unsigned 64-bit integer (section 2.2.1.1) that specifies the value of the object group data element type.");

            if (instance.GetData<ObjectGroupDataElementData>().ObjectMetadataDeclaration != null)
            {
                // Directly capture requirement MS-FSSHTTPB_R2103, if there are no parsing errors. 
                site.CaptureRequirement(
                         "MS-FSSHTTPB",
                         2103,
                         @"[In Object Group Data Elements] Object Metadata Declaration (variable): If object metadata (section 2.2.1.12.6.3.1) exists, this field MUST specify an object metadata declaration (section 2.2.1.12.6.3).");
            }

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

            // Capture requirement MS-FSSHTTPB_R314, if the stream object end is StreamObjectHeaderEnd8bit.
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderEnd8bit),
                     instance.StreamObjectHeaderEnd.GetType(),
                     "MS-FSSHTTPB",
                     314,
                     @"[In Object Group Data Elements] Data Element End (1 byte): An 8-bit stream object header that specifies a data element end.");
        }
コード例 #8
0
        /// <summary>
        /// This method is used to test Storage Manifest Data Element related adapter requirements.
        /// </summary>
        /// <param name="instance">Specify the instance which need to be verified.</param> 
        /// <param name="site">Specify the ITestSite instance.</param>
        private void VerifyStorageManifestDataElement(DataElement instance, ITestSite site)
        {
            // If the instance is not null and there are no parsing errors, then the Storage Manifest Data Element related adapter requirements can be directly captured.
            if (null == instance)
            {
                site.Assert.Fail("The instance of type StorageManifestDataElementData is null due to parsing error or type casting error.");
            }

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

            // Directly capture requirement MS-FSSHTTPB_R272, if the stream object header is StreamObjectHeaderStart16bit.
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderStart16bit),
                     instance.StreamObjectHeaderStart.GetType(),
                     "MS-FSSHTTPB",
                     272,
                     @"[In Storage Manifest Data Element] Data Element Start (2 bytes): A 16-bit stream object header (section 2.2.1.5.1) that specifies a data element start.");

            // Directly capture requirement MS-FSSHTTPB_R273, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     273,
                     @"[In Storage Manifest Data Element] Data Element Extended GUID (variable): An extended GUID (section 2.2.1.7) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R274, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     274,
                     @"[In Storage Manifest Data Element] Serial Number (variable): A serial number (section 2.2.1.9) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R275, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     275,
                     @"[In Storage Manifest Data Element] Data Element Type (variable): A compact unsigned 64-bit integer (section 2.2.1.1) that specifies the value of the storage manifest data element type.");

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

            // Directly capture requirement MS-FSSHTTPB_R281, if the stream object end is StreamObjectHeaderEnd8bit.
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderEnd8bit),
                     instance.StreamObjectHeaderEnd.GetType(),
                     "MS-FSSHTTPB",
                     281,
                     @"[In Storage Manifest Data Element] Data Element End (1 byte): An 8-bit stream object header (section 2.2.1.5.3) that specifies a data element end.");
        }
コード例 #9
0
        /// <summary>
        /// This method is used to test Storage Index Data Element related adapter requirements.
        /// </summary>
        /// <param name="instance">Specify the instance which need to be verified.</param> 
        /// <param name="site">Specify the ITestSite instance.</param>
        private void VerifyStorageIndexDataElement(DataElement instance, ITestSite site)
        {
            // Verify the stream object header related requirements.
            this.ExpectStreamObjectHeaderStart(instance.StreamObjectHeaderStart, instance.GetType(), site);

            // Directly capture requirement MS-FSSHTTPB_R255, if the stream object header is StreamObjectHeaderStart16bit.
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderStart16bit),
                     instance.StreamObjectHeaderStart.GetType(),
                     "MS-FSSHTTPB",
                     255,
                     @"[In Storage Index Data Element] Data Element Start (2 bytes): A 16-bit stream object header (section 2.2.1.5.1) that specifies a data element start.");

            // Directly capture requirement MS-FSSHTTPB_R256, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     256,
                     @"[In Storage Index Data Element] Data Element Extended GUID (variable): An extended GUID (section 2.2.1.7) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R257, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     257,
                     @"[In Storage Index Data Element] Serial Number (variable): A serial number (section 2.2.1.9) that specifies the data element.");

            // Directly capture requirement MS-FSSHTTPB_R258, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     258,
                     @"[In Storage Index Data Element] Data Element Type (variable): A compact unsigned 64-bit integer (section 2.2.1.1) that specifies the value of the storage index data element type.");

            // Directly capture requirement MS-FSSHTTPB_R99007, if there are no parsing errors. 
            site.CaptureRequirement(
                     "MS-FSSHTTPB",
                     99007,
                     @"[In Storage Index Data Element] When serializing a Storage Index data element, there is no sequence for Storage Index Manifest Mapping, Storage Index Cell Mapping and Storage Index Revision Mapping.");

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

            // Directly capture requirement MS-FSSHTTPB_R270, if the stream object end header is StreamObjectHeaderEnd8bit.
            site.CaptureRequirementIfAreEqual<Type>(
                     typeof(StreamObjectHeaderEnd8bit),
                     instance.StreamObjectHeaderEnd.GetType(),
                     "MS-FSSHTTPB",
                     270,
                     @"[In Storage Index Data Element] Data Element End (1 byte): An 8-bit stream object header that specifies a data element end.");
        }