public void MoveToFront(T item) { var removed = Remove(item); Asrt.True(removed, "Item must be present to move it."); AddToFront(item); }
public Snapshot CreateSnapshot() { LogFile.Debug("Create snapshot."); Asrt.True(_isEnabled, "Tracker is disabled, did you forget to enable it?"); return(new Snapshot(_changeHistory.Count)); }
private static void Fail() { var enable = (bool?)CallContext.GetData(EnableKey); if (enable != true) { return; } Asrt.Fail("Usage of a non initialized Trackable<> or TrackableList<> detected!"); }
public void RollbackToSnapshot(Snapshot snapshot) { LogFile.Debug("Restore from snapshot."); Asrt.True(_isEnabled, "Tracker is disabled, did you forget to enable it?"); while (_changeHistory.Count > snapshot.History) { var action = _changeHistory.Pop(); action(); } }
public void Disable() { Asrt.True(_changeHistory.Count == 0, String.Format( "Disabling a change tracker with history ({0}) is not allowed. This is a common indication of an incorrect object copy.", _changeHistory.Count)); _isEnabled = false; _changeHistory.Clear(); Guard.Disable(); }
public static IList <T> ShuffleInPlace <T>(this IList <T> list, IList <int> permutation) { Asrt.True(permutation.Count == list.Count, "Permutation and list must be of equal lenghts."); var listCopy = list.ToArray(); for (var i = 0; i < permutation.Count; i++) { list[permutation[i]] = listCopy[i]; } return(list); }
public ParameterlessCtor GetCtor(Type type) { lock (_ctorLock) { ParameterlessCtor ctor; if (_ctors.TryGetValue(type, out ctor) == false) { ctor = type.GetParameterlessCtor(); Asrt.True(ctor != null, String.Format("Type {0} is marked with [Copyable] but is missing a parameterless constructor.", type)); _ctors.Add(type, ctor); } return(ctor); } }
private void AssertNotLocked() { Asrt.True(!_isLocked, "Trying to modify a locked change tracker. This is a common indication of an incorrect object copy."); }