当前位置: 首页>>代码示例>>C#>>正文


C# Lua.CreateTable方法代码示例

本文整理汇总了C#中NLua.Lua.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# Lua.CreateTable方法的具体用法?C# Lua.CreateTable怎么用?C# Lua.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NLua.Lua的用法示例。


在下文中一共展示了Lua.CreateTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main(string[] args)
        {
            if (args.Contains("-h")) {
            var arglist = new List<string>(args);
            int index = arglist.IndexOf("-h");
            HOME = arglist [index + 1];
            arglist.RemoveAt(index);
            arglist.RemoveAt(index);
            args = arglist.ToArray();
              }

              if (args.Contains("-d")) {
            var arglist = new List<string>(args);
            int index = arglist.IndexOf("-d");
            CURRENT = arglist [index + 1];
            arglist.RemoveAt(index);
            arglist.RemoveAt(index);
            args = arglist.ToArray();
              }

              if (HOME == null) HOME = Directory.GetCurrentDirectory();
              if (CURRENT == null)  CURRENT = HOME;
              Directory.SetCurrentDirectory(CURRENT);

              if (args.Length == 0) args = new[] { "self.build" };

              if (args [0] == "help") {
            Logger.Default
              .Log("> ", false, COLOR).Log ("Available commands:")
              .Log("./kaizow ", false, COLOR).Log ("help                       - display this help message")
              .Log("./kaizow ", false, COLOR).Log ("update (<directory>)       - update kaizo from git repository or from <directory>")
              .Log("./kaizow ", false, COLOR).Log ("<tasks> (-arg <arguments>) - run <tasks> with optional <arguments>");
            return;
              } else if (args [0] == "version") {
            Logger.Default.Log ("Kaizo ", false).Log(VERSION, true, ConsoleColor.Magenta);
            return;
              }

              time.Start ();
              Logger.Default.Log("> ", false, COLOR).Log("Build started");
              Console.Write("Loading build script");

              lua = new Lua ();
              lua.LoadCLRPackage ();
              lua.DoString (@"
            package.path = package.path..';./?/project.lua'

            properties = {}
            dependencies = {
              project = {},
              system = {},
              nuget = {}
            }

            function project(name)
              return module(name, package.seeall)
            end
              ");

              var tasks = Assembly.GetExecutingAssembly().GetTypes().Where(
            t => String.Equals(t.Namespace, "Kaizo.Tasks", StringComparison.Ordinal) &&
            !String.Equals(t.Name, "Task", StringComparison.Ordinal)).ToArray();

              foreach (var task in tasks) {
            Activator.CreateInstance(task, lua);
              }

              lua.RegisterFunction ("task", typeof(Task).GetMethod("Call"));
              LuaFunction project = null;

              try {
            project = lua.LoadFile (Path.Combine(CURRENT, "project.lua"));
              } catch (LuaScriptException e) {
            Fail (e);
              }

              var cmdtasks = new List<string> (args);
              var cmdargs = new List<string> (args);

              if (args.Contains ("-arg")) {
            int index = cmdargs.IndexOf ("-arg");
            cmdargs.RemoveRange (0, index + 1);
            cmdtasks.RemoveRange (index, args.Length - 1);
              } else {
            cmdargs.Clear ();
              }

              var luaargs = lua.CreateTable ();

              foreach (var cmdarg in cmdargs) {
            var key = cmdarg.Replace ("\"", "").Replace ("'", "").Split ('=');
            luaargs [key [0]] = key [1];
              }

              lua ["arg"] = luaargs;

              Console.ForegroundColor = ConsoleColor.Magenta;
              Console.WriteLine(" [DONE]");
              Console.ResetColor();

//.........这里部分代码省略.........
开发者ID:nondev,项目名称:kaizo,代码行数:101,代码来源:Program.cs


注:本文中的NLua.Lua.CreateTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。