/// <summary> /// Override the Equals method. /// </summary> /// <param name="obj">Specify the object.</param> /// <returns>Return true if equals, otherwise return false.</returns> public override bool Equals(object obj) { BinaryItem bi = obj as BinaryItem; if (bi == null) { return(false); } return(this.Length.DecodedValue == bi.Length.DecodedValue && AdapterHelper.ByteArrayEquals(this.content.ToArray(), bi.content.ToArray())); }
/// <summary> /// This method is used to deserialize the items of the version token knowledge from the byte array. /// </summary> /// <param name="byteArray">Specify the byte array.</param> /// <param name="currentIndex">Specify the start index from the byte array.</param> /// <param name="lengthOfItems">Specify the current length of items in the version token knowledge.</param> protected override void DeserializeItemsFromByteArray(byte[] byteArray, ref int currentIndex, int lengthOfItems) { if (lengthOfItems != 0) { throw new KnowledgeParseErrorException(currentIndex, "VersionTokenKnowledge object over-parse error", null); } int index = currentIndex; this.TokenData = BasicObject.Parse <BinaryItem>(byteArray, ref index); currentIndex = index; }
/// <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; this.Data = BasicObject.Parse <BinaryItem>(byteArray, ref index); if (index - currentIndex != lengthOfItems) { throw new StreamObjectParseErrorException(currentIndex, "Signature", "Stream Object over-parse error", null); } currentIndex = index; }
/// <summary> /// This method is used to deserialize the items of the content tag knowledge entry from the byte array. /// </summary> /// <param name="byteArray">Specify the byte array.</param> /// <param name="currentIndex">Specify the start index from the byte array.</param> /// <param name="lengthOfItems">Specify the current length of items in the content tag knowledge entry.</param> protected override void DeserializeItemsFromByteArray(byte[] byteArray, ref int currentIndex, int lengthOfItems) { int index = currentIndex; this.BLOBHeapExtendedGUID = BasicObject.Parse <ExGuid>(byteArray, ref index); this.ClockData = BasicObject.Parse <BinaryItem>(byteArray, ref index); if (index - currentIndex != lengthOfItems) { throw new StreamObjectParseErrorException(currentIndex, "ContentTagKnowledgeEntry", "Stream object over-parse error", null); } currentIndex = index; }
/// <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; this.FragmentExtendedGUID = BasicObject.Parse <ExGuid>(byteArray, ref index); this.FragmentDataElementSize = BasicObject.Parse <Compact64bitInt>(byteArray, ref index); this.FragmentFileChunkReference = BasicObject.Parse <FileChunk>(byteArray, ref index); this.FragmentData = BasicObject.Parse <BinaryItem>(byteArray, ref index); if (index - currentIndex != lengthOfItems) { throw new StreamObjectParseErrorException(currentIndex, "DataElementFragment", "Stream object over-parse error", null); } currentIndex = index; }
/// <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; this.DataElementHashScheme = BasicObject.Parse<Compact64bitInt>(byteArray, ref index); this.DataElementHashData = BasicObject.Parse<BinaryItem>(byteArray, ref index); if (index - currentIndex != lengthOfItems) { throw new StreamObjectParseErrorException(currentIndex, "DataElementHash", "Stream object over-parse error", null); } currentIndex = index; }
/// <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; this.ObjectExGUIDArray = BasicObject.Parse<ExGUIDArray>(byteArray, ref index); this.CellIDArray = BasicObject.Parse<CellIDArray>(byteArray, ref index); this.Data = BasicObject.Parse<BinaryItem>(byteArray, ref index); if (index - currentIndex != lengthOfItems) { throw new StreamObjectParseErrorException(currentIndex, "ObjectGroupObjectData", "Stream object over-parse error", null); } currentIndex = index; }
/// <summary> /// This method is used to build intermediate node object from an list of object group data element. /// </summary> /// <param name="objectGroupList">Specify the list of object group data elements.</param> /// <param name="dataObj">Specify the object group object.</param> /// <param name="intermediateGuid">Specify the intermediate extended GUID.</param> /// <returns>Return the intermediate node object.</returns> public LeafNodeObject Build(List <ObjectGroupDataElementData> objectGroupList, ObjectGroupObjectData dataObj, ExGuid intermediateGuid) { LeafNodeObject node = null; IntermediateNodeObject rootNode = null; int index = 0; if (StreamObject.TryGetCurrent <LeafNodeObject>(dataObj.Data.Content.ToArray(), ref index, out node)) { if (dataObj.ObjectExGUIDArray == null) { throw new InvalidOperationException("Failed to build intermediate node because the object extend GUID array does not exist."); } node.ExGuid = intermediateGuid; // Contain a single Data Node Object. if (dataObj.ObjectExGUIDArray.Count.DecodedValue == 1u) { ObjectGroupObjectDeclare dataNodeDeclare; ObjectGroupObjectData dataNodeData = this.FindByExGuid(objectGroupList, dataObj.ObjectExGUIDArray.Content[0], out dataNodeDeclare); BinaryItem data = dataNodeData.Data; node.DataNodeObjectData = new DataNodeObjectData(data.Content.ToArray(), 0, (int)data.Length.DecodedValue); node.DataNodeObjectData.ExGuid = dataObj.ObjectExGUIDArray.Content[0]; node.IntermediateNodeObjectList = null; if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { MsfsshttpdCapture.VerifyObjectGroupObjectDataForDataNodeObject(dataNodeData, dataNodeDeclare, objectGroupList, SharedContext.Current.Site); } } else { // Contain a list of LeafNodeObjectData node.IntermediateNodeObjectList = new List <LeafNodeObject>(); node.DataNodeObjectData = null; foreach (ExGuid extGuid in dataObj.ObjectExGUIDArray.Content) { ObjectGroupObjectDeclare intermediateDeclare; ObjectGroupObjectData intermediateData = this.FindByExGuid(objectGroupList, extGuid, out intermediateDeclare); node.IntermediateNodeObjectList.Add(new IntermediateNodeObjectBuilder().Build(objectGroupList, intermediateData, extGuid)); if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { MsfsshttpdCapture.VerifyObjectGroupObjectDataForIntermediateNode(intermediateData, intermediateDeclare, objectGroupList, SharedContext.Current.Site); } } } } else if (StreamObject.TryGetCurrent <IntermediateNodeObject>(dataObj.Data.Content.ToArray(), ref index, out rootNode)) { // In Sub chunking for larger than 1MB zip file, MOSS2010 could return IntermediateNodeObject. // For easy further process, the rootNode will be replaced by intermediate node instead. node = new LeafNodeObject(); node.IntermediateNodeObjectList = new List <LeafNodeObject>(); node.DataSize = rootNode.DataSize; node.ExGuid = rootNode.ExGuid; node.Signature = rootNode.Signature; node.DataNodeObjectData = null; foreach (ExGuid extGuid in dataObj.ObjectExGUIDArray.Content) { ObjectGroupObjectDeclare intermediateDeclare; ObjectGroupObjectData intermediateData = this.FindByExGuid(objectGroupList, extGuid, out intermediateDeclare); node.IntermediateNodeObjectList.Add(new IntermediateNodeObjectBuilder().Build(objectGroupList, intermediateData, extGuid)); if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { MsfsshttpdCapture.VerifyObjectGroupObjectDataForIntermediateNode(intermediateData, intermediateDeclare, objectGroupList, SharedContext.Current.Site); } } } else { throw new InvalidOperationException("In the ObjectGroupDataElement cannot only contain the IntermediateNodeObject or IntermediateNodeOBject."); } return(node); }
/// <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; this.SignatureData = BasicObject.Parse<BinaryItem>(byteArray, ref index); if (index - currentIndex != lengthOfItems) { throw new StreamObjectParseErrorException(currentIndex, "Signature", "Stream Object over-parse error", null); } currentIndex = index; }
/// <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; this.FragmentExtendedGUID = BasicObject.Parse<ExGuid>(byteArray, ref index); this.FragmentDataElementSize = BasicObject.Parse<Compact64bitInt>(byteArray, ref index); this.FragmentFileChunkReference = BasicObject.Parse<FileChunk>(byteArray, ref index); this.FragmentData = BasicObject.Parse<BinaryItem>(byteArray, ref index); if (index - currentIndex != lengthOfItems) { throw new StreamObjectParseErrorException(currentIndex, "DataElementFragment", "Stream object over-parse error", null); } currentIndex = index; }
/// <summary> /// This method is used to deserialize the items of the content tag knowledge entry from the byte array. /// </summary> /// <param name="byteArray">Specify the byte array.</param> /// <param name="currentIndex">Specify the start index from the byte array.</param> /// <param name="lengthOfItems">Specify the current length of items in the content tag knowledge entry.</param> protected override void DeserializeItemsFromByteArray(byte[] byteArray, ref int currentIndex, int lengthOfItems) { int index = currentIndex; this.BLOBHeapExtendedGUID = BasicObject.Parse<ExGuid>(byteArray, ref index); this.ClockData = BasicObject.Parse<BinaryItem>(byteArray, ref index); if (index - currentIndex != lengthOfItems) { throw new StreamObjectParseErrorException(currentIndex, "ContentTagKnowledgeEntry", "Stream object over-parse error", null); } currentIndex = index; }