コード例 #1
0
 public static string Generate(string path,ScriptableXml sxml)
 {
     List<string> allNamespaces = new List<string>();
     sxml.Assembly.ForEach(s =>
     {
         if (!string.IsNullOrEmpty(s.Namespace))
             allNamespaces.Add(s.Namespace);
     });
     Lua4NetSerializer serializer = new Lua4NetSerializer(0);
     allNamespaces.ForEach(n =>
     {
         serializer.NewLine(string.Format("{0} = { }",n));
     });
     return Path.Combine(path, "namespace.lua");
 }
コード例 #2
0
        public void GenerateProxy(string path,ScriptableXml sxml)
        {
            List<string> allfile = new List<string>();
            GenerateProxyImpl(csd =>
            {
                if (csd.IsEnum)
                {
                    GenerateEnum(csd, path);
                    allfile.Add(csd.LuaFileName);
                }
                else
                {
                    Lua4NetSerializer serializer = new Lua4NetSerializer(0);
                    ProxyGenerator.Generate(csd, serializer);

                    string content = serializer.ToString();
                    Console.WriteLine(content);

                    string filename = csd.LuaFileName;
                    string fullpath = Path.Combine(path, filename);
                    allfile.Add(filename);

                    SaveAsFile(fullpath, content);
                }
            });

            Lua4NetSerializer rs = new Lua4NetSerializer(0);
            rs.NewLine();

            List<string> allNamespaces = new List<string>();
            sxml.Assembly.ForEach(s =>
            {
                if (!string.IsNullOrEmpty(s.Namespace))
                {
                    GetNamespace(s.Namespace).ForEach(ns=>
                    {
                        if (!allNamespaces.Contains(ns))
                        {
                            allNamespaces.Add(ns);
                        }
                    });
                }
            });

            if (allNamespaces.Count > 0)
            {
                allNamespaces.ForEach(n =>
                {
                    rs.NewLine(n + " = { }");
                });
            }

            allfile.ForEach(s =>
            {
                char ch1 = '\\';
                char ch2 = '/';
                s = s.Replace(ch1, ch2);
                rs.NewLine(string.Format("dofile('{0}')", s));
            });
            rs.NewLine("print('load Lua4NetRoot done!')");
            string rp = Path.Combine(path, "Lua4NetRoot.lua");
            SaveAsFile(rp, rs.ToString());
        }
コード例 #3
0
ファイル: Description.cs プロジェクト: huiguochen/Lua4Net
 public static ScriptableXml Create(string path)
 {
     using (FileStream fs = File.Open(path, FileMode.Open))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(ScriptableXml));
         Instance = serializer.Deserialize(fs) as ScriptableXml;
     }
     return Instance;
 }