/// <summary>Checks the validity of all Table definitions</summary> /// <returns>The amount of invalid columns.</returns> public static int Check(Action <string> feedbackCallback) { ContentMgr.EnsureInitialized(); int num = 0; foreach (LightDBMapper lightDbMapper in ContentMgr.s_mappersByType.Values) { foreach (TableDefinition tableDefinition in lightDbMapper.Mapping.TableDefinitions) { foreach (SimpleDataColumn columnDefinition in tableDefinition.ColumnDefinitions) { if (!columnDefinition.IsEmpty) { try { using (lightDbMapper.Wrapper.Query(SqlUtil.BuildSelect(new string[1] { columnDefinition.ColumnName }, tableDefinition.Name, "LIMIT 1"))) ; } catch (Exception ex) { feedbackCallback(string.Format("Invalid column \"{0}\" in table \"{1}\": {2}", (object)columnDefinition, (object)tableDefinition.Name, (object)ex.GetAllMessages().ToString <string>("\n\t"))); ++num; } } } } } return(num); }
/// <summary>Fetches all content of all registered DataHolders.</summary> public static void FetchAll() { ContentMgr.EnsureInitialized(); foreach (LightDBMapper lightDbMapper in ContentMgr.s_mappersByType.Values) { lightDbMapper.Fetch(); } }
public static LightDBMapper GetMapper(Type t) { ContentMgr.EnsureInitialized(); LightDBMapper lightDbMapper; if (!ContentMgr.s_mappersByType.TryGetValue(t, out lightDbMapper)) { throw new Exception(string.Format( "DataHolder Type \"{0}\" was not registered - Make sure that it's XML definition was defined and associated correctly. If the Type is not in the Core, call ContentHandler.Initialize(Assembly) on its Assembly first.", (object)t.FullName)); } return(lightDbMapper); }
/// <summary> /// Ensures that the DataHolder of the given type and those that are connected with it, are loaded. /// /// </summary> /// <param name="force">Whether to re-load if already loaded.</param> public static bool Load <T>(bool force) where T : IDataHolder { ContentMgr.EnsureInitialized(); LightDBMapper mapper = ContentMgr.GetMapper <T>(); if (!force && mapper.Fetched) { return(false); } if (force && mapper.IsCached()) { mapper.FlushCache(); } ContentMgr.Load(mapper); return(true); }
public static void SaveStubs(Assembly asm) { ContentMgr.EnsureInitialized(); LightDBMgr.SaveAllStubs(Path.Combine(ContentMgr.s_implementationRoot, ".stubs"), (IEnumerable <DataHolderDefinition>)DataHolderMgr.CreateDataHolderDefinitionArray(asm)); }