Ejemplo n.º 1
0
        public void Deserialize_List_Test()
        {
            var json      = "{\"Payload\":\"[\\\"Stranger Things\\\",\\\"The OA\\\",\\\"Lost in Space\\\"]\",\"Type\":\"System.Collections.Generic.List`1[[System.String]]\"}";
            var cacheData = AbpCacheData.Deserialize(json);

            cacheData.ShouldNotBeNull();
        }
Ejemplo n.º 2
0
        public void Deserialize_Class_Test()
        {
            var json = "{\"Payload\": \"{\\\"Field1\\\": 42,\\\"Field2\\\":\\\"Stranger Things\\\"}\",\"Type\":\"Abp.Tests.Runtime.Caching.AbpCacheData_Tests+MyTestClass, Abp.Tests\"}";

            var cacheData = AbpCacheData.Deserialize(json);

            cacheData.ShouldNotBeNull();
        }
        /// <summary>
        ///     Creates an instance of the object from its serialized string representation.
        /// </summary>
        /// <param name="objbyte">String representation of the object from the Redis server.</param>
        /// <returns>Returns a newly constructed object.</returns>
        /// <seealso cref="IRedisCacheSerializer.Serialize" />
        public virtual object Deserialize(string objbyte)
        {
            var serializerSettings = new JsonSerializerSettings();

            serializerSettings.Converters.Insert(0, new AbpDateTimeConverter());

            var cacheData = AbpCacheData.Deserialize(objbyte);

            return(cacheData.Payload.FromJsonString(
                       Type.GetType(cacheData.Type, true, true),
                       serializerSettings));
        }