/// <summary> /// Recreates a <see cref="Trade"/> from a <see cref="TradeStore"/>. /// </summary> /// <param name="store"><see cref="TradeStore"/> to create from</param> /// <returns>Recreated <see cref="Trade"/></returns> public static Trade FromTradeStore(TradeStore store) { return(new Trade( tradeId: store.TradeId, partyUuids: store.PartyUuids, itemsOnOffer: store.ItemsOnOffer.ToDictionary(pair => pair.Key, pair => pair.Value.Things.ToArray()), acceptedParties: store.AcceptedParties )); }
/// <summary> /// Convert to a <see cref="TradeStore"/>. /// </summary> /// <returns>Converted <see cref="TradeStore"/></returns> public static TradeStore ToTradeStore(Trade trade) { // Fill out the majority of the store TradeStore store = new TradeStore { TradeId = trade.TradeId, PartyUuids = { trade.PartyUuids }, AcceptedParties = { trade.AcceptedParties } }; // Add the items on offer foreach (KeyValuePair <string, ProtoThing[]> pair in trade.ItemsOnOffer) { store.ItemsOnOffer.Add(pair.Key, new ProtoThings { Things = { pair.Value } }); } return(store); }