Reputation: 269
I have following code; I want to convert it for winRT. Actually, I dont know how to handle ISerializable, Serializable, SerializationInfo and 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
}
}
Upvotes: 0
Views: 261
Reputation: 31724
Well, COMPACT_FRAMEWORK is I believe what you would have on some old, small devices and the preprocessor directives (#if
, #endif
) simply delimit code that should be used when the code is compiled when building for anything but Compact Framework. WinRT is actually similar in having these missing, but also has the Serializable
attribute missing so you would do something like this, which is essentially a simple Exception class definition that doesn't include any new or overridden members:
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
}
}
Upvotes: 1