Exemplo n.º 1
0
		// Still here for backward compatibility
		private /*static*/ void readTypeDetails(XmlReader xmlReader)
		{
			System.Diagnostics.Debug.Assert(null != xmlReader, "The 'xmlReader' argument cannot be null.");

			string typeName = xmlReader.GetAttribute("name");
			Type type = new TypeParser().Resolve(typeName);
			if (type.IsGenericTypeDefinition) {
				xmlReader.ReadStartElement("Type");
				while (xmlReader.IsStartElement("Type")) {
					this.readTypeDetails(xmlReader);
					if (xmlReader.IsStartElement("Type"))
						xmlReader.ReadStartElement();
				}
			}

			if (!xmlReader.IsEmptyElement)
				xmlReader.ReadEndElement();
		}
Exemplo n.º 2
0
		private object deserialize(XmlReader xmlReader, int id, SerializationInfo info, List<int> dimensionLengths, IFormatterConverter converter)
		{
			System.Diagnostics.Debug.Assert(null != xmlReader, "The 'xmlReader' argument cannot be null.");
			System.Diagnostics.Debug.Assert(null != info, "The 'info' argument cannot be null.");
			System.Diagnostics.Debug.Assert(null != converter, "The 'converter' argument cannot be null.");

			string assemblyQualifiedTypeName = string.Format("{0}, {1}", info.FullTypeName, info.AssemblyName);
			Type objectType = new TypeParser().Resolve(assemblyQualifiedTypeName);

			object deserialized = null; // Return value
			if (this.isSimpleType(objectType)) {
				deserialized = this.readValue(xmlReader, objectType, converter);
			}
			else if (objectType.IsArray) {
				Type elementType = objectType.GetElementType();
				deserialized = this.deserializeArray(xmlReader, id, elementType, dimensionLengths, converter);
			}
			else {
				deserialized = this.deserializeObject(xmlReader, id, objectType, info, converter);
			}

			IObjectReference objectReference = deserialized as IObjectReference;
			if (null != objectReference)
				deserialized = objectReference.GetRealObject(this.context);

			IDeserializationCallback deserializationCallback = deserialized as IDeserializationCallback;
			if (null != deserializationCallback)
				deserializationCallback.OnDeserialization(this);

			if (XmlNodeType.EndElement == xmlReader.NodeType)
				xmlReader.ReadEndElement();

			return deserialized;
		}
Exemplo n.º 3
0
		private /*static*/ List<int> readArrayDimensions(XmlReader xmlReader)
		{
			System.Diagnostics.Debug.Assert(null != xmlReader, "The 'xmlReader' argument cannot be null.");
			System.Diagnostics.Debug.Assert(null != xmlReader.GetAttribute("type"), "The 'type' attribute does not exist.");

			List<int> dimensionLengths = null; // Return value

			string typeName = xmlReader.GetAttribute("type");
			if (!String.IsNullOrEmpty(typeName))
				dimensionLengths = new TypeParser().GetArrayDimensions(typeName);

			return dimensionLengths;
		}
Exemplo n.º 4
0
		private void serializeInfo(XmlWriter xmlWriter, SerializationInfo info, IFormatterConverter converter)
		{
			System.Diagnostics.Debug.Assert(null != xmlWriter, "The 'xmlWriter' argument cannot be null.");
			System.Diagnostics.Debug.Assert(null != info, "The 'info' argument cannot be null.");
			System.Diagnostics.Debug.Assert(null != converter, "The 'converter' argument cannot be null.");

			string assemblyQualifiedTypeName = string.Format("{0}, {1}", info.FullTypeName, info.AssemblyName);
			Type objectType = new TypeParser().Resolve(assemblyQualifiedTypeName);
			this.writeType(xmlWriter, objectType, this.assemblyFormat);

			foreach (SerializationEntry entry in info)
				this.serializeEntry(xmlWriter, entry, converter);
		}