public static string Serialize(Unity.PackageManager.Ivy.IvyModule module) { HasErrors = false; ErrorMessage = null; ErrorException = null; Unity.PackageManager.IvyInternal.IvyModule o = Cloner.CloneObject <Unity.PackageManager.IvyInternal.IvyModule>(module); IvyRoot root = new IvyRoot { Module = o }; StringBuilder builder = new StringBuilder(); using (UTF8StringWriter writer = new UTF8StringWriter(builder)) { XmlSerializable.GetSerializer(o.GetType()).Serialize(writer, o, Namespaces); } return(builder.ToString().Replace("<root>", "").Replace("</root>", "")); }
public static string Serialize(IvyModule module) { IvyParser.HasErrors = false; IvyParser.ErrorMessage = null; IvyParser.ErrorException = null; Unity.PackageManager.IvyInternal.IvyModule ivyModule = Cloner.CloneObject <Unity.PackageManager.IvyInternal.IvyModule>(module); IvyRoot ivyRoot = new IvyRoot(); ivyRoot.Module = ivyModule; StringBuilder stringBuilder = new StringBuilder(); using (UTF8StringWriter uTF8StringWriter = new UTF8StringWriter(stringBuilder)) { XmlSerializer serializer = XmlSerializable.GetSerializer(ivyModule.GetType()); serializer.Serialize(uTF8StringWriter, ivyModule, IvyParser.Namespaces); } return(stringBuilder.ToString().Replace("<root>", string.Empty).Replace("</root>", string.Empty)); }