public static LevelMetadata CreateFromXml(XmlWorldData xml)
        {
            LevelMetadata metadata = new LevelMetadata();

            metadata.FromXml(xml);
            return(metadata);
        }
        public static LevelMetadata LoadMetadataByGenre(Guid worldId, Genres genres)
        {
            string bucket = BokuGame.MyWorldsPath;

            if (genres != 0)
            {
                bucket = Utils.FolderNameFromFlags(genres);
            }

            string fullPath = BokuGame.Settings.MediaPath + bucket + worldId.ToString() + @".Xml";

            Xml.XmlWorldData xml = XmlWorldData.Load(fullPath, XnaStorageHelper.Instance);
            if (xml != null)
            {
                LevelMetadata data = new LevelMetadata();
                data.FromXml(xml);

                //minor hackery - seems previous versions of kodu will sometimes leave the genres set to 0
                //even though they should be updated for the bucket the level is in.  Then at load time, a run-time
                //genre is set.  This code will maintain that behavior for levels loaded through this helper
                if (bucket == BokuGame.DownloadsPath)
                {
                    //ensure downloads always have the downloads flag
                    data.Genres |= Genres.Downloads;
                }
                else if (bucket == BokuGame.BuiltInWorldsPath)
                {
                    //ensure built in worlds always have the built in flag
                    data.Genres |= Genres.BuiltInWorlds;
                }
                else if (bucket == BokuGame.MyWorldsPath)
                {
                    data.Genres |= Genres.MyWorlds;
                }

                return(data);
            }

            return(null);
        }