Exemplo n.º 1
0
 public TagsToSerialize readTagsFromFile()
 {
     try
     {
         using (StreamReader r = new StreamReader(currentPath + directory_path + file_path))
         {
             string          json = r.ReadToEnd();
             TagsToSerialize tags = JsonConvert.DeserializeObject <TagsToSerialize>(json);
             return(tags);
         }
     } catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 public bool writeTagsToFile(TagsToSerialize tags)
 {
     try
     {
         using (StreamWriter file = File.CreateText(currentPath + directory_path + file_path))
         {
             JsonSerializer serializer = new JsonSerializer();
             //serialize object directly into file stream
             serializer.Serialize(file, tags);
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 3
0
        public Tag[] getTags()
        {
            lock (tags)
            {
                if (tags.Count == 0)
                {
                    tagsToSer = tagIO.readTagsFromFile();
                    if (tagsToSer != null)
                    {
                        processLoadedTags();
                    }
                    else
                    {
                        tagsToSer = new TagsToSerialize();
                    }
                }

                return(tags.Values.ToArray());
            }
        }