/// <summary> /// Removes the given Element from the List of SyncIndexElement elements /// if the element could be found /// </summary> /// <param name="element"></param> public void Remove(SyncIndexElementDTO element) { SyncIndexElementDTO foundElement = FindElement(element); if (foundElement != null) { _indexBuffer.elements.Remove(foundElement); _logger.Debug("Removing " + element.ReleativeFilePath + " from index file"); UpdateFile(_indexBuffer); } }
/// <summary> /// Adds new IndexElementDTO to the _index Buffer /// </summary> /// <param name="element"></param> public void AddOrUpdate(SyncIndexElementDTO element) { SyncIndexElementDTO foundElement = FindElement(element); if (foundElement == null) { _logger.Debug("Adding new element " + element.ReleativeFilePath + " to index"); _indexBuffer.elements.Add(element); } else { _logger.Debug("Updating element " + element.ReleativeFilePath + " in index"); foundElement.LocalRevision = element.LocalRevision; foundElement.RemoteRevision = element.RemoteRevision; } UpdateFile(_indexBuffer); }
/// <summary> /// returns the SyncIndex element matching given element is possible /// </summary> /// <param name="element"></param> /// <returns></returns> private SyncIndexElementDTO FindElement(SyncIndexElementDTO element) { return(_indexBuffer.elements.Where(x => x.ElementType == element.ElementType && x.ReleativeFilePath == element.ReleativeFilePath ).FirstOrDefault()); }