public IInfoReport Subtract(IInfoReport targetFromThisObject) { // Value - targetFromThisObject.Value int newID; double newTimestamp; ILocation newLocation; bool sameNode; if (targetFromThisObject.ID == _id) { sameNode = true; newID = _id; newLocation = _location; } else { sameNode = false; newID = int.MaxValue; newLocation = null; } if (targetFromThisObject.Time > _timestamp) newTimestamp = targetFromThisObject.Time; else newTimestamp = _timestamp; if (targetFromThisObject is DoubleInfoReport) { DoubleInfoReport target = (DoubleInfoReport)targetFromThisObject; DoubleInfoReport output = new DoubleInfoReport(newID, newTimestamp, _key, _label, Value - target.Value); output._location = newLocation; return output; } else return null; }
/* / \ * // | \\ * / | \ * | */ public IInfoReport Add(IInfoReport withTarget) { int newID; double newTimestamp; ILocation newLocation; bool sameNode; if (withTarget.ID == _id) { sameNode = true; newID = _id; newLocation = _location; } else { sameNode = false; newID = int.MaxValue; newLocation = null; } if (withTarget.Time > _timestamp) newTimestamp = withTarget.Time; else newTimestamp = _timestamp; if (withTarget is DoubleInfoReport) { DoubleInfoReport target = (DoubleInfoReport)withTarget; DoubleInfoReport output = new DoubleInfoReport(newID, newTimestamp, _key, _label, Value + target.Value); output._location = newLocation; return output; } else return null; }