public static WidgetInstance Load(Database db, System.Data.DataRow row) { var rowid = row.GetLong("rowid"); var fullName = row.GetString("name"); var type = WidgetManager.GetTypeFromFullName(fullName); if (type == null) { throw new WidgetLoadException(string.Format("A widget with the name '{0}' cannot be found.", fullName)); } var bounds = new Rectangle(row.GetInt("bounds_left"), row.GetInt("bounds_top"), row.GetInt("bounds_width"), row.GetInt("bounds_height")); var settings = new WidgetConfig(); foreach (System.Data.DataRow settingRow in db.SelectDataTable("select name, value from widget_config where widget_id = @id", "@id", rowid).Rows) { var name = settingRow.GetString("name"); if (string.IsNullOrEmpty(name)) { continue; } settings.Add(new WidgetConfigItem(name, settingRow.GetString("value"))); } return(new WidgetInstance(type, bounds, settings)); }