Esempio n. 1
0
 public bool UpdateList(string key, string value)
 {
     if (!string.IsNullOrEmpty(key) && !string.IsNullOrWhiteSpace(key) &&
         ContentList != null && ContentList.ContainsKey(key))
     {
         ContentList[key] = value;
         return(true);
     }
     return(false);
 }
Esempio n. 2
0
 public bool RemoveList(string key)
 {
     if (!string.IsNullOrEmpty(key) && !string.IsNullOrWhiteSpace(key) &&
         ContentList != null && ContentList.ContainsKey(key))
     {
         ContentList.Remove(key);
         OnPropertyChanged();
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
        public bool AddList(string key, string value)
        {
            if (ContentList == null)
            {
                ContentList = new ObservableDictionary <string, string>();
            }

            if (!string.IsNullOrEmpty(key) && !string.IsNullOrWhiteSpace(key) &&
                !string.IsNullOrEmpty(value) && !string.IsNullOrWhiteSpace(value) &&
                ContentList != null && !ContentList.ContainsKey(key))
            {
                ContentList.Add(key, value);
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        public void TestMethod1()
        {
            string assemblyPath = Assembly.GetExecutingAssembly().Location;
            string workDirPath  = Path.GetDirectoryName(assemblyPath);
            string dbPath       = Path.Combine(workDirPath, "testdb.sqlite");
            var    contentList  = new ContentList(dbPath);

            contentList.Clear();
            string testPath      = assemblyPath;
            var    testTimestamp = File.GetLastWriteTime(testPath).ToUnixTimestamp();

            contentList.Add(testPath, testTimestamp, removed: false);
            Assert.IsTrue(contentList.ContainsKey(testPath));
            Assert.AreEqual(1, contentList.Count);
            Assert.AreEqual(contentList.Keys.First(), testPath);
            Assert.IsTrue(contentList.TryGetValue(testPath, out int storedTimestamp, out bool removed));
            Assert.AreEqual(testTimestamp, storedTimestamp);
            contentList.Remove(testPath);
            Assert.AreEqual(0, contentList.Count);
            contentList.Dispose();
            File.Delete(dbPath);
        }