public void Delete(Int32 position) { int wsCount = _worksheets.Values.Count(w => w.Position == position); if (wsCount == 0) { throw new ArgumentException("There isn't a worksheet associated with that index."); } if (wsCount > 1) { throw new ArgumentException( "Can't delete the worksheet because there are multiple worksheets associated with that index."); } var ws = _worksheets.Values.Single(w => w.Position == position); if (!String.IsNullOrWhiteSpace(ws.RelId) && !Deleted.Contains(ws.RelId)) { Deleted.Add(ws.RelId); } _worksheets.RemoveAll(w => w.Position == position); _worksheets.Values.Where(w => w.Position > position).ForEach(w => w._position -= 1); _workbook.UnsupportedSheets.Where(w => w.Position > position).ForEach(w => w.Position -= 1); _workbook.InvalidateFormulas(); ws.Cleanup(); }
public bool Remove(int key) { if (!Deleted.ContainsKey(key)) { Deleted.Add(key, _dictionary[key]); } return(_dictionary.Remove(key)); }
public void RemoveAll(Func <XLRow, Boolean> predicate) { foreach (var row in _dictionary.Values.Where(predicate).Where(row1 => !Deleted.ContainsKey(row1.RowNumber()))) { Deleted.Add(row.RowNumber(), row); } _dictionary.RemoveAll(predicate); }
public bool Remove(KeyValuePair <int, XLRow> item) { if (!Deleted.ContainsKey(item.Key)) { Deleted.Add(item.Key, _dictionary[item.Key]); } return(_dictionary.Remove(item.Key)); }
private void AddDeletedEvent(SystemEntity obj) { if (Deleted.All(info => info.ObjectBase != obj)) { EventInfo eventInfo = obj.GetEventInfo(); Deleted.Add(eventInfo); eventInfo.PreTransactionHandled = true; eventInfo.Publish(this, typeof(IOnDeleting <>), (info, ses, t) => info.GetTypedInfo(t).ToDeletingArgs(ses, t)); } }
private void DeleteVM(QuestionViewModel obj) { var indexOf = QuestionViewModels.IndexOf(obj); QuestionViewModels.Remove(obj); EntityViewModel.QuestionViewModels.Remove(obj); for (int i = indexOf; i < QuestionViewModels.Count; i++) { QuestionViewModels[i].Order = i + 1; } Deleted.Add(obj); }
public void Delete(string pictureName) { var picturesToDelete = _pictures .Where(picture => picture.Name.Equals(pictureName, StringComparison.OrdinalIgnoreCase)) .ToList(); foreach (var picture in picturesToDelete) { if (!string.IsNullOrEmpty(picture.RelId)) { Deleted.Add(picture.RelId); } _pictures.Remove(picture); } }
public void Remove(Int32 row, Int32 column) { Count--; var rowRemoved = DecrementUsage(RowsUsed, row); var columnRemoved = DecrementUsage(ColumnsUsed, column); if (rowRemoved && row == MaxRowUsed) { MaxRowUsed = RowsUsed.Keys.Any() ? RowsUsed.Keys.Max() : 0; } if (columnRemoved && column == MaxColumnUsed) { MaxColumnUsed = ColumnsUsed.Keys.Any() ? ColumnsUsed.Keys.Max() : 0; } if (Deleted.TryGetValue(row, out HashSet <Int32> delHash)) { if (!delHash.Contains(column)) { delHash.Add(column); } } else { delHash = new HashSet <int>(); delHash.Add(column); Deleted.Add(row, delHash); } if (RowsCollection.TryGetValue(row, out Dictionary <Int32, XLCell> columnsCollection)) { columnsCollection.Remove(column); if (columnsCollection.Count == 0) { RowsCollection.Remove(row); } } }
public bool Diff(object prev, object cur, string parent = null) { Contract.Requires(prev != null); Contract.Requires(cur != null); var prevObj = ToJObject(prev); var curObj = ToJObject(cur); // Added and modified foreach (var curProp in EnumerateProperties(curObj)) { var prevProp = GetProperty(prevObj, curProp.Name); var key = curProp.Name; var prefix = parent == null ? string.Empty : parent; if (IsArray(prevObj)) { key = "[" + key + "]"; // We have a parent that's an array, use brackets } else if (parent != null) { prefix += "."; // We have a parent that's not an array, use dot notation } if (prevProp == null) // Property just created now { Added.Add(prefix + key, curProp.Value); continue; } // Property already exists if (IsValue(curProp.Value)) { if (object.Equals(curProp.Value, prevProp.Value)) { continue; // Values are the same, no change here } Modified.Add(prefix + key, curProp.Value); continue; } // This is an object Diff(prevProp.Value, curProp.Value, prefix + key); } // Deleted foreach (var prevProp in EnumerateProperties(prevObj).Where(x => !EnumerateProperties(curObj).Any(y => y.Name == x.Name))) { var key = prevProp.Name; var prefix = parent == null ? string.Empty : parent; if (IsArray(prev)) { key = "[" + key + "]"; } else if (parent != null) { prefix += "."; } Deleted.Add(prefix + key); } IsDifferent = Added.Count + Modified.Count + Deleted.Count > 0; return(IsDifferent); }