コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }