XML反序列化
问题描述:
当XML的反序列化完成时,有没有办法得到通知,比如回调方法?
我尝试了IDeserializationCallback接口,但这并不适用于
XML-Deserialization。
谢谢
josh
Is there a way to be notified when the deserialization of an XML is
complete, like a callback method?
I tried the IDeserializationCallback interface, but that doesnt for
XML-Deserialization.
thanks
josh
答
使用XmlSerializer.Deserialize方法的同步重载;当它返回时,它已经完成。
-
HTH,
Kevin Spencer
Microsoft MVP
..Net开发人员
你可以带鱼去骑自行车,
但需要很长时间,
并且自行车必须*要*改变。
" yoshijg" <乔***** @ gmail.com>在消息中写道
news:11 ********************** @ g14g2000cwa.googlegr oups.com ...
Use a synchronous overload of the XmlSerializer.Deserialize method; when it
returns, it is finished.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
"yoshijg" <jo*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
有没有办法在XML的反序列化完成时得到通知,比如回调方法?
我尝试了IDeserializationCallback接口,但这不适用于
XML-Deserialization。
感谢
josh
Is there a way to be notified when the deserialization of an XML is
complete, like a callback method?
I tried the IDeserializationCallback interface, but that doesnt for
XML-Deserialization.
thanks
josh
Hi Kev,
你的意思是这样的......
-
FooType fooobj;
XmlSerializer xmlObj =新系统.Xml.XmlSerialialzer(TypeOf(FooType));
Filestream strObj = new Filestream(" foo",Open);
fooobj = xmlObj.Deserialize(strObj);
fooObj.DeserializeComplete(); //手动通知
-
是的,我现在正在这样做...但我想要在
$ b内创建对象反序列化的$ b通过XmlSerializer创建完成后通知的方法
我可以做你的建议而且它是'容易......但有些程序员可能会忘记
来电DeserializeComplete。现在我可以在
函数调用中包装这整个东西,但这只是另一个每个人都不需要的b / b
跳过。
>
现在为什么没有实现IDeserializationCallback工作?
Hi Kev,
Do you mean something like this...
--
FooType fooobj;
XmlSerializer xmlObj = new System.Xml.XmlSerialialzer(TypeOf(FooType));
Filestream strObj = new Filestream("foo", Open);
fooobj = xmlObj.Deserialize( strObj );
fooObj.DeserializeComplete(); //Notify manually
--
Yeah, i am doing that now... but I want the object being created inside
of the "Deserialize" method to be notified when it''s done being created
by the "XmlSerializer".
I can do what you suggest and it''s easy...but some coder may forget to
call "DeserializeComplete". Now I can wrap this whole thing in a
function call, but that''s just another hoop everybody doesnt need to
jump through.
Now why doesn''t implementing IDeserializationCallback work?
我不知道为什么。你是如何实现它的?
-
HTH,
Kevin Spencer
Microsoft MVP
..Net开发人员
您可以将鱼带到自行车上,
但需要很长时间,
和自行车必须*要*改变。
" yoshijg" <乔***** @ gmail.com>在消息中写道
news:11 ********************** @ g44g2000cwa.googlegr oups.com ...
I don''t know why. How are you implementing it?
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
"yoshijg" <jo*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
你好Kev,
你的意思是这样的......
-
FooType fooobj;
XmlSerializer xmlObj = new System .Xml.XmlSerialialzer(TypeOf(FooType));
Filestream strObj = new Filestream(" foo",Open);
fooobj = xmlObj.Deserialize(strObj);
fooObj.DeserializeComplete( ); //手动通知
-
是的,我现在正在这样做...但我希望在反序列化的内部创建对象。 XmlSerializer创建完成后要通知的方法。
我可以按照你的建议行事,而且很容易......但有些编码员可能会忘记打电话DeserializeComplete。现在我可以将这整个事情包裹在
函数调用中,但这只是每个人都不需要跳过的另一个环。
现在为什么不实现IDeserializationCallback工作?
Hi Kev,
Do you mean something like this...
--
FooType fooobj;
XmlSerializer xmlObj = new System.Xml.XmlSerialialzer(TypeOf(FooType));
Filestream strObj = new Filestream("foo", Open);
fooobj = xmlObj.Deserialize( strObj );
fooObj.DeserializeComplete(); //Notify manually
--
Yeah, i am doing that now... but I want the object being created inside
of the "Deserialize" method to be notified when it''s done being created
by the "XmlSerializer".
I can do what you suggest and it''s easy...but some coder may forget to
call "DeserializeComplete". Now I can wrap this whole thing in a
function call, but that''s just another hoop everybody doesnt need to
jump through.
Now why doesn''t implementing IDeserializationCallback work?