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); }
private static string getNameManifest(JObject item, JToken manifestDataType) { string res = string.Empty; IEnumerable <JProperty> property = ((JObject)manifestDataType).Properties(); foreach (JProperty prop in property) { JToken bvn = item.GetValue(prop.Name); if (bvn != null) { Type a = GetTupeFromString(prop.Value.ToString()); res += '1'; var ub = bvn.ToObject(a); if (a == typeof(bool)) { if ((bool)ub == true) { res += '1'; } else { res += '0'; } } else if (a == typeof(DateTime)) { res += BinaryHelper.DataBitsSerealization((DateTime)ub); } else { byte[] Bytes = BinaryHelper.GetBytes(ub, 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); }