Ejemplo n.º 1
0
 private static void WriteBasicValue(XmlWriter XMLwrt, XmlRpcValueBasic val)
 {
     XMLwrt.WriteStartElement("value");//value
     switch (val.ValueType)
     {
         case XmlRpcBasicValueType.String:
             XMLwrt.WriteStartElement("string");
             if (val.Data != null)
                 XMLwrt.WriteString(val.Data.ToString());
             XMLwrt.WriteEndElement();
             break;
         case XmlRpcBasicValueType.Int:
             XMLwrt.WriteStartElement("int");
             if (val.Data != null)
                 XMLwrt.WriteString(val.Data.ToString());
             XMLwrt.WriteEndElement();
             break;
         case XmlRpcBasicValueType.Boolean:
             XMLwrt.WriteStartElement("boolean");
             if (val.Data != null)
                 XMLwrt.WriteString(((bool)val.Data) ? "1" : "0");
             XMLwrt.WriteEndElement();
             break;
         case XmlRpcBasicValueType.Double:
             XMLwrt.WriteStartElement("double");
             if (val.Data != null)
                 XMLwrt.WriteString(val.Data.ToString());
             XMLwrt.WriteEndElement();
             break;
         case XmlRpcBasicValueType.dateTime_iso8601:
             XMLwrt.WriteStartElement("dateTime.iso8601");
             // Get date time format
             if (val.Data != null)
             {
                 DateTime time = (DateTime)val.Data;
                 string dt = time.Year + time.Month.ToString("D2") + time.Day.ToString("D2") +
                     "T" + time.Hour.ToString("D2") + ":" + time.Minute.ToString("D2") + ":" +
                     time.Second.ToString("D2");
                 XMLwrt.WriteString(dt);
             }
             XMLwrt.WriteEndElement();
             break;
         case XmlRpcBasicValueType.base64:
             XMLwrt.WriteStartElement("base64");
             if (val.Data != null)
                 XMLwrt.WriteString(Convert.ToBase64String(BitConverter.GetBytes((long)val.Data)));
             XMLwrt.WriteEndElement();
             break;
     }
     XMLwrt.WriteEndElement();//value
 }
Ejemplo n.º 2
0
        private static void WriteBasicValue(XmlWriter XMLwrt, XmlRpcValueBasic val)
        {
            XMLwrt.WriteStartElement("value");//value
            switch (val.ValueType)
            {
            case XmlRpcBasicValueType.String:
                XMLwrt.WriteStartElement("string");
                if (val.Data != null)
                {
                    XMLwrt.WriteString(val.Data.ToString());
                }
                XMLwrt.WriteEndElement();
                break;

            case XmlRpcBasicValueType.Int:
                XMLwrt.WriteStartElement("int");
                if (val.Data != null)
                {
                    XMLwrt.WriteString(val.Data.ToString());
                }
                XMLwrt.WriteEndElement();
                break;

            case XmlRpcBasicValueType.Boolean:
                XMLwrt.WriteStartElement("boolean");
                if (val.Data != null)
                {
                    XMLwrt.WriteString(((bool)val.Data) ? "1" : "0");
                }
                XMLwrt.WriteEndElement();
                break;

            case XmlRpcBasicValueType.Double:
                XMLwrt.WriteStartElement("double");
                if (val.Data != null)
                {
                    XMLwrt.WriteString(val.Data.ToString());
                }
                XMLwrt.WriteEndElement();
                break;

            case XmlRpcBasicValueType.dateTime_iso8601:
                XMLwrt.WriteStartElement("dateTime.iso8601");
                // Get date time format
                if (val.Data != null)
                {
                    DateTime time = (DateTime)val.Data;
                    string   dt   = time.Year + time.Month.ToString("D2") + time.Day.ToString("D2") +
                                    "T" + time.Hour.ToString("D2") + ":" + time.Minute.ToString("D2") + ":" +
                                    time.Second.ToString("D2");
                    XMLwrt.WriteString(dt);
                }
                XMLwrt.WriteEndElement();
                break;

            case XmlRpcBasicValueType.base64:
                XMLwrt.WriteStartElement("base64");
                if (val.Data != null)
                {
                    XMLwrt.WriteString(Convert.ToBase64String(BitConverter.GetBytes((long)val.Data)));
                }
                XMLwrt.WriteEndElement();
                break;
            }
            XMLwrt.WriteEndElement();//value
        }
Ejemplo n.º 3
0
 public XmlRpcValueArray(XmlRpcValueBasic[] basicValues) :
     base()
 {
     values = new List<IXmlRpcValue>();
     foreach (XmlRpcValueBasic val in basicValues)
     {
         values.Add(val);
     }
 }