EntryAndPagePair CreateEntryAndPagePairByID(string id)
{
var hashIndex = id.IndexOf("#");
string entryName;
string pageNumberOverride;
if (hashIndex == -1)
{
entryName = id;
pageNumberOverride = null;
}
else
{
entryName = id.Substring(0, hashIndex);
pageNumberOverride = id.Substring(hashIndex + 1);
}
var entry = databaseProvider()[entryName];
if (entry == null)
{
throw new InvalidOperationException(String.Format("Cannot find item named '{0}' in BibTex database", entryName));
}
return new EntryAndPagePair(entry, pageNumberOverride);
}