public DeserializeBlockFromZippedXML ( String zipFilePath, String blockFileName ) : |
||
zipFilePath | String | |
blockFileName | String | |
return |
public Block DeserializeBlockFromZippedXML(String zipFilePath, String blockFileName)
{
FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Open);
ZipInputStream zippedStream = new ZipInputStream(zipFileStream);
ZipEntry zipEntry;
Block block = null;
while ((zipEntry = zippedStream.GetNextEntry()) != null)
{
if (zipEntry.Name == blockFileName)
{
block = (Block)xmls.Deserialize(zippedStream);
break;
}
}
zippedStream.Close();
// the following is a workaround. We took a lot of data before we started recording
// the rfState. Luckily, almost all of this data was taken in the same rf state.
// Here, if no rfState is found in the block it is assigned the default, true.
try
{
bool rfState = (bool)block.Config.Settings["rfState"];
}
catch (Exception)
{
block.Config.Settings.Add("rfState", true);
}
return block;
}
// This method is thread-safe. public void AddBlock(string path, string[] demodulationConfigs) { string[] splitPath = path.Split('\\'); log("Loading block " + splitPath[splitPath.Length - 1]); BlockSerializer bs = new BlockSerializer(); Block b = bs.DeserializeBlockFromZippedXML(path, "block.xml"); AddBlock(b, demodulationConfigs); }