我希望将Lua嵌入到我的C#应用程序中,我认为C#的lua API周围有一个包装器,但是不记得它是什么.有人能指出我的方向吗?
我有一个方法,根据传递给它的动作委托改变"帐户"对象:
public static void AlterAccount(string AccountID, Action<Account> AccountAction) {
Account someAccount = accountRepository.GetAccount(AccountID);
AccountAction.Invoke(someAccount);
someAccount.Save();
}
Run Code Online (Sandbox Code Playgroud)
这按预期工作......
AlterAccount("Account1234", a => a.Enabled = false);
Run Code Online (Sandbox Code Playgroud)
...但是现在我想尝试做的是这样的方法:
public static void AlterAccount(string AccountID, string AccountActionText) {
Account someAccount = accountRepository.GetAccount(AccountID);
Action<Account> AccountAction = MagicLibrary.ConvertMagically<Action<Account>>(AccountActionText);
AccountAction.Invoke(someAccount);
someAccount.Save();
}
Run Code Online (Sandbox Code Playgroud)
它可以像以下一样使用:
AlterAccount("Account1234", "a => a.Enabled = false");
Run Code Online (Sandbox Code Playgroud)
禁用帐户"Account1234".
我已经看过linq动态查询库了,它似乎或多或少地做了我想要的但是对于Func类型的委托,而我对表达式树等的了解并不是很好来弄清楚如何实现我的目标想.
有没有一种简单的方法可以做我想要的,或者我是否需要正确学习表达式并编写大量代码?
(我想这样做的原因是允许从powershell脚本中批量更新帐户对象的简单方法,其中用户可以指定lambda表达式来执行更改.)
我有一个List<Student>包含让我们说500名学生.当我在断点上进入调试模式时,有没有办法过滤/搜索学生?
我不想为此检查编写代码,如下所示:
List<Student> students = data.GetStudents();
//break here and filter for student in debug mode
var myStudent = students.Where(k=>k.StudentNumber=="S12312");
Run Code Online (Sandbox Code Playgroud)
是否在Visual Studio 2013中无法执行此操作,我认为添加...将是一个很棒的功能...
我认为如果我能在运行时编写vb.net或c#代码会很有趣,而解释器会像python一样自动解析它,所以我做了一个小程序,它会做类似的事情.基本上它看起来像这样:
InputArgs = Console.ReadLine()
ParseInput(InputArgs.Split(" "))
Private Sub ParseInput(Args as List(Of String), Optional TempArgs as List(Of String))
Dim arg as string = Args(0)
If arg = ".." then
...
elseif arg = ".." then
...
end if
End Sub
Run Code Online (Sandbox Code Playgroud)
我知道这不是一个好的系统,但它显示了基础知识.所以我的问题是:是否有可能使vb.net或c#像python一样 - 在运行时解释?