Serialize() public static méthode

public static Serialize ( string testName, object obj, Encoding encoding, MappingAction action ) : XmlDocument
testName string
obj object
encoding System.Text.Encoding
action MappingAction
Résultat System.Xml.XmlDocument
Exemple #1
0
        public void Struct0_AllExist()
        {
            Struct0 strout = new Struct0();

            strout.xi  = 1234;
            strout.xb  = true;
            strout.xd  = 1234.567;
            strout.xdt = new DateTime(2006, 8, 9, 10, 11, 13);
#if !FX1_0
            strout.nxi   = 5678;
            strout.nxb   = true;
            strout.nxd   = 2345.678;
            strout.nxdt  = new DateTime(2007, 9, 10, 11, 12, 14);
            strout.nxstr = new ChildStruct(567);
#endif
            XmlReader xdoc = Utils.Serialize("Struct0_AllExist",
                                             strout, Encoding.UTF8, new MappingActions {
                NullMappingAction = NullMappingAction.Error
            });
            Type   parsedType, parsedArrayType;
            object obj = Utils.Parse(xdoc, typeof(Struct0), MappingAction.Error,
                                     out parsedType, out parsedArrayType);
            Assert.IsInstanceOf(typeof(Struct0), obj);
            Struct0 strin = (Struct0)obj;
            Assert.AreEqual(strout.xi, strin.xi);
            Assert.AreEqual(strout.xb, strin.xb);
            Assert.AreEqual(strout.xd, strin.xd);
            Assert.AreEqual(strout.xdt, strin.xdt);
#if !FX1_0
            Assert.AreEqual(strout.nxi, strin.nxi);
            Assert.AreEqual(strout.nxb, strin.nxb);
            Assert.AreEqual(strout.nxd, strin.nxd);
            Assert.AreEqual(strout.nxdt, strin.nxdt);
            Assert.AreEqual(((ChildStruct)strout.nxstr).x, ((ChildStruct)strin.nxstr).x);
#endif
        }
 public void Struct1_AllMissing_IgnoreDefault()
 {
     XmlDocument xdoc = Utils.Serialize("Struct1_AllMissing_IgnoreDefault",
                                        new Struct1(),
                                        Encoding.UTF8, MappingAction.Ignore);
 }
Exemple #3
0
 public void Struct1_AllMissing_ErrorDefault()
 {
     Assert.That(() => Utils.Serialize("Struct1_AllMissing_ErrorDefault",
                                       new Struct1(),
                                       Encoding.UTF8, MappingAction.Error), Throws.TypeOf <XmlRpcMappingSerializeException>());
 }