Made AnimationEditor compatible with Dictionary SpriteMaps
Added MonoGame Pipeline's IntermediateSerializer and needed classes from the pipeline and MonoGame.Framework.Utilities to make AnimationEditor capable of reading Dictionaries
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate
|
||||
{
|
||||
class EnumSerializer : ContentTypeSerializer
|
||||
{
|
||||
public EnumSerializer(Type targetType) :
|
||||
base(targetType, targetType.Name)
|
||||
{
|
||||
}
|
||||
|
||||
protected internal override object Deserialize(IntermediateReader input, ContentSerializerAttribute format, object existingInstance)
|
||||
{
|
||||
var str = input.Xml.ReadString();
|
||||
try
|
||||
{
|
||||
return Enum.Parse(TargetType, str, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw input.NewInvalidContentException(ex, "Invalid enum value '{0}' for type '{1}'", str, TargetType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override void Serialize(IntermediateWriter output, object value, ContentSerializerAttribute format)
|
||||
{
|
||||
Debug.Assert(value.GetType() == TargetType, "Got invalid value type!");
|
||||
output.Xml.WriteString(value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user