Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public IDiaryItem Update(IDiaryItem item)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 public Dictionary <Guid, IDiaryItem> Read(IDiaryItem item)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 8
0
 public bool Delete(IDiaryItem item)
 {
     throw new NotImplementedException();
 }