public bool Load(string XmlFilePath) { if (!System.IO.File.Exists(XmlFilePath)) { throw new ArgumentException("Argument XmlFilePath must contain a valid path to a XML file."); } XDocument xmlRepo; xmlRepo = XDocument.Load(XmlFilePath); Dictionary <Guid, IDiaryItem> tmpRepo = new Dictionary <Guid, IDiaryItem>(); foreach (XElement item in xmlRepo.Root.Elements("item")) { Dictionary <string, string[]> itemDataDict = new Dictionary <string, string[]>(); foreach (XElement itemProperty in item.Elements("property")) { List <string> values = new List <string>(); foreach (XElement propertyValue in itemProperty.Elements("value")) { values.Add(propertyValue.Value); } itemDataDict.Add(itemProperty.Attribute("name").Value, values.ToArray()); } IDiaryItem diaryItem = Global.classFactory.Create <IDiaryItem>(itemDataDict); tmpRepo.Add(diaryItem.guid, diaryItem); } this.repository = tmpRepo; return(true); }
public DiaryItem(IDiaryItem diaryItem) { this.guid = diaryItem.guid; this.title = diaryItem.title; this.description = diaryItem.description; this.dateTimeStart = diaryItem.dateTimeStart; this.dateTimeEnd = diaryItem.dateTimeEnd; this.labels = diaryItem.labels; }
public bool Delete(IDiaryItem item) { if (repository == null) { throw new InvalidOperationException("Repository is null."); } if (repository.ContainsKey(item.guid)) { repository.Remove(item.guid); } return(true); }
public IDiaryItem Create(IDiaryItem item) { if (repository == null) { throw new InvalidOperationException("Repository is null."); } if (!repository.ContainsKey(item.guid)) { repository.Add(item.guid, (IDiaryItem)item.Clone()); } return((IDiaryItem)repository[item.guid].Clone()); }
public IDiaryItem Update(IDiaryItem item) { if (repository == null) { throw new InvalidOperationException("Repository is null."); } if (repository.ContainsKey(item.guid)) { repository[item.guid] = (IDiaryItem)item.Clone(); } var re = Global.classFactory.Create <IDiaryItem>(repository[item.guid]); return(re); }
public IDiaryItem Update(IDiaryItem item) { throw new NotImplementedException(); }
public Dictionary <Guid, IDiaryItem> Read(IDiaryItem item) { throw new NotImplementedException(); }
public bool Delete(IDiaryItem item) { throw new NotImplementedException(); }