Beispiel #1
0
        public async void PostTest()
        {
            dynamic data = new DynamicObjectExt();

            data.channel  = 0;
            data.d        = 10;
            data.domains  = "163.com";
            data.l        = 0;
            data.pd       = "mail126";
            data.pkid     = "QdQXWEQ";
            data.pw       = "SHywNfsbpCUH6U/9lKQRLYBOa7eMRZp0MqyrF7sfng2hxnRRWoLRNNrPxFF84Wnfz5mbusIBXPLJkN/Ruc2ucA3dYcNQ0k+3DYRphkq6K7xVaJAV2Znw8A43Rl4V/zBmeRvHIvwf0Q4DQJnK+Fbj4+yo3P0bIge7euoPEGrbHUs=";
            data.pwdKeyUp = 0;
            data.rtid     = "QQ1MeSNpLaDGwtZG50SlKRzhgz7yAU75";
            data.t        = 1624606697553;
            data.tk       = "2d47c20c858e673ab49bf00fe7541807";
            data.topURL   = "https://www.126.com/";
            data.un       = "*****@*****.**";

            HttpResponseExt rep = await Xmtool.Web.Client()
                                  .SetJsonContent(data)
                                  .PostJsonAsync("https://passport.126.com/dl/l");

            Assert.Equal(HttpStatusCode.OK, rep.StatusCode);
            Assert.Equal("401", rep.Json.ret);
        }
Beispiel #2
0
        private void DeserializeXmlNode(Stack <DynamicObjectExt> s,
                                        XmlNodeInfo node, bool includeRoot)
        {
            if (!node.IsEndNode)
            {
                if (!node.IsRoot || includeRoot)
                {
                    DynamicObjectExt p = s.Peek();
                    if (node.IsNode)
                    {
                        DynamicObjectExt newObj = new DynamicObjectExt();
                        p.TrySetValue(node.LocalName, newObj);
                        s.Push(newObj);

                        for (int i = 0; i < node.AttributeCount; i++)
                        {
                            string attrName = node.GetAttributeName(i);
                            newObj.TrySetValue(attrName, node.GetAttribute(i));
                        }
                    }
                    else if (node.IsTextNode)
                    {
                        p.TrySetValue("Value", node.Text);
                    }
                    else if (node.IsCDATANode)
                    {
                        p.TrySetValue("Value", node.CData);
                    }
                }
            }
            else if (node.IsEndNode && node.IsNode)
            {
                s.Pop();
            }
        }
Beispiel #3
0
        public void TestDynamicObjectExtKeys()
        {
            dynamic obj = new DynamicObjectExt();

            obj.Id   = "001";
            obj.Name = "wangxm";
            Assert.Equal(2, obj.Keys.Count);
        }
Beispiel #4
0
        public void TestDynamicObjectExtIndexerProperty()
        {
            dynamic obj = new DynamicObjectExt();

            obj.Id   = "001";
            obj.Name = "wangxm";
            Assert.Equal("wangxm", obj["Name"]);
            Assert.Null(obj["Age"]);
        }
Beispiel #5
0
        public dynamic DeserializeFromString(string xml, bool includeRoot = false)
        {
            DynamicObjectExt         r = new DynamicObjectExt();
            Stack <DynamicObjectExt> s = new Stack <DynamicObjectExt>();

            s.Push(r);

            IterateFromString(xml, (XmlNodeInfo node) =>
            {
                DeserializeXmlNode(s, node, includeRoot);
                return(true);
            });
            return(r);
        }
Beispiel #6
0
        public void JsonToXML()
        {
            dynamic obj = new DynamicObjectExt();

            obj.Name         = "wangxm";
            obj.Age          = 18;
            obj.Dog          = new DynamicObjectExt();
            obj.Dog.Name     = "Tom";
            obj.Dog.Kind     = "中华田园犬";
            obj.Dog.Toys     = new DynamicObjectExt();
            obj.Dog.Toys.One = "玩具一";
            obj.Dog.Toys.Two = "玩具二";
            string xml = obj.ToXMLString();

            Assert.NotNull(xml);
            Assert.Contains("<Name>wangxm</Name>", xml);
            Assert.Contains("<Dog Name=\"Tom\"", xml);
            Assert.Contains("<Dog Name=\"Tom\" Kind=\"中华田园犬\">", xml);
            Assert.Contains("<Dog Name=\"Tom\" Kind=\"中华田园犬\"><Toys", xml);
            Assert.Contains("<Dog Name=\"Tom\" Kind=\"中华田园犬\"><Toys One=\"玩具一\"", xml);
            Assert.Contains("<Dog Name=\"Tom\" Kind=\"中华田园犬\"><Toys One=\"玩具一\" Two=\"玩具二\">", xml);
        }