/// <summary>
/// This method is used to create the instance of AbstractChunking.
/// </summary>
/// <param name="nodeObject">Specify the root node object.</param>
/// <returns>The instance of AbstractChunking.</returns>
public static AbstractChunking CreateChunkingInstance(IntermediateNodeObject nodeObject)
{
byte[] fileContent = nodeObject.GetContent().ToArray();
if (EditorsTableUtils.IsEditorsTableHeader(fileContent))
{
return(null);
}
if (ZipHeader.IsFileHeader(fileContent, 0))
{
return(new ZipFilesChunking(fileContent));
}
else
{
// For SharePoint Server 2013 compatible SUTs, always using the RDC Chunking method in the current test suite involved file resources.
if (SharedContext.Current.CellStorageVersionType.MinorVersion >= 2)
{
return(new RDCAnalysisChunking(fileContent));
}
// For SharePoint Server 2010 SP2 compatible SUTs, chunking method depends on file content and size. So first try using the simple chunking.
AbstractChunking returnChunking = new SimpleChunking(fileContent);
List <LeafNodeObject> nodes = returnChunking.Chunking();
if (nodeObject.IntermediateNodeObjectList.Count == nodes.Count)
{
bool isDataSizeMatching = true;
for (int i = 0; i < nodes.Count; i++)
{
if (nodeObject.IntermediateNodeObjectList[i].DataSize.DataSize != nodes[i].DataSize.DataSize)
{
isDataSizeMatching = false;
break;
}
}
if (isDataSizeMatching)
{
return(returnChunking);
}
}
// If the intermediate count number or data size does not equals, then try to use RDC chunking method.
return(new RDCAnalysisChunking(fileContent));
}
}