public void Serialize_Class_Test() { var source = new MyTestClass { Field1 = 42, Field2 = "Stranger Things" }; var result = AbpCacheData.Serialize(source); result.Type.ShouldBe("Abp.Tests.Runtime.Caching.AbpCacheData_Tests+MyTestClass, Abp.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); result.Payload.ShouldBe("{\"Field1\":42,\"Field2\":\"Stranger Things\"}"); }
public void Serialize_List_Test() { List <string> source = new List <string> { "Stranger Things", "The OA", "Lost in Space" }; var result = AbpCacheData.Serialize(source); result.Type.ShouldStartWith("System.Collections.Generic.List`1[[System.String,"); result.Payload.ShouldBe("[\"Stranger Things\",\"The OA\",\"Lost in Space\"]"); }
/// <summary> /// Produce a string representation of the supplied object. /// </summary> /// <param name="value">Instance to serialize.</param> /// <param name="type">Type of the object.</param> /// <returns>Returns a string representing the object instance that can be placed into the Redis cache.</returns> /// <seealso cref="IRedisCacheSerializer.Deserialize" /> public virtual string Serialize(object value, Type type) { return(JsonConvert.SerializeObject(AbpCacheData.Serialize(value))); }