示例#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);
     }
 }
示例#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);
     }
 }
示例#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());
            }
        }