从共享项目

时间:2017-12-14 19:36:16

标签: c# xml visual-studio project shared

我正在使用Visual Studio for Mac和Xamarin

项目结构

Shared (Shared Project name)
    GameData
        Levels
            Level1
                Level1Data.xml
                Level1DataXML.cs
        ReadMe.txt

    MainMenuSystem
        LevelSelectionConfiguration.cs

Level1DataXML.cs:

using System;
using Foundation;

namespace Mind2MindV1.GameData.Levels.Level1
{
    [Preserve(AllMembers = true)]
    public class Level1DataXML
    {
        public string Title;
        public string Description;
        public string LevelPuzzlesData;
    }
}

Level1Data.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<Level1DataXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Title>Level 1</Title>
    <Description>Level 1 Puzzles Data</Description>
    <LevelPuzzlesData>GameData/Level1/Lvl1Puzzles/Level1PuzzlesData.xml</LevelPuzzlesData>
</Level1DataXML>

我的Conde in&#34; LevelSelectionConfiguration.cs&#34;

用于加载xml文件:

 var assembly = typeof(Level1DataXML).GetTypeInfo().Assembly; 
            Stream stream = assembly.GetManifestResourceStream("GameData.Levels.Level1.Level1Data.xml"); 
            using (var reader = new System.IO.StreamReader(stream)) { 
                var serializer = new XmlSerializer(typeof(Level1DataXML)); 
                xmlData = (Level1DataXML)serializer.Deserialize(reader); 
            }

assembly.GetManifestResourceStream(&#34; GameData.Levels.Level1.Level1Data.xml&#34);正在返回&#34; null&#34;

我做错了什么?

0 个答案:

没有答案