Ejemplo n.º 1
0
        public static IvyModule FromPackageInfo(PackageInfo package)
        {
            IvyModule ivyModule = new IvyModule();

            ivyModule.Info.Organisation = package.organisation;
            ivyModule.Info.UnityVersion = package.unityVersion;
            ivyModule.Info.Module       = package.name;
            ivyModule.Info.Version      = package.version;
            ivyModule.Info.Type         = package.type;
            ivyModule.BasePath          = package.basePath;
            ivyModule.Loaded            = package.loaded;
            ivyModule.Artifacts.Add(new IvyArtifact
            {
                Name      = ivyModule.Info.FullName,
                Type      = ArtifactType.Ivy,
                Extension = "xml"
            });
            if (package.files != null)
            {
                ivyModule.Artifacts.AddRange(from f in package.files.Keys
                                             select new IvyArtifact(f)
                {
                    Type = (ArtifactType)package.files[f].type,
                    Url  = new Uri(package.files[f].url)
                });
            }
            return(ivyModule);
        }
Ejemplo n.º 2
0
        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));
        }