Ensure accessor is open before trying to use it

This commit is contained in:
Michael Becker 2014-11-14 10:51:24 -05:00
parent 8bbae10613
commit 4c9b303d1c

View File

@ -1157,6 +1157,14 @@ namespace UniversalEditor.Common
}
public static DataFormatReference[] GetAvailableDataFormats(Accessor accessor)
{
bool needsOpen = false;
if (!accessor.IsOpen)
{
// we need to open the accessor before we can sniff the file
needsOpen = true;
accessor.Open();
}
List<DataFormatReference> list = new List<DataFormatReference>();
DataFormatReference[] dfs = GetAvailableDataFormats();
foreach (DataFormatReference df in dfs)
@ -1171,6 +1179,12 @@ namespace UniversalEditor.Common
}
}
list.Sort(new Comparison<DataFormatReference>(_DataFormatReferenceComparer));
if (needsOpen)
{
// close the accessor since we're done with it
accessor.Close();
}
return list.ToArray();
}