private void Load()
 {
     if (!File.Exists(fileName))
       {
     File.WriteAllText(fileName, "");
     keyValues = new EsuInfoCollection<EsuKeyValue>();
       }
       var data = File.ReadAllText(fileName);
       data = data.Decrypt();
       keyValues = data.Load<EsuInfoCollection<EsuKeyValue>>();
       if (keyValues == null)
       {
     keyValues = new EsuInfoCollection<EsuKeyValue>();
     if (keys != null)
     {
       foreach (var key in keys)
       {
     if (!keyValues.Any(a => a.Key.Equals(key, StringComparison.InvariantCultureIgnoreCase)))
     {
       keyValues.Add(new EsuKeyValue {Key = key});
     }
       }
     }
       }
 }
        public void TestDataChange()
        {
            var collection = new EsuInfoCollection<TestData>
              {
            EsuInfoBase.InitailizeDefaultData<TestData>(),
            EsuInfoBase.InitailizeDefaultData<TestData>()
              };

              Assert.IsTrue(collection.HasChanged);
              Assert.AreEqual(collection.ChangedCollection.Count, 2);

              collection.Remove(collection[0]);
              Assert.AreEqual(collection.ChangedCollection.Count, 2);

              collection[0].Description = "Test1";
              Assert.AreEqual(collection.ChangedCollection.Count, 2);

              collection.AcceptChanges();
              Assert.IsFalse(collection.HasChanged);

              TestData data = collection[0];
              data.Description = "Test2";

              Assert.AreEqual(collection.ChangedCollection.Count, 1);
        }
示例#3
0
 private void LoadRegisties()
 {
     registries = new EsuInfoCollection<EsuInfoBase>();
       foreach (var key in keys)
       {
     var value = Registry.LocalMachine.GetValue(key) ?? "";
     registries.Add(new EsuInfoBase { ID = key, Description = value.ToString() });
       }
 }
示例#4
0
 public static EsuInfoCollection<TestData> GetTestDataCollection(int count)
 {
     var collection = new EsuInfoCollection<TestData>();
       for (int i = 0; i < count; i++)
       {
     collection.Add(new TestData { ID = i.ToString(CultureInfo.InvariantCulture), Name = "Name:" + i });
       }
       return collection;
 }
示例#5
0
 private HomeViewModel()
 {
   progress = new EsuProgressViewModel();
   var uri = new Uri("Functionalities.xml", UriKind.Relative);
   functionCollection = uri.ReadXmlFromLocalSource<EsuInfoCollection<FunctionModel>>();
   foreach (FunctionModel model in functionCollection)
     model.ClickAction = new DelegateCommand<FunctionModel>(FunctionClick);
   TurnToPage(functionCollection.Count - 1);
 }
示例#6
0
 public void Load()
 {
   IReadService service = new WcfClientAddressBase<ReadServiceClient>("../ReadService.svc").GetService();
   HomeViewModel.Instance.Progress.ShowProgress("正在获取下载列表...");
   service.BeginGetDownloads(ThreadHelper.SyncContextCallback(ar => Globals.ProcessAsyncServiceData(() =>
   {
     string result = service.EndGetDownloads(ar);
     Collection = result.Load<EsuInfoCollection<Links>>();
   })), null);
 }
 public TestModel()
 {
     collection = new EsuInfoCollection<TestData>();
       for (int i = 0; i < 10; i++)
       {
     collection.Add(new TestData {ID = i.ToString(), Description = "Description"});
       }
       collection.CurrentItemChanged = s =>
       {
     text = s.ID;
     NotifyOfPropertyChange(() => Text);
       };
 }
 public void TestCheck()
 {
     var collection = new EsuInfoCollection<TreeData>();
       collection.Add(new TreeData("1", "0"));
       collection.Add(new TreeData("2", "1"));
       collection.Add(new TreeData("3", "1"));
       collection.Add(new TreeData("4", "0"));
       collection.Add(new TreeData("5", "4"));
       var item = collection[0];
       item.IsChecked = true;
       item.Check(collection);
       Assert.IsTrue(collection[1].IsChecked);
       Assert.IsTrue(collection[2].IsChecked);
       Assert.IsFalse(collection[3].IsChecked);
       Assert.IsFalse(collection[4].IsChecked);
       Console.WriteLine(collection.ToString());
       item.IsChecked = false;
       item.Check(collection);
       Assert.IsFalse(collection[1].IsChecked);
       Assert.IsFalse(collection[2].IsChecked);
       Assert.IsFalse(collection[3].IsChecked);
       Assert.IsFalse(collection[4].IsChecked);
       Console.WriteLine(collection.ToString());
 }