public static bool Initialize() { List <FishType> fisht = FishType.GetFishTypes(); if (fisht.Count == 0) { var assembly = IntrospectionExtensions.GetTypeInfo(typeof(Record)).Assembly; Stream stream = assembly.GetManifestResourceStream("AlienScale.StaticResources.JSON.FirstUse.json"); //get info from json using (var reader = new System.IO.StreamReader(stream)) { var json = reader.ReadToEnd(); try { var result = JsonConvert.DeserializeObject <IEnumerable <Record> >(json); var records = result as List <Record>; foreach (var rec in records) { FishType ft = new FishType() { TypeName = rec.typename, TypeDescription = rec.typedescription }; FishType.Insert(ft); } } catch (Exception ex) { } } } return(true); }
public bool UpdateFishTypes() { try { var types = FishType.GetFishTypes(); if (types != null) { FishTypes.Clear(); foreach (var type in types) { FishTypes.Add(type); } } return(true); } catch (Exception) { return(false); } }