private static string getBinFromJtoken(JToken token) { string res = string.Empty; Type a = HelperForJsonSerealization.GetTupeFromString(((JProperty)token).Value.ToString()); MinifestById.Children(); if (a != null) { string defTypeString = "lololo"; var defType = GetDefault(a); char defChar = 'G'; if (a == typeof(string)) { defType = defTypeString; } if (a == typeof(char)) { defType = defChar; } if (defType != null) { res += '1'; if (a == typeof(bool)) { if ((bool)defType == true) { res += '1'; } else { res += '0'; } } else if (a == typeof(DateTime)) { res += BinaryHelper.DataBitsSerealization((DateTime)defType); } else { byte[] Bytes = BinaryHelper.GetBytes(defType, a); BitArray bits = new BitArray(Bytes); res += BinaryHelper.ToBitString(bits); } } else { res += '0'; } } return(res); }
public static string convertToStringBitsObject(JToken tampManifVal, JToken Val) { string res = string.Empty; Type type = HelperForJsonSerealization.GetTupeFromString(tampManifVal.ToString()); var HelperForJsonSerealizationInstens = Val.ToObject(type); if (tampManifVal.ToString() == "currency") { Type twype = typeof(double); int currency = (int)((double)Val.ToObject(twype) * 100); HelperForJsonSerealizationInstens = currency; } res += '1'; if (type == typeof(bool)) { if ((bool)HelperForJsonSerealizationInstens == true) { res += '1'; } else { res += '0'; } } else if (type == typeof(DateTime)) { res += BinaryHelper.DataBitsSerealization((DateTime)HelperForJsonSerealizationInstens); } else { byte[] Bytes = BinaryHelper.GetBytes(HelperForJsonSerealizationInstens, type); BitArray bits = new BitArray(Bytes); res += BinaryHelper.ToBitString(bits); } return(res); }
public static string ParseJsonToByteArray(string dataForSerealization, string manifestFilwPath) { AllStringBits = string.Empty; string res = string.Empty; string dataForSerealizationFileJson = dataForSerealization; string manifetFileJson = File.ReadAllText(manifestFilwPath); //string a = HelperForJsonSerealization.getServerId(dataForSerealizationFileJson); JObject manifestByClientId = HelperForJsonSerealization.getDataById("17"); var dataVal = manifestByClientId.ToString(); var dataVal1 = manifestByClientId.Property("id"); var dataValChild = manifestByClientId.ToString(); var idObjeck = dataVal1.ToObject(typeof(byte)); byte[] Bytes = BinaryHelper.GetBytes(idObjeck, typeof(byte)); BitArray B_Id = new BitArray(Bytes); res += BinaryHelper.ToBitString(B_Id); string content = dataValChild; JToken token = JToken.Parse(content); JToken token2 = (JToken.Parse(dataForSerealizationFileJson)); MinifestById = token; rec(token); List <JToken> adsdd = tryFind(token.Last); List <JToken> adsdd1 = tryFind(token2); //dynamic jobject = JsonConvert.DeserializeObject(dataForSerealizationFileJson); //bool isArray = IfDataArray(); //JObject manifetJson = JObject.Parse(manifetFileJson); //JProperty manifetId = ((JObject)manifetJson.First.First).Property("id"); //JProperty manifetName = ((JObject)manifetJson.First.First).Property("name"); //JToken manifestDataType = manifetJson.First.First.Last.First; //JObject dataForSerealizationJson = JObject.Parse(dataForSerealizationFileJson); //JProperty dataForSerealizationId = ((JObject)dataForSerealizationJson.First.First).Property("id"); //JProperty dataForSerealizationName = ((JObject)dataForSerealizationJson.First.First).Property("name"); //JToken manifestDataValue = dataForSerealizationJson.First.First.Last.First; //Type aId = HelperForJsonSerealization.GetTupeFromString(manifetId.Value.ToString()); //var idObjeck = dataForSerealizationId.ToObject(aId); //byte[] Bytes = BinaryHelper.GetBytes(idObjeck, aId); //BitArray B_Id = new BitArray(Bytes); //res += BinaryHelper.ToBitString(B_Id); //res += HelperForJsonSerealization.GetBitsFromData(dataForSerealizationJson, manifestDataType, isArray); //HelperForJsonSerealization.ToFoolByte(res); res += MakeBits(adsdd, adsdd1); res = HelperForJsonSerealization.ToFoolByte(res); return(res); }