Beispiel #1
0
 public void AddUpdate(UpdateDto update)
 {
     if (Utils.Version.IsPatch(update.From))
     {
         throw new ProviderException("Update patch must be 0.");
     }
     if (repository.updates.Any(x => x.To == update.To))
     {
         throw new ProviderException("Update already added.");
     }
     repository.updates.Add(update);
     repository.Save();
 }
Beispiel #2
0
        public List <UpdateDto> GetUpdates(int from)
        {
            List <UpdateDto> updates = new List <UpdateDto>();

            if (from == Version)
            {
                return(updates);
            }
            from = Utils.Version.RemovePatch(from);
            int current = Version;
            int len     = 0;

            while (true)
            {
                UpdateDto update = repository.updates.SingleOrDefault(x => x.To == current);
                if (update == null)
                {
                    return(null);
                }
                updates.Add(update);
                if (Utils.Version.IsPatch(current))
                {
                    current = Utils.Version.RemovePatch(current);
                }
                else
                {
                    current = Utils.Version.Previous(current);
                }
                if (current == from)
                {
                    return(updates);
                }
                ++len;
                if (len > 5)
                {
                    return(null);
                }
            }
        }