1 /*----------------------------------------------------------------------------
 2 Name:      ServiceListTO.cs
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 Comment:   A generic service approach
 6 Author:    "Marcel Ruff" <xmlBlaster@marcelruff.info>
 7 Date:      04/2007
 8 See:       http://www.xmlblaster.org/
 9 -----------------------------------------------------------------------------*/
10 using System;
11 using System.Collections.Generic;
12 using System.Text;
13 using System.Xml;
14 using System.Xml.Schema;
15 using System.Xml.Serialization;
16 
17 namespace org.xmlBlaster.contrib.service {
18    /// <summary>

19    /// <sc>

20    ///   <s>

21    ///    <p k='serviceName'>buddy</p>

22    ///    <p k='bounce'>myRequestId-5301785</p>

23    ///    <p k='taskType'>named</p>

24    ///    <p k='task'>getBuddies</p>

25    ///   </s>

26    ///  </sc>

27    /// </summary>

28    [XmlRootAttribute("sc", IsNullable = false)]
29    public class ServiceListTO : IXmlSerializable {
30       private List<ServiceTO> serviceTOs;
31       public static readonly string SERVICES = "sc"; // tag name

32 
33       public ServiceListTO() {
34       }
35 
36       public ServiceListTO(ServiceTO serviceTO) {
37          addService(serviceTO);
38       }
39 
40       public void addService(ServiceTO serviceTO) {
41          if (this.serviceTOs == null)
42             this.serviceTOs = new List<ServiceTO>();
43          this.serviceTOs.Add(serviceTO);
44       }
45 
46       public List<ServiceTO> getServices() {
47          return (this.serviceTOs == null) ? new List<ServiceTO>()
48                : this.serviceTOs;
49       }
50 
51       public void setServices(List<ServiceTO> serviceTOs) {
52          this.serviceTOs = serviceTOs;
53       }
54 
55       public void ReadXml(XmlReader reader) {
56          //reader.ReadToFollowing(SERVICES);

57          this.serviceTOs = ServiceTO.ReadSiblings(reader);
58       }
59 
60       public void WriteXml(XmlWriter writer) {
61          //writer.WriteStartElement(SERVICES);

62          foreach (ServiceTO service in getServices()) {
63             service.WriteXml(writer);
64          }
65          //writer.WriteEndElement();

66       }
67 
68       public XmlSchema GetSchema() {
69          return null;
70       }
71 
72       /// <summary>

73       /// </summary>

74       /// <param name="prop">Of type PropTO.KEY_DATA or PropTO.KEY_RESULT</param>

75       /// <returns></returns>

76       public static ServiceListTO parse(byte[] bytes) {
77          return org.xmlBlaster.util.Serialization.Deserialize<ServiceListTO>(bytes);
78       }
79 
80       public static ServiceListTO parseStr(string xml) {
81          return org.xmlBlaster.util.Serialization.DeserializeStr<ServiceListTO>(xml);
82       }
83 
84       public byte[] ToXml() {
85          return org.xmlBlaster.util.Serialization.Serialize<ServiceListTO>(this);
86       }
87 
88       public string ToXmlStr() {
89          return org.xmlBlaster.util.Serialization.SerializeStr<ServiceListTO>(this);
90       }
91    }
92 }


syntax highlighted by Code2HTML, v. 0.9.1