Ejemplo n.º 1
0
        Test BuildTestObject()
        {
            XmlDocument doc = new XmlDocument();

            Test t = new UknTestPart();

            t.a                 = 1;
            t.b                 = "hola";
            t.bbis              = t.b;
            t.c                 = 44;
            t.parts             = new TestPart[3];
            t.parts[0]          = new TestPart();
            t.parts[0].name     = "un";
            t.parts[0].bval     = true;
            t.parts[1]          = new TestPart();
            t.parts[1].name     = "dos";
            t.parts[1].bval     = false;
            t.parts[2]          = t.parts[0];
            t.part              = t.parts[1];
            t.strings           = new string[] { "un", "dos", null, "tres" };
            t.ushorts           = new ushort[] { 1, 2, 3 };
            t.ta                = new TB();
            t.ta.extraTextNodes = new XmlNode[] { doc.CreateTextNode("AA"), doc.CreateTextNode("BB") };

            t.tam2 = new TA[][][]
            {
                new TA[][] { new TA[] { new TA(), new TA() }, new TA[] { new TA(), new TA() } },
                new TA[][] { new TA[] { new TB(), new TA() }, new TA[] { new TB(), new TA() } },
                new TA[][] { new TA[] { new TA(), new TB() }, new TA[] { new TA(), new TA() } }
            };

            t.tam3      = t.tam2;
            t.flatParts = t.parts;

            t.flatParts2 = new TA[] { new TA(), new TB(), null, new TB() };

            t.anot = new AnotherTestPart();
            ((AnotherTestPart)t.anot).lo = 1234567890;

            t.ob  = t.parts[1];
            t.ob2 = t.parts[1];

            XmlElement e1 = doc.CreateElement("explicitElement");
            XmlElement e2 = doc.CreateElement("subElement");

            e2.SetAttribute("unAtrib", "val");
            doc.AppendChild(e1);
            e1.AppendChild(e2);

            t.oneElem      = e1;
            t.oneElem2     = e1;
            t.someElems    = new XmlNode[3];
            t.someElems[0] = e1;
            t.someElems[1] = null;
            t.someElems[2] = e2;

            t.extraElems    = new XmlElement[1];
            t.extraElems[0] = doc.CreateElement("extra1");
            t.extraElems[0].SetAttribute("val", "1");

            t.extraElems23    = new XmlElement[2];
            t.extraElems23[0] = doc.CreateElement("extra2");
            t.extraElems23[0].SetAttribute("val", "2");
            t.extraElems23[1] = doc.CreateElement("extra3");
            t.extraElems23[1].SetAttribute("val", "3");

            t.extraElemsRest = doc.CreateElement("extra4");
            t.extraElemsRest.SetAttribute("val", "4");

            t.uktester    = new UnknownAttributeTester();
            t.uktester.aa = "hihi";

            t.uktester.extraAtts          = new XmlAttribute[3];
            t.uktester.extraAtts[0]       = doc.CreateAttribute("extraAtt1");
            t.uktester.extraAtts[0].Value = "val1";
            t.uktester.extraAtts[1]       = doc.CreateAttribute("extraAtt2");
            t.uktester.extraAtts[1].Value = "val2";
            t.uktester.extraAtts[2]       = doc.CreateAttribute("extraAtt3");
            t.uktester.extraAtts[2].Value = "val3";

            t.ob3 = 12345;
            t.ob4 = (float)54321.12;

            t.op1     = option.AA;
            t.opArray = new option[] { option.CC, option.BB, option.AA };
            t.ukOpt   = option.DD;
            t.opAtt   = option.BB;

            t.byteArray     = new byte[] { 11, 33, 55, 222 };
            t.byteByteArray = new byte[][] { t.byteArray, t.byteArray };

            t.ttList = new ArrayList();
            t.ttList.Add("two");
            t.ttList.Add("strings");
            //			t.extraText = "Additional text";

            t.RoList = new ArrayList();
            t.RoList.Add(t.parts[0]);
            t.RoList.Add(t.parts[1]);

/*			t.struc = new OneStruct();
 *                      t.struc.aa = 776655;
 *                      t.struc.cc = "this is a struct";
 */
            t.multiList    = new ArrayList[2];
            t.multiList[0] = new ArrayList();
            t.multiList[0].Add(22);
            t.multiList[0].Add(33);
            t.multiList[1] = new ArrayList();
            t.multiList[1].Add(888);
            t.multiList[1].Add(999);

            // XmlSerializer does not deserialize default values explicitly.
            //t.defElem = "theDefValue";
            //t.defAttr = "theDefValue";

            t.special = new CustomHashtable();
            t.special.Add("one", "1");
            t.special.Add("two", "2");
            t.special.Add("three", "3");

            t.attqname = new XmlQualifiedName("thename", "thenamespace");

            DblStringContainer dbc = new DblStringContainer();

            dbc.doublestring = new string [][] { null, new string[] { "hello" } };
            AnotherTestPart at = new AnotherTestPart();

            at.lo  = 567;
            dbc.at = at;

            DblStringContainerAnm dbca = new DblStringContainerAnm();

            dbca.at        = dbc;
            t.dbscontainer = dbca;

            return(t);
        }
Ejemplo n.º 2
0
		Test BuildTestObject ()
		{
			XmlDocument doc = new XmlDocument();

			Test t = new UknTestPart();
			t.a = 1;
			t.b = "hola";
			t.bbis = t.b;
			t.c = 44;
			t.parts = new TestPart[3];
			t.parts[0] = new TestPart();
			t.parts[0].name = "un";
			t.parts[0].bval = true;
			t.parts[1] = new TestPart();
			t.parts[1].name = "dos";
			t.parts[1].bval = false;
			t.parts[2] = t.parts[0];
			t.part = t.parts[1];
			t.strings = new string[] { "un", "dos", null, "tres" };
			t.ushorts = new ushort[] { 1,2,3 };
			t.ta = new TB();
			t.ta.extraTextNodes = new XmlNode[] { doc.CreateTextNode ("AA"), doc.CreateTextNode ("BB") };

			t.tam2 = new TA[][][]
					{
						new TA[][] { new TA[] {new TA(), new TA()}, new TA[] {new TA(), new TA()}},
						new TA[][] { new TA[] {new TB(), new TA()}, new TA[] {new TB(), new TA()}},
						new TA[][] { new TA[] {new TA(), new TB()}, new TA[] {new TA(), new TA()}} 
					};

			t.tam3 = t.tam2;
			t.flatParts = t.parts;

			t.flatParts2 = new TA[] {new TA(), new TB(), null, new TB()};

			t.anot = new AnotherTestPart ();
			((AnotherTestPart)t.anot).lo = 1234567890;

			t.ob = t.parts[1];
			t.ob2 = t.parts[1];

			XmlElement e1 = doc.CreateElement ("explicitElement");
			XmlElement e2 = doc.CreateElement ("subElement");
			e2.SetAttribute ("unAtrib","val");
			doc.AppendChild (e1);
			e1.AppendChild (e2);

			t.oneElem = e1;
			t.oneElem2 = e1;
			t.someElems = new XmlNode[3];
			t.someElems[0] = e1;
			t.someElems[1] = null;
			t.someElems[2] = e2;

			t.extraElems = new XmlElement[1];
			t.extraElems[0] = doc.CreateElement ("extra1");
			t.extraElems[0].SetAttribute ("val","1");

			t.extraElems23 = new XmlElement[2];
			t.extraElems23[0] = doc.CreateElement ("extra2");
			t.extraElems23[0].SetAttribute ("val","2");
			t.extraElems23[1] = doc.CreateElement ("extra3");
			t.extraElems23[1].SetAttribute ("val","3");

			t.extraElemsRest = doc.CreateElement ("extra4");
			t.extraElemsRest.SetAttribute ("val","4");

			t.uktester = new UnknownAttributeTester();
			t.uktester.aa = "hihi";

			t.uktester.extraAtts = new XmlAttribute[3];
			t.uktester.extraAtts[0] = doc.CreateAttribute ("extraAtt1");
			t.uktester.extraAtts[0].Value = "val1";
			t.uktester.extraAtts[1] = doc.CreateAttribute ("extraAtt2");
			t.uktester.extraAtts[1].Value = "val2";
			t.uktester.extraAtts[2] = doc.CreateAttribute ("extraAtt3");
			t.uktester.extraAtts[2].Value = "val3";

			t.ob3 = 12345;
			t.ob4 = (float)54321.12;

			t.op1 = option.AA;
			t.opArray = new option[] { option.CC, option.BB, option.AA };
			t.ukOpt = option.DD;
			t.opAtt = option.BB;

			t.byteArray = new byte[] { 11,33,55,222 };
			t.byteByteArray = new byte[][] { t.byteArray, t.byteArray };

			t.ttList = new ArrayList();
			t.ttList.Add ("two");
			t.ttList.Add ("strings");
			//			t.extraText = "Additional text";

			t.RoList = new ArrayList ();
			t.RoList.Add (t.parts[0]);
			t.RoList.Add (t.parts[1]);

/*			t.struc = new OneStruct();
			t.struc.aa = 776655;
			t.struc.cc = "this is a struct";
*/
			t.multiList = new ArrayList[2];
			t.multiList[0] = new ArrayList ();
			t.multiList[0].Add (22);
			t.multiList[0].Add (33);
			t.multiList[1] = new ArrayList ();
			t.multiList[1].Add (888);
			t.multiList[1].Add (999);

			// XmlSerializer does not deserialize default values explicitly.
			//t.defElem = "theDefValue";
			//t.defAttr = "theDefValue";

			t.special = new CustomHashtable ();
			t.special.Add ("one","1");
			t.special.Add ("two","2");
			t.special.Add ("three","3");

			t.attqname = new XmlQualifiedName ("thename","thenamespace");

			DblStringContainer dbc = new DblStringContainer ();
			dbc.doublestring = new string [][] { null, new string[] {"hello"} };
			AnotherTestPart at = new AnotherTestPart ();
			at.lo = 567;
			dbc.at = at;

			DblStringContainerAnm dbca = new DblStringContainerAnm ();
			dbca.at = dbc;
			t.dbscontainer = dbca;
			
			return t;
		}