本文整理汇总了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();
//.........这里部分代码省略.........