/// <summary> /// Used to de-serialize the element. /// </summary> /// <param name="byteArray">A Byte array</param> /// <param name="currentIndex">Start position</param> /// <param name="lengthOfItems">The length of the items</param> protected override void DeserializeItemsFromByteArray(byte[] byteArray, ref int currentIndex, int lengthOfItems) { int index = currentIndex; if (lengthOfItems != 0) { throw new StreamObjectParseErrorException(currentIndex, "LeafNodeObjectData", "Stream Object over-parse error", null); } this.Signature = StreamObject.GetCurrent <SignatureObject>(byteArray, ref index); this.DataSize = StreamObject.GetCurrent <DataSizeObject>(byteArray, ref index); // Try to read StreamObjectHeaderStart to see there is data hash object or not StreamObjectHeaderStart streamObjectHeader; if ((StreamObjectHeaderStart.TryParse(byteArray, index, out streamObjectHeader)) != 0) { if (streamObjectHeader.Type == StreamObjectTypeHeaderStart.DataHashObject) { this.DataHash = StreamObject.GetCurrent <DataHashObject>(byteArray, ref index); } } currentIndex = index; }
/// <summary> /// This method is used to verify the DataHash object related requirements. /// </summary> /// <param name="instance">Specify the DataHash object instance.</param> /// <param name="site">Specify the ITestSite instance.</param> public void VerifyDataHashObject(DataHashObject instance, ITestSite site) { // If the instance is not null and there are no parsing errors, then the SignatureObject related adapter requirements can be directly captured. if (null == instance) { site.Assert.Fail("The instance of type DataHashObject is null due to parsing error or type casting error."); } // Verify the stream object header related requirements. this.ExpectStreamObjectHeaderStart(instance.StreamObjectHeaderStart, instance.GetType(), site); this.ExpectSingleObject(instance.StreamObjectHeaderStart, site); }
/// <summary> /// Override the equals method. /// </summary> /// <param name="obj">Specify the compared instance.</param> /// <returns>If equals return true, otherwise return false.</returns> public override bool Equals(object obj) { DataHashObject so = obj as DataHashObject; if (so == null) { return(false); } if (so.Data != null && this.Data != null) { return(so.Data.Equals(this.Data)); } else if (so.Data == null && this.Data == null) { return(true); } else { return(false); } }