public Alice(int numOrders, Guid actorGuid, CustomerModel personalModel) { NumOrders = numOrders; ActorGuid = actorGuid; Money = 1000m; PersonalModel = personalModel; PersonalDataBytes = Helpers.GetBytes(SerializeCustomerModel.SerializeCustomerModelToJson(personalModel)); Ledger = new Dictionary<Guid, List<MoneyOrder>>(); }
/// <summary> /// Return pretty-printed JSON serialized form of the instance of CustomerModel passed in /// </summary> /// <param name="toSerialize"></param> /// <returns></returns> public static string SerializeCustomerModelToJson(CustomerModel toSerialize) { string serialized = null; try { serialized = JsonConvert.SerializeObject(toSerialize, Formatting.Indented); } catch (JsonSerializationException e) { Console.WriteLine(e.Message); return null; } return serialized; }