示例#1
0
        public static ServiceResponse Deserialize(XmlReader reader, ServiceResponse serviceResponse)
        {
            if (reader.IsStartElement(DTD.Response.TagServiceResponse))
            {
                if (serviceResponse == null)
                {
                    serviceResponse = new ServiceResponse();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    do
                    {
                        #region <ERROR>
                        if (reader.IsStartElement(DTD.Response.ServiceResponse.TagError))
                        {
                            if (int.Parse(reader.GetAttribute(DTD.Error.TagNumber)) != 0)
                            {
                                throw XMLErrorSerializer.Deserialize(reader.ReadSubtree());
                            }
                            else
                            {
                                reader.Skip();
                            }
                        }
                        #endregion <ERROR>

                        #region <OID>
                        if (reader.IsStartElement(DTD.TagOID))
                        {
                            serviceResponse.Oid = XMLAdaptorOIDSerializer.Deserialize(reader.ReadSubtree());
                        }
                        #endregion <OID>

                        #region <Arguments>
                        if (reader.IsStartElement(DTD.Response.ServiceResponse.TagArguments))
                        {
                            serviceResponse.Arguments = XMLArgumentsSerializer.Deserialize(reader.ReadSubtree());
                        }
                        #endregion <Arguments>
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the Service.Response in Start Element.", "XmlReader reader");
            }
            return(serviceResponse);
        }
        public static object Deserialize(XmlReader reader, string type, string className)
        {
            object value = null;

            if ((reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemOldValue)) ||
                (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemNewValue)))
            {
                reader.ReadStartElement();

                switch (reader.LocalName)
                {
                case DTD.Error.ChangedItems.ChangedItem.TagNull:
                    try
                    {
                        value = Convert.XmlToType(type, null);
                    }
                    catch
                    {                            // the ChangedItem is an object-valued ChangedItem
                        value = null;
                    }
                    reader.Skip();
                    break;

                case DTD.Error.ChangedItems.ChangedItem.TagLiteral:
                {
                    if (reader.IsEmptyElement)
                    {
                        value = string.Empty;
                        reader.Skip();
                    }
                    else
                    {
                        value = Convert.XmlToType(type, reader.ReadString());
                        reader.ReadEndElement();
                    }
                }
                break;

                case DTD.TagOID:
                    value = XMLAdaptorOIDSerializer.Deserialize(reader.ReadSubtree());
                    reader.ReadEndElement();
                    break;
                }
                reader.ReadEndElement();
            }
            return(value);
        }
示例#3
0
 /// <summary>
 /// Deserializes Agent from an XML stream.
 /// </summary>
 /// <param name="reader">XML stream.</param>
 /// <returns>Oid (agent).</returns>
 public static Oids.Oid Deserialize(XmlReader reader)
 {
     Oids.Oid lResult = null;
     if (reader.IsStartElement(DTD.Request.TagAgent))
     {
         if (!reader.IsEmptyElement)
         {
             reader.ReadStartElement();
             lResult = XMLAdaptorOIDSerializer.Deserialize(reader);
         }
         else
         {
             reader.Skip();
         }
     }
     else
     {
         throw new ArgumentException("Xml Reader don't have the Agent in Start Element.", "XmlReader reader");
     }
     return(lResult);
 }
示例#4
0
        /// <summary>
        /// Deserializes an ChangeDetectionItem from an XML file.
        /// </summary>
        /// <param name="reader">XMLReader where the ChangeDetectionItem is.</param>
        /// <returns>ChangeDetectionItem.</returns>
        public static ChangeDetectionItem Deserialize(XmlReader reader)
        {
            ChangeDetectionItem lResult = null;

            if (reader.IsStartElement(DTD.Request.ServiceRequest.ChangeDetectionItems.TagChangeDetectionItem))
            {
                lResult = new ChangeDetectionItem();
                string    stringModelType = reader.GetAttribute(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagType);
                ModelType modelType       = Convert.StringTypeToMODELType(stringModelType);

                if (modelType == ModelType.Oid)
                {
                    lResult.Type      = Convert.MODELTypeToStringType(ModelType.Oid);
                    lResult.ClassName = stringModelType;
                }
                else
                {
                    lResult.Type      = stringModelType;
                    lResult.ClassName = string.Empty;
                }
                lResult.Name = reader.GetAttribute(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagName);

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    // if the ChangeDetectionItem is OutBound
                    if (reader.IsStartElement(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagValue))
                    {
                        reader.Read();
                    }
                    switch (reader.LocalName)
                    {
                    case DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagNull:
                        try
                        {
                            lResult.Value = Convert.XmlToType(lResult.Type, null);
                        }
                        catch
                        {
                            // the ChangeDetectionItem is an object-valued ChangeDetectionItem
                            lResult.Value = null;
                        }
                        reader.Skip();
                        break;

                    case DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagLiteral:
                    {
                        if (reader.IsEmptyElement)
                        {
                            lResult.Value = string.Empty;
                            reader.Skip();
                        }
                        else
                        {
                            lResult.Value = Convert.XmlToType(lResult.Type, reader.ReadString());
                            reader.ReadEndElement();
                        }
                    }
                    break;

                    case DTD.TagOID:
                        lResult.Value = XMLAdaptorOIDSerializer.Deserialize(reader.ReadSubtree());
                        break;
                    }
                    reader.ReadEndElement();
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the ChangeDetectionItem in Start Element.", "XmlReader reader");
            }
            return(lResult);
        }