Fix serialization of custom exceptions.

This commit is contained in:
RoosterDragon
2015-12-29 20:11:39 +00:00
parent b5f24c3fa6
commit 5f13fa0343
3 changed files with 18 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ using System.Drawing.Imaging;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Primitives; using OpenRA.Primitives;
@@ -24,6 +25,7 @@ namespace OpenRA
{ {
public static class FieldLoader public static class FieldLoader
{ {
[Serializable]
public class MissingFieldsException : YamlException public class MissingFieldsException : YamlException
{ {
public readonly string[] Missing; public readonly string[] Missing;
@@ -42,6 +44,13 @@ namespace OpenRA
Header = missing.Length > 1 ? header : headerSingle ?? header; Header = missing.Length > 1 ? header : headerSingle ?? header;
Missing = missing; Missing = missing;
} }
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("Missing", Missing);
info.AddValue("Header", Header);
}
} }
public static Func<string, Type, string, object> InvalidValueAction = (s, t, f) => public static Func<string, Type, string, object> InvalidValueAction = (s, t, f) =>

View File

@@ -125,6 +125,7 @@ namespace OpenRA.Mods.Common.Commands
world.IssueOrder(new Order(command, world.LocalPlayer.PlayerActor, false)); world.IssueOrder(new Order(command, world.LocalPlayer.PlayerActor, false));
} }
[Serializable]
class DevException : Exception { } class DevException : Exception { }
} }
} }

View File

@@ -11,9 +11,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
namespace OpenRA.Utility namespace OpenRA.Utility
{ {
[Serializable]
public class NoSuchCommandException : Exception public class NoSuchCommandException : Exception
{ {
public readonly string Command; public readonly string Command;
@@ -22,6 +24,12 @@ namespace OpenRA.Utility
{ {
Command = command; Command = command;
} }
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("Command", Command);
}
} }
class Program class Program