ironruby

Are IronPython or IronRuby well-suited for the MVVM pattern in WPF/Silverlight?

雨燕双飞 提交于 2019-12-24 01:54:49
问题 I've been very happily using the Model-View-ViewModel (MVVM) pattern in WPF and Silverlight apps in combination with C#. Declarative XAML markup and data binding are invaluable - I just can't live without them. But, this talk by Harry Pierson on dynamic languages got me excited about learning a dynamic language, and I'd like to try one out in a new project. I've been enjoying reading IronPython In Action, and it does contain a few WPF examples - but only with imperative-style code. What are

IronRuby performance issue while using Variables

瘦欲@ 提交于 2019-12-23 04:09:19
问题 Here is code of very simple expression evaluator using IronRuby public class BasicRubyExpressionEvaluator { ScriptEngine engine; ScriptScope scope; public Exception LastException { get; set; } private static readonly Dictionary<string, ScriptSource> parserCache = new Dictionary<string, ScriptSource>(); public BasicRubyExpressionEvaluator() { engine = Ruby.CreateEngine(); scope = engine.CreateScope(); } public object Evaluate(string expression, DataRow context) { ScriptSource source;

Short namespace acronym in ruby

久未见 提交于 2019-12-22 03:47:02
问题 I'm very new to ruby. I use IronRuby and my ruby code has long namespaces: Company:: Division::Group::Product::Package.new since I use this ns multiple times is there a way to create a shortcut? In c# I add a using clause so I'm not required to specify the full prefix. 回答1: You can simply assign it to another constant, like: Package = Company::Division::Group::Product::Package Package.new 回答2: You can also use the "include" method, which is more Ruby-esk: include Company::Division::Group:

How do I Implement an interface in IronRuby that includes CLR Events

随声附和 提交于 2019-12-21 20:35:06
问题 I'm experimenting with IronRuby and WPF and I'd like to write my own commands. What I have below Is as far as I can figure out. class MyCommand include System::Windows::Input::ICommand def can_execute() true end def execute() puts "I'm being commanded" end end But the ICommand interface defines the CanExecuteChanged event. How do I implement that in IronRuby? Edit: Thanks to Kevin's response Here's what works based on the 27223 change set of the DLR. The value passed in to can_execute and

How to use ErrorListener for IronRuby

不想你离开。 提交于 2019-12-20 03:29:06
问题 I have a C# program to execute an IronRuby script. But before doing that, I'd like to compile the file first to see if there is any errors. But it seems the ErrorListener does not work well. Is there anything wrong with my code? class Program { static void Main(string[] args) { try { ScriptEngine engine = null; engine = Ruby.CreateEngine(); ScriptSource sc = engine.CreateScriptSourceFromFile("MainForm.rb"); ErrorListener errLis = new MyErrorListener(); sc.Compile(errLis); } } class

Key based authenication with net-sftp in Ruby

风格不统一 提交于 2019-12-19 02:49:32
问题 I want to be able to use SFTP to login into a number of servers and download certain files to help debug issues as and when they arise. While we could use a client, we wanted to start automating the process to streamline everything. My first attempt looks something like this: def download(files_to_download, destination_directory) Net::SFTP.start(@server, @username, :password => @password) do |sftp| files_to_download.each do |f| local_path = File.join(destination_directory, File.basename(f))

How do you add a string to a c# IList<string> from IronRuby?

前提是你 提交于 2019-12-13 04:59:43
问题 I get the following exception when I try to use a ruby script to modify a list of c# strings. Unhandled Exception: System.ArgumentException: The value "Scott" is not of type "System.String" and cannot be used in this generic collection. c# IList<string> names = new List<string>(); names.Add("scott"); names.Add("jason"); ScriptRuntime runtime = IronRuby.Ruby.CreateRuntime(); ScriptEngine engine = runtime.GetEngine("IronRuby"); ScriptScope scope = engine.CreateScope(); scope.SetVariable("names"

IronRuby performance?

故事扮演 提交于 2019-12-12 14:10:55
问题 While I know IronRuby isn't quite ready for the world to use it, I was wondering if anyone here tried it and tested how well it faired against the other Rubies out there in terms of raw performance? If so, what are the results, and how did you go about measuring the performance (which benchmarks etc)? Edit : The IronRuby team maintains a site on how they compare to Ruby MRI 1.8 at http://ironruby.info/. Below the spec pass rate table, they also have some information on how IronRuby performs

Returning a CLR type from IronRuby

冷暖自知 提交于 2019-12-12 12:15:59
问题 I am trying to return a CLR object from Iron Ruby. I have the following CLR type defined in C# public class BuildMetaData { public string Description { get; set; } } I have the following IronRuby file: $:.unshift(File.dirname(__FILE__) + '/../bin/Debug') require 'mscorlib' require 'Horn.Core.DSL.Domain' class MetaDataFactory def return_meta_data() meta = Horn::Core::DSL::Domain::BuildMetaData.new meta.Description = "A description of sorts" meta end end I have the following test that is

IronRuby and Handling XAML UI Events

坚强是说给别人听的谎言 提交于 2019-12-11 11:52:42
问题 What it is the most brief and concise way of adding event handlers to UI elements in XAML via an IronRuby script? Assumption: the code to add the event handler would be written in the IronRuby script and the code to handle the event would be in the same IronRuby script. I'd like the equivalent of the following code but in IronRuby. Handling a simple button1 click event. public partial class Window1 : Window { public Window1() { InitializeComponent(); button1.Click += new RoutedEventHandler