public static MessageDatabase From(AbsoluteFilePath filePath) { using (var file = File.Open(filePath.NativePath, FileMode.Open)) using (var reader = new BinaryReader(file)) { var databaseItems = new List <MessageDatabaseItem>(); var name = reader.ReadString(); var count = reader.ReadInt32(); for (var i = 0; i < count; ++i) { databaseItems.Add(MessageDatabaseItem.Read(reader)); } return(new MessageDatabase(name, databaseItems)); } }
public static MessageDatabaseItem Read(BinaryReader reader) { var name = reader.ReadString(); var comment = reader.ReadString(); var example = reader.ReadString(); var isNumber = reader.ReadBoolean(); var numChildren = reader.ReadInt32(); var children = new List <MessageDatabaseItem>(); for (var i = 0; i < numChildren; ++i) { children.Add(MessageDatabaseItem.Read(reader)); } return(new MessageDatabaseItem(name, new PluginCommentAttribute(comment, example, isNumber), children)); }