public UpdateAction <ManageableMarketDataSnapshot> PrepareUpdateFrom(ManageableMarketDataSnapshot newSnapshot) { var globalUpdate = _globalValues.PrepareUpdateFrom(newSnapshot._globalValues); var ycActions = _yieldCurves.ProjectStructure(newSnapshot._yieldCurves, (k, va, vb) => va.PrepareUpdateFrom(vb).Wrap <ManageableMarketDataSnapshot>(s => s._yieldCurves[k]), PrepareCurveRemoveAction, PrepareCurveAddAction ); var cubeActions = _volatilityCubes.ProjectStructure(newSnapshot._volatilityCubes, (k, va, vb) => va.PrepareUpdateFrom(vb).Wrap <ManageableMarketDataSnapshot>(s => s._volatilityCubes[k]), PrepareCubeRemoveAction, PrepareCubeAddAction ); var surfaceActions = _volatilitySurfaces.ProjectStructure(newSnapshot._volatilitySurfaces, (k, va, vb) => va.PrepareUpdateFrom(vb).Wrap <ManageableMarketDataSnapshot>(s => s._volatilitySurfaces[k]), PrepareSurfaceRemoveAction, PrepareSurfaceAddAction ); return(globalUpdate.Wrap <ManageableMarketDataSnapshot>(s => s._globalValues) .Concat(UpdateAction <ManageableMarketDataSnapshot> .Create(ycActions)) .Concat(UpdateAction <ManageableMarketDataSnapshot> .Create(cubeActions)) .Concat(UpdateAction <ManageableMarketDataSnapshot> .Create(surfaceActions))); }
private static UpdateAction <ManageableUnstructuredMarketDataSnapshot> PrepareUpdateFrom(MarketDataValueSpecification currSpec, IDictionary <string, ValueSnapshot> currValues, MarketDataValueSpecification newSpec, IDictionary <string, ValueSnapshot> newValues) { var actions = currValues.ProjectStructure(newValues, (k, a, b) => { var newMarketValue = b.MarketValue; return(new UpdateAction <ManageableUnstructuredMarketDataSnapshot>(delegate(ManageableUnstructuredMarketDataSnapshot s) { s._values[currSpec][k].MarketValue = newMarketValue; })); }, (k, v) => PrepareRemoveAction(currSpec, k, v), (k, v) => { var valueSnapshot = v.Clone(); return(new UpdateAction <ManageableUnstructuredMarketDataSnapshot>( delegate(ManageableUnstructuredMarketDataSnapshot s) { s._values[currSpec].Add(k, valueSnapshot.Clone()); s.InvokePropertyChanged("Values"); })); }); UpdateAction <ManageableUnstructuredMarketDataSnapshot> ret = UpdateAction <ManageableUnstructuredMarketDataSnapshot> .Create(actions); if (!currSpec.Equals(newSpec)) {//we need to update the key, since we used a non standard comparer ret = ret.Concat( new UpdateAction <ManageableUnstructuredMarketDataSnapshot>(delegate(ManageableUnstructuredMarketDataSnapshot s) { var prevValue = s._values[currSpec]; s.Values[newSpec] = prevValue; s._values.Remove(currSpec); s.InvokePropertyChanged("Values"); }) ); } return(ret); }