public static bool TryGetItem(string nome, out RPGItem item) { item = ColecaoItem.Find(x => x.Nome == nome).FirstOrDefault(); if (item == null) { return(false); } return(true); }
public static async Task CarregarItensAsync() { Database.DropCollection("itens"); var Files = Directory.EnumerateFiles(Program.EntrarPasta(@"Data/Itens"), "*.json", SearchOption.AllDirectories); int quant = 0; foreach (var file in Files) { using (var sr = new StreamReader(file)) { var f = Newtonsoft.Json.JsonConvert.DeserializeObject <RPGItem>(sr.ReadToEnd()); await ColecaoItem.InsertOneAsync(f); quant++; } } Console.WriteLine($"{quant} Itens carregados!"); }