示例#1
0
        /// <summary>
        ///获取第三方支持的快递
        /// </summary>
        /// <param name="auth">授权参数</param>
        /// <returns>2018-03-25 罗勤尧</returns>
        public Result <UpGradeExpress> GetExpress(AuthorizationParameters auth)
        {
            var result = new Result <UpGradeExpress>()
            {
                Status = true
            };
            var _param = new Dictionary <string, string>();

            //海外购订单发货
            GeGeJiaDeliverGoods req = new GeGeJiaDeliverGoods();

            //订单类型,0:渠道订单,1:格格家订单,2:格格团订单,3:格格团全球购订单,4:环球捕手订单,5:燕网订单,6:b2b订单,7:手q,8:云店
            string parm = "{\"params\":{},\"partner\":\"" + auth.DealerApp.AppSecret + "\",\"timestamp\":\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"}";

            //MD5加密签名
            string sign = MD5Encrypt(auth.DealerApp.AppKey + parm + auth.DealerApp.AppKey).ToUpper();

            var response  = PostJson("http://openapi.gegejia.com:8902/api/express/names", parm, sign);
            var Assreturn = JsonSerializationHelper.JsonToObject <UpGradeExpress>(response);
            var _response = JObject.Parse(response.ToString());

            //var names = _response.Property("names");
            if (_response.Property("errMsg") != null)
            {
                result.Status  = false;
                result.Message = _response.Property("errMsg").ToString();
                result.errCode = _response.Property("errCode").ToString();
            }
            else
            {
                result.Data    = Assreturn;
                result.Message = "获取成功";
            }
            return(result);
        }
示例#2
0
        private void ThrowApiException(HttpWebResponse webResponse, Stream resultStream)
        {
            try
            {
                resultStream.Position = 0;
                using (var responseReader = new StreamReader(resultStream))
                {
                    var responseData  = responseReader.ReadToEnd();
                    var errorResponse = (ApiErrorResponse)JsonSerializationHelper.Deserialize(responseData, typeof(ApiErrorResponse));

                    if (errorResponse == null)
                    {
                        errorResponse       = new ApiErrorResponse();
                        errorResponse.Error = new HttpWebException(responseData, CommonStatusCode.Error.Code, webResponse.StatusCode);
                    }

                    throw errorResponse.Error;
                }
            }
            catch (HttpWebException)
            {
                throw;
            }
            catch (Exception)
            {
                throw new HttpWebException(webResponse.StatusDescription, CommonStatusCode.Error.Code, webResponse.StatusCode);
            }
        }
        /// <summary>
        /// 利嘉新增商品品牌
        /// </summary>
        /// <param name="info">商品品牌信息</param>
        /// <returns>利嘉商品品牌系统编号</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static int AddLiJiaBrand(LiJiaBrandAdd info)
        {
            //创建新增商品品牌请求参数
            string addds = JsonHelper.ToJson(info);
            //新增商品品牌接口
            string pathAdd  = "brand.add";
            string postData = "";
            int    id       = 0;
            string BraCode  = "";

            try
            {
                string responseAddDsDealer = MainHttpT(host, pathAdd, methodTs, Token, postData, addds);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        id      = Assreturn.BrandId;
                        BraCode = Assreturn.BrandCode;
                    }
                    else
                    {
                        //记录失败日志
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia");
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    }
                }
            }
            catch (Exception ex)
            {
                return(id);
            }
            return(id);
        }
        public override void WriteJson(JsonWriter writer, TImplementation?value, JsonSerializer serializer)
        {
            if (value == null)
            {
                return;
            }

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.Id)));
            serializer.Serialize(writer, value.Id);

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.TotalGoldOwned)));
            serializer.Serialize(writer, value.TotalGoldOwned);

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.UnspentKills)));
            serializer.Serialize(writer, value.UnspentKills);

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.UnspentAssists)));
            serializer.Serialize(writer, value.UnspentAssists);

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.UnspentDeaths)));
            serializer.Serialize(writer, value.UnspentDeaths);

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.TotalKills)));
            serializer.Serialize(writer, value.TotalKills);

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.TotalAssists)));
            serializer.Serialize(writer, value.TotalAssists);

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.TotalDeaths)));
            serializer.Serialize(writer, value.TotalDeaths);
        }
        /// <summary>
        /// 利嘉订单出库发货接口
        /// </summary>
        /// <param name="info">出库信息</param>
        /// <returns>是否成功</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static bool LiJiaOrderInfoTracking(OrderInfoTracking Info)
        {
            //创建出库发货请求参数
            string addds = JsonHelper.ToJson(Info);
            //出库发货接口
            string pathAddPdCa = "orderInfo.tracking";
            string postData    = "";
            string Code        = "";
            bool   Result      = false;

            try
            {
                string responseAddDsDealer = MainHttpT(host, pathAddPdCa, methodTs, Token, postData, addds);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        Result = true;
                    }
                    else
                    {
                        //记录失败日志
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia");
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    }
                }
            }
            catch (Exception ex)
            {
                return(Result);
            }
            return(Result);
        }
        //string postData = "";
        /// <summary>
        /// 利嘉查询商品分类
        /// </summary>
        /// <param name="info">商品分类</param>
        /// <returns>结果对象</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static ResultLiJia SeachLiJiaProductCategory(LiJiaMemberSearch info)
        {
            //创建查询请求参数
            string searchjosn = JsonHelper.ToJson(info);
            //查询接口
            string      searchpath = "category.search";
            string      postData   = "";
            bool        Result     = false;
            ResultLiJia resultList = new ResultLiJia();

            try
            {
                string responseAddDsDealer = MainHttp(host, searchpath, methodTs, Token, postData, searchjosn);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        resultList = Assreturn;
                    }
                    else
                    {
                        //记录失败日志
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(searchjosn, "LiJia");
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    }
                }
            }
            catch (Exception ex)
            {
                return(resultList);
            }
            return(resultList);
        }
        /// <summary>
        /// 利嘉采购入库单
        /// </summary>
        /// <param name="info">采购入库单信息</param>
        /// <returns>利嘉采购入库单系统编号</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static string AddLiJiaPurchaseInfo(LiJiaPurchaseInfo Info)
        {
            //创建新增采购入库单请求参数
            string addds = JsonHelper.ToJson(Info);
            //新增采购入库单接口
            string pathAddPdCa = "purchaseInfo.add";
            string postData    = "";
            string Code        = "";

            try
            {
                string responseAddDsDealer = MainHttpT(host, pathAddPdCa, methodTs, Token, postData, addds);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        Code = Assreturn.PurchaseInboundOrderNo;
                    }
                    else
                    {
                        //记录失败日志
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia");
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    }
                }
            }
            catch (Exception ex)
            {
                return(Code);
            }
            return(Code);
        }
        /// <summary>
        /// 利嘉新增商品分类
        /// </summary>
        /// <param name="info">商品分类信息</param>
        /// <returns>利嘉商品分类系统编号</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static int AddLiJiaProductCategory(ProductCategoryLiJia info)
        {
            //创建新增商品分类请求参数
            string addds = JsonHelper.ToJson(info);
            //新增新增商品分类接口
            string pathAddPdCa = "category.add";
            string postData    = "";
            int    id          = 0;

            try
            {
                string responseAddDsDealer = MainHttpT(host, pathAddPdCa, methodTs, Token, postData, addds);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        id = Assreturn.CategoryId;
                    }
                    else
                    {
                        //记录失败日志
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia");
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    }
                }
            }
            catch (Exception ex)
            {
                return(id);
            }
            return(id);
        }
        //string postData = "";
        /// <summary>
        /// 利嘉修改商品分类
        /// </summary>
        /// <param name="info">商品分类信息</param>
        /// <returns>是否修改成</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static bool UpdateLiJiaProductCategory(CategoryLiJiaEdit info)
        {
            //创建修改商品分类请求参数
            string UpdateJson = JsonHelper.ToJson(info);
            //修改商品分类接口
            string pathUpdateDsDealer = "category.update";
            string postData           = "";
            bool   Result             = false;

            try
            {
                string responseAddDsDealer = MainHttpT(host, pathUpdateDsDealer, methodTs, Token, postData, UpdateJson);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        Result = true;
                    }
                    else
                    {
                        //记录失败日志
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(UpdateJson, "LiJia");
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    }
                }
            }
            catch (Exception ex)
            {
                return(Result);
            }
            return(Result);
        }
示例#10
0
        /// <summary>
        /// 利嘉取消订单
        /// </summary>
        /// <param name="info">订单编号</param>
        /// <returns>是否成功</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static bool CancelLiJiaOrder(LiJiaOrderCancel info)
        {
            //创建新增分销商请求参数
            string addorderstr = JsonHelper.ToJson(info);
            //新增订单接口
            //Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addorderstr, "LiJia");
            string addorderpath = "orderInfo.cancel";
            string postData     = "";
            bool   Result       = false;

            try
            {
                string responseAddDsDealer = MainHttpT(host, addorderpath, methodTs, Token, postData, addorderstr);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    // Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        Result = true;
                    }
                    else
                    {
                        //记录失败日志
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addorderstr, "LiJia");
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    }
                }
            }
            catch (Exception ex)
            {
                return(Result);
            }
            return(Result);
        }
        public override void WriteJson(JsonWriter writer, LeagueItem?value, JsonSerializer serializer)
        {
            if (value == null)
            {
                return;
            }

            var retrievalConfiguration = LgoLeagueItemRetrievalConfiguration.GetCurrentOrDefault();

            writer.WriteStartObject();

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.Id)));
            serializer.Serialize(writer, value.Id);

            if (retrievalConfiguration.IncludeName)
            {
                writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.Name)));
                serializer.Serialize(writer, value.Name);
            }

            if (retrievalConfiguration.IncludePrice)
            {
                writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.Price)));
                serializer.Serialize(writer, value.Price);
            }

            if (retrievalConfiguration.IncludeImage)
            {
                writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.PathToImage)));
                serializer.Serialize(writer, value.PathToImage);
            }

            writer.WriteEndObject();
        }
示例#12
0
        /// <summary>
        /// 快递信息
        /// </summary>
        /// <param name="serverUrl">登录URL</param>
        /// <param name="txtParams">参数</param>
        /// <returns>返回</returns>
        /// <remarks>2017-6-13 罗勤尧 创建</remarks>
        public HaiDaiResultKuaiDi KuaiDiDetail(string serverUrl, IDictionary <string, string> txtParams)
        {
            if (!txtParams.ContainsKey("timestamp"))
            {
                txtParams.Add("timestamp", this.GetTime());
            }
            if (!txtParams.ContainsKey("appkey"))
            {
                txtParams.Add("appkey", this.appkey);
            }
            if (serverUrl.Contains("?"))
            {
                serverUrl = serverUrl.Substring(0, serverUrl.IndexOf('?') + 1);
            }
            Uri    uri          = new Uri(serverUrl);
            string absolutePath = uri.AbsolutePath;
            string encoding     = "utf-8";
            string sign         = this.GetSign(this.method, absolutePath, txtParams, encoding);

            if (!txtParams.ContainsKey("topSign"))
            {
                txtParams.Add("topSign", sign);
            }
            string text = string.Empty;

            text = this.webUtils.DoPost(serverUrl, txtParams);

            return(JsonSerializationHelper.JsonToObject <HaiDaiResultKuaiDi>(text));
        }
示例#13
0
        /// <summary>
        /// 利嘉新增仓库
        /// </summary>
        /// <param name="info">仓库信息</param>
        /// <returns>利嘉仓库系统编号</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static string AddLiJiaStore(LiJiaStoreAdd info)
        {
            //创建新增仓库请求参数
            string addds = JsonHelper.ToJson(info);
            //新增仓库接口
            string pathAddPdCa = "store.add";
            string postData    = "";
            string StoreCode   = "";

            try
            {
                string responseAddDsDealer = MainHttpT(host, pathAddPdCa, methodTs, Token, postData, addds);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        StoreCode = Assreturn.StoreCode;
                    }
                    else
                    {
                        //记录失败日志
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia");
                        Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia");
                    }
                }
            }
            catch (Exception ex)
            {
                return(StoreCode);
            }
            return(StoreCode);
        }
示例#14
0
        //string postData = "";
        /// <summary>
        /// 利嘉修改会员信息
        /// </summary>
        /// <param name="info">会员信息</param>
        /// <returns>是否修改成</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static bool UpdateLiJiaMemerber(DsDealerLiJiaEdit info)
        {
            //创建新增分销商请求参数
            string UpdateJson = JsonHelper.ToJson(info);
            //修改分销商接口
            string pathUpdateDsDealer = "member.update";
            string postData           = "";
            bool   Result             = false;

            try
            {
                string responseAddDsDealer = MainHttpT(host, pathUpdateDsDealer, methodTs, Token, postData, UpdateJson);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        Result = true;
                    }
                }
            }
            catch (Exception ex)
            {
                return(Result);
            }
            return(Result);
        }
示例#15
0
        /// <summary>
        /// Write a json to record all audio tracks we have.
        /// </summary>
        private void GenerateAllAudioList()
        {
            List <string> names             = new List <string>();
            string        audioRootPath     = Application.dataPath + "/Audio/Resources/" + GetAudioRootPath();
            DirectoryInfo rootDirectoryPath = new DirectoryInfo(audioRootPath);

            FileInfo[] fileInfo = rootDirectoryPath.GetFiles("*.*", SearchOption.AllDirectories);
            //Debug.Log("full path " + rootDirectoryPath + _prefixName + "_*.*");

            foreach (FileInfo file in fileInfo)
            {
                // file extension check
                if (file.Extension == ".mp3" || file.Extension == ".wav")
                {
                    string   nameWithFolder = file.Name.Split('.')[0];
                    string[] fullName       = file.FullName.Split('\\');
                    if (fullName[fullName.Length - 2] + '/' != GetAudioRootPath())
                    {
                        nameWithFolder = fullName[fullName.Length - 2] + '\\' + nameWithFolder;
                    }

                    names.Add(nameWithFolder);
                }
            }

            Debug.Log("Update audio track list. Count: " + names.Count);
            if (Directory.Exists(GetStreamingAssetsRootPath()) == false)
            {
                Directory.CreateDirectory(GetStreamingAssetsRootPath());
            }
            JsonSerializationHelper.WriteJsonList <string>(GetStreamingAssetsRootPath() + "/AudioTrackList.json", names);
        }
        public void Save(Config config)
        {
            WritableSettingsStore userSettingsStore = GetSettingsStore();
            var configJson = JsonSerializationHelper.ToJson(config);

            userSettingsStore.SetString(SettingsStoreCollectionPath, SettingsStorePropertyName, configJson);
        }
示例#17
0
        public void TestArrayDeserialization()
        {
            var numericList = JsonSerializationHelper.Deserialize <List <int> >("[1337,-1337,0]");

            Assert.IsNotNull(numericList);
            Assert.AreEqual(3, numericList.Count);

            Assert.AreEqual(1337, numericList[0]);
            Assert.AreEqual(-1337, numericList[1]);
            Assert.AreEqual(0, numericList[2]);

            var stringList = JsonSerializationHelper.Deserialize <List <string> >("[\"the quick brown fox\",\"jumps over the\",\"lazy dog\"]");

            Assert.IsNotNull(stringList);
            Assert.AreEqual(3, stringList.Count);

            Assert.AreEqual("the quick brown fox", stringList[0]);
            Assert.AreEqual("jumps over the", stringList[1]);
            Assert.AreEqual("lazy dog", stringList[2]);

            var groupJson  = "{\"Leader\":{Name:null},{\"Id\":\"" + Guid.NewGuid() + "\",\"Name\":\"Ole\"},Persons:[{Name:\"Jens\"},{\"Name\":\"Ole\"}],Title:\"My group\"}";
            var objectList = JsonSerializationHelper.Deserialize <List <Group> >("[" + groupJson + "," + groupJson + "]");

            Assert.IsNotNull(objectList);
            Assert.AreEqual(2, objectList.Count);
        }
示例#18
0
        public override void WriteJson(JsonWriter writer, TTimer?value, JsonSerializer serializer)
        {
            if (value == null)
            {
                return;
            }

            var retrievalConfiguration = LgoLeaguePowerPlayTimerRetrievalConfiguration.GetCurrentOrDefault();

            writer.WriteStartObject();

            SerializeProperties(writer, value, serializer);

            writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.Team)));
            serializer.Serialize(writer, value.Team);

            if (retrievalConfiguration.IncludeIsActive)
            {
                writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.IsActive)));
                serializer.Serialize(writer, value.IsActive);
            }

            if (retrievalConfiguration.IncludeMatchUps)
            {
                writer.WritePropertyName(JsonSerializationHelper.GetPropertyName(value.GetType(), nameof(value.MatchUps)));
                serializer.Serialize(writer, value.MatchUps);
            }

            writer.WriteEndObject();
        }
示例#19
0
        //string postData = "";
        /// <summary>
        /// 利嘉查询商品品牌
        /// </summary>
        /// <param name="info">商品品牌查询参数</param>
        /// <returns>结果对象</returns>
        /// <remarks>2017-05-18 罗勤尧 创建</remarks>
        public static ResultLiJia SeachLiJiaBrand(LiJiaMemberSearch info)
        {
            //创建查询请求参数
            string searchjosn = JsonHelper.ToJson(info);
            //查询接口
            string      searchpath = "brand.search";
            string      postData   = "";
            bool        Result     = false;
            ResultLiJia resultList = new ResultLiJia();

            try
            {
                string responseAddDsDealer = MainHttp(host, searchpath, methodTs, Token, postData, searchjosn);
                if (!string.IsNullOrEmpty(responseAddDsDealer))
                {
                    var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer);
                    if (Assreturn.Success)
                    {
                        resultList = Assreturn;
                    }
                }
            }
            catch (Exception ex)
            {
                return(resultList);
            }
            return(resultList);
        }
        public void Should_resolve_constructor_created_by_memberinfo()
        {
            var expected = typeof(Overload).GetConstructor(Array.Empty <Type>());
            var ctor     = new ConstructorInfo(expected);
            var ctor2    = JsonSerializationHelper.Serialize(ctor);

            ctor2.Constructor.ShouldBeSameAs(expected);
        }
        public void Test_1()
        {
            var str = JsonSerializationHelper.SerializeWithType(new MyClass1("Derrick"));
            var obj = JsonSerializationHelper.DeserializeWithType(str) as MyClass1;

            obj.ShouldNotBe(null);
            obj.Name.ShouldBe("Derrick");
        }
示例#22
0
        public void Test_1()
        {
            var str    = JsonSerializationHelper.SerializeWithType(new MyClass1("John"));
            var result = (MyClass1)JsonSerializationHelper.DeserializeWithType(str);

            result.ShouldNotBeNull();
            result.Name.ShouldBe("John");
        }
        public override object GetOrDefault(string key)
        {
            var objbyte = _database.StringGet(GetLocalizedKey(key));

            return(objbyte.HasValue
                ? JsonSerializationHelper.DeserializeWithType(objbyte)
                : null);
        }
示例#24
0
        public void TestStringSerialization()
        {
            Assert.AreEqual("\"hello world\"", JsonSerializationHelper.Serialize("hello world"));
            Assert.AreEqual("\"hello Mr. \\\"officer\\\"!\"", JsonSerializationHelper.Serialize("hello Mr. \"officer\"!"));
            Assert.AreEqual("\"The file is in C:\\\\mystuff\"", JsonSerializationHelper.Serialize("The file is in C:\\mystuff"));

            Assert.AreEqual("null", JsonSerializationHelper.Serialize((string)null));
        }
示例#25
0
        public override void WriteJson(JsonWriter writer, TEnum?value, JsonSerializer serializer)
        {
            if (value == null)
            {
                return;
            }

            writer.WriteValue(JsonSerializationHelper.GetPropertyName(value.GetType(), value.ToString()));
        }
        public void Should_Deserialize_With_Different_Assembly_Version()
        {
            var str    = "SharePlatformSystem.Core.Localization.LocalizableString, SharePlatformSystem.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null|{\"SourceName\":\"Bar\",\"Name\":\"Foo\"}";
            var result = (LocalizableString)JsonSerializationHelper.DeserializeWithType(str);

            result.ShouldNotBeNull();
            result.Name.ShouldBe("Foo");
            result.SourceName.ShouldBe("Bar");
        }
        public void Should_Simply_Serialize_And_Deserialize()
        {
            var str    = JsonSerializationHelper.SerializeWithType(new LocalizableString("Foo", "Bar"));
            var result = (LocalizableString)JsonSerializationHelper.DeserializeWithType(str);

            result.ShouldNotBeNull();
            result.Name.ShouldBe("Foo");
            result.SourceName.ShouldBe("Bar");
        }
        public void ShouldDeserializeWithDifferentAssemblyVersion()
        {
            var str    = "StudioX.Localization.LocalizableString, StudioX, Version=1.5.1.0, Culture=neutral, PublicKeyToken=null|{\"SourceName\":\"Bar\",\"Name\":\"Foo\"}";
            var result = (LocalizableString)JsonSerializationHelper.DeserializeWithType(str);

            result.ShouldNotBeNull();
            result.Name.ShouldBe("Foo");
            result.SourceName.ShouldBe("Bar");
        }
示例#29
0
 private void ReadAllAudioList()
 {
     //m_allAudioNames = new List<string>();
     m_allAudioNames = JsonSerializationHelper.ReadJsonList <string>(GetStreamingAssetsRootPath() + "/AudioTrackList.json");
     //foreach (var name in m_allAudioNames)
     //{
     //    print("Load audio track: " + name);
     //}
 }
        public void Test_3()
        {
            Clock.Provider = ClockProviders.Local;

            var myClass = new MyClass2(new DateTime(2016, 04, 13, 08, 58, 10, 526, Clock.Kind));
            var str     = JsonSerializationHelper.SerializeWithType(myClass);
            var result  = (MyClass2)JsonSerializationHelper.DeserializeWithType(str);

            result.Date.ShouldBe(new DateTime(2016, 04, 13, 08, 58, 10, 526, Clock.Kind));
            result.Date.Kind.ShouldBe(Clock.Kind);
        }