Ejemplo n.º 1
0
        public static IList <SpokenLanguages> LoadType(ResumeDbContext context, string path, Boolean writeJson)
        {
            using (StreamReader r = new StreamReader(path))
            {
                var deserializer = new Deserializer();
                var yamlObject   = deserializer.Deserialize(r);

                var serializer = new Newtonsoft.Json.JsonSerializer();
                serializer.Formatting = Newtonsoft.Json.Formatting.Indented;

                string json;
                using (StringWriter w = new StringWriter())
                {
                    serializer.Serialize(w, yamlObject);
                    json = w.ToString();
                }

                if (writeJson)
                {
                    string jsonPath = path.Replace("yml", "json");
                    using (StreamWriter w2 = new StreamWriter(jsonPath))
                    {
                        w2.Write(json);
                    }
                }

                // string json = r.ReadToEnd();

                SpokenLanguagesJson spokenLanguages = JsonConvert.DeserializeObject <SpokenLanguagesJson>(json);
                context.Add(spokenLanguages.SpokenLanguages);
                return(spokenLanguages.SpokenLanguages);
            }
        }
Ejemplo n.º 2
0
 public static SpokenLanguagesJson LoadJson(string path)
 {
     using (StreamReader r = new StreamReader(path))
     {
         string json = r.ReadToEnd();
         SpokenLanguagesJson resume = JsonConvert.DeserializeObject <SpokenLanguagesJson>(json);
         return(resume);
     }
 }