Exemplo n.º 1
0
        public static string Serialize(Unity.PackageManager.Ivy.ModuleRepository repo)
        {
            HasErrors      = false;
            ErrorMessage   = null;
            ErrorException = null;
            Unity.PackageManager.IvyInternal.ModuleRepository repository = Cloner.CloneObject <Unity.PackageManager.IvyInternal.ModuleRepository>(repo);
            IvyRoot o = new IvyRoot {
                Repository = repository
            };
            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>", ""));
        }
Exemplo n.º 2
0
        public static string Serialize(ModuleRepository repo)
        {
            IvyParser.HasErrors      = false;
            IvyParser.ErrorMessage   = null;
            IvyParser.ErrorException = null;
            Unity.PackageManager.IvyInternal.ModuleRepository repository = Cloner.CloneObject <Unity.PackageManager.IvyInternal.ModuleRepository>(repo);
            IvyRoot ivyRoot = new IvyRoot();

            ivyRoot.Repository = repository;
            StringBuilder stringBuilder = new StringBuilder();

            using (UTF8StringWriter uTF8StringWriter = new UTF8StringWriter(stringBuilder))
            {
                XmlSerializer serializer = XmlSerializable.GetSerializer(ivyRoot.GetType());
                serializer.Serialize(uTF8StringWriter, ivyRoot, IvyParser.Namespaces);
            }
            return(stringBuilder.ToString().Replace("<root>", string.Empty).Replace("</root>", string.Empty));
        }