コード例 #1
0
 private void EndElement()
 {
     if (_elementStack.Count > 0) //we don't push the top-level MULTI_OBJECT_ELEMENT on the stack
     {
         XmlElement element = _elementStack[_elementStack.Count - 1];
         _elementStack.RemoveAt(_elementStack.Count - 1);
         if (_elementStack.Count == 0)
         {
             _currentTopLevelElementDocument = null;
             if (_stillHandling)
             {
                 XmlObjectDecoder decoder = new XmlObjectDecoder(element, null);
                 Object           obj     = decoder.ReadObject();
                 _stillHandling = _handler(obj);
             }
         }
     }
 }
コード例 #2
0
 private void EndElement()
 {
     if (_elementStack.Count > 0) //we don't push the top-level MULTI_OBJECT_ELEMENT on the stack
     {
         XmlElement element = _elementStack[_elementStack.Count - 1];
         _elementStack.RemoveAt(_elementStack.Count - 1);
         if (_elementStack.Count == 0)
         {
             _currentTopLevelElementDocument = null;
             if (_stillHandling)
             {
                 XmlObjectDecoder decoder = new XmlObjectDecoder(element, null);
                 Object obj = decoder.ReadObject();
                 _stillHandling = _handler(obj);
             }
         }
     }
 }
コード例 #3
0
 private Object ReadObjectInternal()
 {
     if (_expectedClass != null)
     {
         ObjectSerializationHandler handler =
             ObjectSerializerRegistry.GetHandlerByObjectType(_expectedClass);
         if (handler == null)
         {
             if (_expectedClass.IsArray)
             {
                 IList<Object> temp = new List<Object>();
                 for (XmlElement child = XmlUtil.GetFirstChildElement(_node); child != null;
                      child = XmlUtil.GetNextElement(child))
                 {
                     XmlObjectDecoder sub = new XmlObjectDecoder(child, null);
                     Object obj = sub.ReadObject();
                     temp.Add(obj);
                 }
                 int length = temp.Count;
                 Array array = Array.CreateInstance(_expectedClass.GetElementType(), length);
                 for (int i = 0; i < length; i++)
                 {
                     Object element = temp[i];
                     array.SetValue(element, i);
                 }
                 return array;
             }
             else
             {
                 throw new ConnectorException("No deserializer for type: " + _expectedClass);
             }
         }
         else
         {
             return handler.Deserialize(this);
         }
     }
     else if (_node.LocalName.Equals("null"))
     {
         return null;
     }
     else if (_node.LocalName.Equals("Array"))
     {
         String componentType = XmlUtil.GetAttribute(_node, "componentType");
         if (componentType == null)
         {
             componentType = "Object";
         }
         Type componentClass = DecodeClass(componentType);
         IList<Object> temp = new List<Object>();
         for (XmlElement child = XmlUtil.GetFirstChildElement(_node); child != null;
              child = XmlUtil.GetNextElement(child))
         {
             XmlObjectDecoder sub = new XmlObjectDecoder(child, null);
             Object obj = sub.ReadObject();
             temp.Add(obj);
         }
         int length = temp.Count;
         Array array = Array.CreateInstance(componentClass,
                 length);
         for (int i = 0; i < length; i++)
         {
             Object element = temp[i];
             array.SetValue(element, i);
         }
         return array;
     }
     else
     {
         Type clazz =
             DecodeClass(_node.LocalName);
         ObjectSerializationHandler handler =
             ObjectSerializerRegistry.GetHandlerByObjectType(clazz);
         if (handler == null)
         {
             throw new ConnectorException("No deserializer for type: " + clazz);
         }
         else
         {
             return handler.Deserialize(this);
         }
     }
 }
コード例 #4
0
 private Object ReadObjectInternal()
 {
     if (_expectedClass != null)
     {
         ObjectSerializationHandler handler =
             ObjectSerializerRegistry.GetHandlerByObjectType(_expectedClass);
         if (handler == null)
         {
             if (_expectedClass.IsArray)
             {
                 IList <Object> temp = new List <Object>();
                 for (XmlElement child = XmlUtil.GetFirstChildElement(_node); child != null;
                      child = XmlUtil.GetNextElement(child))
                 {
                     XmlObjectDecoder sub = new XmlObjectDecoder(child, null);
                     Object           obj = sub.ReadObject();
                     temp.Add(obj);
                 }
                 int   length = temp.Count;
                 Array array  = Array.CreateInstance(_expectedClass.GetElementType(), length);
                 for (int i = 0; i < length; i++)
                 {
                     Object element = temp[i];
                     array.SetValue(element, i);
                 }
                 return(array);
             }
             else
             {
                 throw new ConnectorException("No deserializer for type: " + _expectedClass);
             }
         }
         else
         {
             return(handler.Deserialize(this));
         }
     }
     else if (_node.LocalName.Equals("null"))
     {
         return(null);
     }
     else if (_node.LocalName.Equals("Array"))
     {
         String componentType = XmlUtil.GetAttribute(_node, "componentType");
         if (componentType == null)
         {
             componentType = "Object";
         }
         Type           componentClass = DecodeClass(componentType);
         IList <Object> temp           = new List <Object>();
         for (XmlElement child = XmlUtil.GetFirstChildElement(_node); child != null;
              child = XmlUtil.GetNextElement(child))
         {
             XmlObjectDecoder sub = new XmlObjectDecoder(child, null);
             Object           obj = sub.ReadObject();
             temp.Add(obj);
         }
         int   length = temp.Count;
         Array array  = Array.CreateInstance(componentClass,
                                             length);
         for (int i = 0; i < length; i++)
         {
             Object element = temp[i];
             array.SetValue(element, i);
         }
         return(array);
     }
     else
     {
         Type clazz =
             DecodeClass(_node.LocalName);
         ObjectSerializationHandler handler =
             ObjectSerializerRegistry.GetHandlerByObjectType(clazz);
         if (handler == null)
         {
             throw new ConnectorException("No deserializer for type: " + clazz);
         }
         else
         {
             return(handler.Deserialize(this));
         }
     }
 }