ironruby

.net 4 - run code from string - in C# / F# / IronRuby / IronPython

感情迁移 提交于 2019-12-11 10:18:19
问题 What ways do I have in .net to run code from string? Console.WriteLine(Compile("1 + 2 * 3")); // results is 7. What other options do we have? C# - Compile the code on runtime? IronRuby / IronPython? F#? 回答1: So, the dynamic languages like IronRuby and IronPython make it very easy to do what you want. Create a script engine and execute the string. Easy as that. C#, it is possible, using the Code DOM... but it it compiles the code every time into a DLL. This is a costly behavior and can cause

Does Visual Studio 2010 have tooling support for IronRuby?

微笑、不失礼 提交于 2019-12-11 04:24:38
问题 I am interested in the following features: Code highlighting, Intellisense, Refactorings, Code navigation (Go to Definition etc.). If this functionality is missing from Visual Studio 2010 maybe Microsoft is planning to add these features in the future or there are community project to develop IronRuby tooling add-in? 回答1: Microsoft has recently released IronPython tools for Visual Studio and they are working on the same thing for IronRuby. No planned release date yet but they are working on

Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?

夙愿已清 提交于 2019-12-09 15:01:36
问题 Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!): 1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable. 2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may

Is it possible to host the .Net DLR in an “idiot-proof” sandbox?

给你一囗甜甜゛ 提交于 2019-12-09 05:42:16
问题 I would like to host the Dynamic Language Runtime (DLR) in such a way that users who run arbitrary scripts in it cannot bring the process down? The DLR hosting spec describes how to host the DLR in a separate ApplicationDomain. This allows to tear down and unload a script runtime and to restrict certain operations through CAS (e.g. I can restrict file system access or disallow use of reflection). But are there also ways to for example: - restrict the maximum amount of memory used by a script?

IronRuby calling C# Extension Methods - Error - Compatibility in .NET 3.5

…衆ロ難τιáo~ 提交于 2019-12-08 10:08:55
问题 I have written an Extension Method off of DataGridView called HideColumns. public static class Extensions { public static void HideColumns(this DataGridView dataGridView, params string[] columnNames) { foreach (string str in columnNames) { if (dataGridView.Columns[str] != null) { dataGridView.Columns[str].Visible = false; } } } } I pass my grid into an IronRuby script as a variable called main_grid When my script calls main_grid.HideColumns("FirstName","LastName") the script blows up with

Executing a mixin method at the end of a class definition

丶灬走出姿态 提交于 2019-12-08 05:53:47
问题 I have a Mix-in that reflects on the receiver class to generate some code. This means that I need to execute the class method at the end of the class definition, like in this trivially dumbed down example: module PrintMethods module ClassMethods def print_methods puts instance_methods end end def self.included(receiver) receiver.extend ClassMethods end end class Tester include PrintMethods def method_that_needs_to_print end print_methods end I'd like to have the mixin do this for me

How to use an IronRuby block with a C# method

放肆的年华 提交于 2019-12-07 10:26:14
问题 I'm using IronRuby and trying to work out how to use a block with a C# method. This is the basic Ruby code I'm attempting to emulate: def BlockTest () result = yield("hello") puts result end BlockTest { |x| x + " world" } My attempt to do the same thing with C# and IronRuby is: string scriptText = "csharp.BlockTest { |arg| arg + 'world'}\n"; ScriptEngine scriptEngine = Ruby.CreateEngine(); ScriptScope scriptScope = scriptEngine.CreateScope(); scriptScope.SetVariable("csharp", new

Can I compile IronRuby project in VS2010 into DLL/exe file?

心已入冬 提交于 2019-12-07 08:19:29
问题 After created IronRuby project in VS2010 by using IronRuby v1.1.x, I was able to use almost .NET library by importing them. But can't actually compile ironruby into exe/DLL. I see the build option but can't build any exe or DLL from IronRuby project. Please help ! 回答1: You can't compile your IronRuby classes into a .NET assembly and then access them from another assembly. Preet is right that the nearest you can get is to embed your IronRuby scripts in (say) a C# assembly. From the C# side it

is F# to IronPython/IronRuby as C# is to VB.NET?

老子叫甜甜 提交于 2019-12-07 01:30:50
问题 I just listened to podcast of Chris Smith talking about F# in which he talks about how F# is a language which allows you to approach problems in a different way than in C#/VB.NET, i.e. instead of "pushing bits around" you "chain together data transformations", and that how F# will "become like XML", something that you use in addition to your language of choice (C# or VB.NET) in order to solve certain problems in a more efficient way. This got me to thinking about the relationship of the .NET

Executing a mixin method at the end of a class definition

吃可爱长大的小学妹 提交于 2019-12-06 15:58:13
I have a Mix-in that reflects on the receiver class to generate some code. This means that I need to execute the class method at the end of the class definition, like in this trivially dumbed down example: module PrintMethods module ClassMethods def print_methods puts instance_methods end end def self.included(receiver) receiver.extend ClassMethods end end class Tester include PrintMethods def method_that_needs_to_print end print_methods end I'd like to have the mixin do this for me automatically, but I can't come up with a way. My first thought was to add receiver.print_methods to self