/// <summary> Returns true if the type is a base type. </summary> public static bool IsBaseType(Type type) { if (type.IsEnum) { return(true); } if (BaseSerializeMethods.ContainsKey(type)) { return(true); } if (BaseStyledSerializeMethods.ContainsKey(type)) { return(true); } return(false); }
internal static string SerializeBaseType(object thing, Type type, FileStyle style) { if (BaseSerializeMethods.TryGetValue(type, out var method)) { return(method(thing)); } if (BaseStyledSerializeMethods.TryGetValue(type, out var stylemethod)) { return(stylemethod(thing, style)); } if (type.IsEnum) { return(SerializeEnum(thing, style)); } throw new Exception($"Cannot serialize base type {type} - are you sure it is a base type?"); }