public IActionResult GetSignedXml()
        {
            var timestamp = DateTime.Now.Ticks;
            var encrypted = AesHelper.Encrypt(timestamp.ToString());
            var xml       = XmlSerializationHelper.SerializeToXml(encrypted);
            var base64    = Convert.ToBase64String(new UTF8Encoding(false).GetBytes(xml));

            return(Json(ApiResponse.Success(base64)));
        }
示例#2
0
        public void TestSerialize()
        {
            Vertexes vertexs = new Vertexes();

            vertexs.VertexList = new List <Vertex>();

            Vertex v = new Vertex()
            {
                Name   = "A",
                Points = new List <float>()
                {
                    1.35f, 2.25f
                },
                Neighbors = new List <Neighbor>()
                {
                    new Neighbor()
                    {
                        Name = "B", Weight = 120.0f
                    },
                    new Neighbor()
                    {
                        Name = "C", Weight = 52.0f
                    }
                }
            };

            vertexs.VertexList.Add(v);
            vertexs.VertexList.Add(new Vertex()
            {
                Name = "B", Points = new List <float>()
                {
                    13.3f, 5.12f
                }
            });
            vertexs.VertexList.Add(new Vertex()
            {
                Name = "C", Points = new List <float>()
                {
                    53.3f, 25.12f
                }
            });

            _Vertexs = vertexs;

            string xml = XmlSerializationHelper.SerializeToXml(vertexs);
        }
示例#3
0
        static void Main(string[] args)
        {
            string path   = @"F:\Project\MyTest\MyTest\OutputTest\bin\Debug\Test.xml";
            string bnpath = @"F:\Project\MyTest\MyTest\OutputTest\bin\Debug\bnTest.txt";
            string jpath  = @"F:\Project\MyTest\MyTest\OutputTest\bin\Debug\jTest.txt";

            double[]   data = new double[] { 10.2, 15.3, 4, 51.2, 5, 4, 0, -5.3, 5, 8 };
            List <int> list = new List <int> {
                6, 2, 48, 8, 6, 7, 4,
            };

            data.BubbleSort();
            list.InsertSort();
            foreach (var item in list)
            {
                Console.WriteLine(item);
            }

            People p = new People();

            p.Name = "李静";
            p.Sex  = "女";
            var t = ConvertHelpers.CreateInstanceByBase <Teacher, People>(p);

            ///启动队列
            BusinessInfoHelper.Instance.start(StartThread);
            BusinessInfoHelper.Instance.AddQueue("胡大帅3", "666666676666");
            BusinessInfoHelper.Instance.AddQueue("胡大帅", "6666666666");
            BusinessInfoHelper.Instance.AddQueue("胡大帅2", "66664666666");

            List <SerializationModel> modellist = new List <SerializationModel>()
            {
                new SerializationModel()
                {
                    name = "just fly", passWord = "******"
                },
                new SerializationModel()
                {
                    name = "just fly1", passWord = "******"
                },
                new SerializationModel()
                {
                    name = "just fly2", passWord = "******"
                }
            };
            List <SerializationModel> nmodellist = new List <SerializationModel>();

            foreach (var item in modellist)
            {
                nmodellist.Add(BinarySerializationHelper.DeepClone(item));
            }
            modellist[1].name = "hu";
            SerializationModel model = BinarySerializationHelper.DeepClone(new SerializationModel()
            {
                name = "just fly", passWord = "******"
            });

            XmlSerializationHelper.SerializeToXml <List <SerializationModel> >(modellist, path);
            var li  = XmlSerializationHelper.DeSerializeFromXml <List <SerializationModel> >(path, true);
            var ss  = XmlSerializationHelper.SerializeToXml <List <SerializationModel> >(modellist);
            var sss = XmlSerializationHelper.DeSerializeFromXml <List <SerializationModel> >(ss);

            var bt = BinarySerializationHelper.FormatterObjectBytes(modellist);

            BinarySerializationHelper.BinaryFileSave(bnpath, modellist);

            var json = JsonSerializationHelper.SerializeToJson(modellist);

            JsonSerializationHelper.SerializeToJson(modellist, jpath);

            var dejson  = JsonSerializationHelper.DeSerializeFromJson <List <SerializationModel> >(json);
            var pdejson = JsonSerializationHelper.DeSerializeFromJson <List <SerializationModel> >(jpath, true);

            Console.Read();
        }