void InvokeOnDeserializing(ClassDataContract classContract)
 {
     if (classContract.BaseContract != null)
     {
         InvokeOnDeserializing(classContract.BaseContract);
     }
     if (classContract.OnDeserializing != null)
     {
         classContract.OnDeserializing.Invoke(objectLocal, new object [] { context.GetStreamingContext() });
     }
 }
Exemplo n.º 2
0
        public override object ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
        {
            xmlReader.Read();
            Type   objType = UnderlyingType;
            object obj     = objType.IsArray ? Array.CreateInstance(objType.GetElementType(), 0) : GetUninitializedObject(objType);

            context.AddNewObject(obj);
            string            objectId = context.GetObjectId();
            SerializationInfo serInfo  = context.ReadSerializationInfo(xmlReader, objType);
            object            newObj   = SerializationSurrogateSetObjectData(obj, serInfo, context.GetStreamingContext());

            if (newObj == null)
            {
                newObj = obj;
            }
            if (newObj is IDeserializationCallback)
            {
                ((IDeserializationCallback)newObj).OnDeserialization(null);
            }
            if (newObj is IObjectReference)
            {
                newObj = GetRealObject((IObjectReference)newObj, context.GetStreamingContext());
            }
            context.ReplaceDeserializedObject(objectId, obj, newObj);
            xmlReader.ReadEndElement();
            return(newObj);
        }
Exemplo n.º 3
0
        private static object ReadISerializable(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context, ClassDataContract classContract)
        {
            object            obj;
            SerializationInfo serializationInfo        = context.ReadSerializationInfo(xmlReader, classContract.UnderlyingType);
            StreamingContext  streamingContext         = context.GetStreamingContext();
            ConstructorInfo   iSerializableConstructor = classContract.GetISerializableConstructor();

            obj = iSerializableConstructor.Invoke(new object[] { serializationInfo, streamingContext });
            return(obj);
        }
Exemplo n.º 4
0
 private void InvokeOnDeserialized(XmlObjectSerializerReadContext context, ClassDataContract classContract, object obj)
 {
     if (classContract.BaseContract != null)
     {
         InvokeOnDeserialized(context, classContract.BaseContract, obj);
     }
     if (classContract.OnDeserialized != null)
     {
         var contextArg = context.GetStreamingContext();
         classContract.OnDeserialized.Invoke(obj, new object[] { contextArg });
     }
 }