从.Net转换为winRT

时间:2013-12-10 05:30:58

标签: windows-8 windows-phone-8 windows-runtime c#-5.0

我有以下代码;我想将其转换为winRT。实际上,我不知道如何处理ISerializable,Serializable,SerializationInfo和COMPACT_FRAMEWORK

using System;
using System.Collections;
#if !COMPACT_FRAMEWORK
using System.Runtime.Serialization;
#endif

namespace Coversant.Attributes
{
    [Serializable]
public class AssertionFailedError : Exception
      #if !COMPACT_FRAMEWORK, ISerializable
      #endif
    {
      #if !COMPACT_FRAMEWORK
    protected AssertionFailedError(SerializationInfo info, StreamingContext context) :        base(info, context){}
      #endif
}

}

1 个答案:

答案 0 :(得分:1)

嗯,COMPACT_FRAMEWORK,我相信你在一些旧的,小型设备和预处理器指令(#if#endif)上的内容只是界定在构建时编译代码时应该使用的代码除了Compact Framework之外的任何东西。 WinRT实际上类似于缺少这些,但也缺少Serializable属性,所以你会做这样的事情,这本质上是一个简单的异常类定义,不包括任何新的或被覆盖的成员:

using System;
using System.Collections;
#if (!COMPACT_FRAMEWORK && !NETFX_CORE)
using System.Runtime.Serialization;
#endif

namespace Coversant.Attributes
{
#if !NETFX_CORE
    [Serializable]
#endif
    public class AssertionFailedError : Exception
#if (!COMPACT_FRAMEWORK && !NETFX_CORE)
    , ISerializable
#endif
    {
#if (!COMPACT_FRAMEWORK && !NETFX_CORE)
        protected AssertionFailedError(SerializationInfo info, StreamingContext context) :        base(info, context){}
#endif
    }
} 
相关问题