private void CacheCodeBlocks() { _CodeBlockCache.Clear(); CodeBlocksLoaded = false; if (_FilesValid) { using (var connection = CreateOpenConnection()) { Sql.RunSql(connection, null, "SELECT [BitMask]" + " ,[SignificantBitMask]" + " ,[IsMilitary]" + " ,[Country]" + " FROM [CodeBlockView]", null, (reader) => { var cacheEntry = new CodeBlockBitMask() { BitMask = Sql.GetInt32(reader, 0), SignificantBitMask = Sql.GetInt32(reader, 1), CodeBlock = new CodeBlock() { IsMilitary = Sql.GetBool(reader, 2), Country = Sql.GetString(reader, 3), }, }; _CodeBlockCache.Add(cacheEntry); return(true); }, false, null); } } CodeBlocksLoaded = _CodeBlockCache.Count > 0; _CodeBlockCache.Sort((CodeBlockBitMask lhs, CodeBlockBitMask rhs) => { return(-(lhs.SignificantBitMask - rhs.SignificantBitMask)); }); }
private void CacheCodeBlocks() { _CodeBlockCache.Clear(); CodeBlocksLoaded = false; if(_FilesValid) { using(var connection = CreateOpenConnection()) { Sql.RunSql(connection, null, "SELECT [BitMask]" + " ,[SignificantBitMask]" + " ,[IsMilitary]" + " ,[Country]" + " FROM [CodeBlockView]", null, (reader) => { var cacheEntry = new CodeBlockBitMask() { BitMask = Sql.GetInt32(reader, 0), SignificantBitMask = Sql.GetInt32(reader, 1), CodeBlock = new CodeBlock() { IsMilitary = Sql.GetBool(reader, 2), Country = Sql.GetString(reader, 3), }, }; _CodeBlockCache.Add(cacheEntry); return true; }, false, null); } } CodeBlocksLoaded = _CodeBlockCache.Count > 0; _CodeBlockCache.Sort((CodeBlockBitMask lhs, CodeBlockBitMask rhs) => { return -(lhs.SignificantBitMask - rhs.SignificantBitMask); }); }