/// <summary> /// Obtains a partial database in the case that the parsing fails /// by throwing a DatabaseLoadingException during parsing. /// </summary> /// <param name="filename">The file to parse.</param> /// <returns>A complete or partial database.</returns> public static async Task <DBCFile> TryParseDatabaseAsync(string filename) { DBCFile file; try { file = new DBCFile(filename, false); await file.CreateLibraryDBCAsync(); } catch (DatabaseLoadingException e) { if (e.Data.Contains("Partial Database")) { file = (DBCFile)e.Data["Partial Database"]; } else { file = null; } } return(file); }
/// <summary> /// Obtains a partial database in the case that the parsing fails /// by throwing a DatabaseLoadingException during parsing. /// </summary> /// <param name="filename">The file to parse.</param> /// <param name="partial">An argument that will be assigned false if the file is parsed completely.</param> /// <returns>A complete or partial database.</returns> public static DBCFile TryParseDatabase(string filename, out bool partial) { DBCFile file; try { file = new DBCFile(filename); partial = false; } catch (DatabaseLoadingException e) { if (e.Data.Contains("Partial Database")) { file = (DBCFile)e.Data["Partial Database"]; partial = true; } else { file = null; partial = false; } } return(file); }
/// <summary> /// /// </summary> /// <param name="message"></param> /// <param name="inner"></param> /// <param name="file"></param> /// <param name="fileLine"></param> public DatabaseLoadingException(string message, Exception inner, DBCFile file, string fileLine = "") : base(message, inner) { partialDatabase = file; this.fileLine = fileLine; }
/// <summary> /// /// </summary> /// <param name="file"></param> /// <param name="fileLine"></param> public DatabaseLoadingException(DBCFile file, string fileLine = "") { partialDatabase = file; this.fileLine = fileLine; }