private void generate(string application, string device, string language) { this._window.updateStatus("Generating..."); using (var db = new DatabaseCon()) { var dbApp = db.getFromDescription <application>(application); var dbLang = db.getFromDescription <language>(language); var errors = db.getFilteredErrors(application, device).ToList(); this.showExportedErrors(db, errors); switch (dbLang.description) { case "C++": this.copyTemplates( dbLang.path_to_templates, dbApp.path_to_output_file, this.generateCPP(db, errors), (uint)errors.Count(), "Template.cpp", "Template.h" ); break; default: throw new Exception($"Unsupported language: {language}"); } } }
/// <summary> /// Gets a filtered set of error codes from the database. /// </summary> /// <param name="db">The database connection.</param> /// <param name="application">The application to filter by.</param> /// <param name="device">The device type to filter by.</param> /// <returns>All error codes that can be used by the chosen application and device type.</returns> public static IQueryable <error_code> getFilteredErrors(this DatabaseCon db, string application, string device) { var dbApp = db.getFromDescription <application>(application); var dbDevice = db.getFromDescription <device_type>(device); // These are variables since LINQ doesn't like it when I do it inside the query. var dbAppBit = (1 << dbApp.bit_index); var dbDevBit = (1 << dbDevice.bit_index); var query = from error in db.error_code where ((error.application_ids & dbAppBit) > 0 || error.application_ids == 0) && ((error.device_ids & dbDevBit) > 0 || error.device_ids == 0) select error; return(query); }