为什么从Windows Phone中删除了[Serializable]属性(以及其他属性)? [英] Why was the [Serializable] attribute (and others) removed from Windows Phone?

查看:72
本文介绍了为什么从Windows Phone中删除了[Serializable]属性(以及其他属性)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力将WinForms类库迁移到Windows Phone,但我遇到了一个似乎没有实际影响的更改。

I am working on migrating a WinForms class library to Windows Phone, but I am coming across a change that seems to have no real effect.

代码可以正常运行看来,只有通用逻辑,但WinForms中的类都归因于[Serializable]。但是,Windows Phone或Windows应用商店应用中不存在该属性。有没有理由省略这个?这与ISerializable接口的
相同。在MSDN文档底部的列表中,它实际上包括Windows 8和Windows Phone 8。

The code works as it stands, there is just common logic, but the classes in WinForms are all attributed with [Serializable]. However, the attribute does not exist in Windows Phone or Windows Store Apps. Is there a reason this was omitted? This is the same for the ISerializable interface. In the list at the bottom of the MSDN docs, it does actually include both Windows 8 and Windows Phone 8.

我不明白为什么这些类型被删除,因为它们都有用非常通用。

I do not understand why these type were removed as they are both helpful as well as very generic.

我发现可序列化属性仅由BinaryFormatter使用,而不是在Windows Phone上,为什么会删除它?我看到可以使用[DataContract]而不是[Serializable],它是用于不同的方法,还是
弃用了?我将其视为[Serializable]以及BinaryFormatter序列化所有内容,除了[NonSerialized]和[DataContract]除了[DataMember]之外什么都没有序列化。这是正确的吗?

I worked out that the serializable attribute was only used by the BinaryFormatter, which is not on Windows Phone, why was this removed? I see that the [DataContract] can be used instead of [Serializable], is it just for different methods, or is one deprecated? I see it as [Serializable] along with the BinaryFormatter serialized everything, except the [NonSerialized] and the [DataContract] serialized nothing except [DataMember]s. Is this correct?

另外,如果我省略Windows Phone和WinForms上的[Serializable]属性,我可以正常使用XmlSerializer。如果被忽略,属性的重点是什么?是仅仅用于BinaryFormatter,还是用于其他目的?

Also, if I omit the [Serializable] attribute on both Windows Phone and WinForms, I can use the XmlSerializer just fine. What is the point of the attributes if they are ignored? Is it just for the BinaryFormatter, or do they serve another purpose?

最后一点,如果IS PhoneizableAttribute在Windows Phone上不可用,那么如何实现类似的功能?

And one last thing, if the ISerializableAttribute is not available on Windows Phone, how does one achieve similar functionality?

推荐答案

所以,让我们忽略"为什么"现在的问题。我保证这些问题的答案是您不同意或不允许知道的,因为您不为Microsoft工作。 仅供参考,我不知道这些问题的答案




真正的问题是:你想做什么,你可以'现在使用API​​,是否也适用于8.1 API?
So, let's ignore the "why" questions for now. I guarantee that there are answers for these questions that you either don't agree with, or aren't allowed to know since you don't work for Microsoft.  FYI, I don't know the answers to these questions either.

The real question is: What is it you want to do that you can't do with the APIs as they are right now, and does it hold true for the 8.1 APIs as well?


这篇关于为什么从Windows Phone中删除了[Serializable]属性(以及其他属性)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆