dynamic-language-runtime

Optimising Method Calls on Dynamic Type

假装没事ソ 提交于 2019-12-11 13:46:19
问题 I have the following code that instantiates a registered COM object private dynamic server = null // Global variable. ... Type type = Type.GetTypeFromProgID("Svr.GrpCall"); this.server = Activator.CreateInstance(type); I can invoke methods from this COM/ dynamic object just fine using very intuitive notation string expectedResult = this.server.GroupInit(someString, someBoolean); For single calls the performance of calling such methods through the Dynamic Language Runtime (DLR) is liveable.

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

Ironpython - Named parameters to constructor

谁说胖子不能爱 提交于 2019-12-11 08:14:49
问题 When I create an instance of my C# class in IronPython with named parameters to the constructor, it is setting properties corresponding to the names of the parameters. I wish to disable this behavior so I can have better control on the order the properties are evaluated. Is this possible? 回答1: There's no way to turn this off without modifying IronPython. 来源: https://stackoverflow.com/questions/2517367/ironpython-named-parameters-to-constructor

C# dynamic support?

不羁的心 提交于 2019-12-11 03:35:40
问题 After reading this post and links I still have 2 questions Question #1 What is the criteria so that I would be able to execute dynamic code in c# ? must the target classes/objects rely on .net clr ? I mean if someone gives me a Pascal DLL , I guess I won't be able to use its code via dynamic ( or will ? )..so: What are the requirements for dynamic to work ? Question #2 For example : In script object - in order to increase an int the code should be : Scriptobj.SetProperty("Count", ((int

Syntax alternatives to casting of dynamic objects

烈酒焚心 提交于 2019-12-11 03:33:20
问题 I have an implementation of DynamicDictionary where all of the entries in the dictionary are of a known type: public class FooClass { public void SomeMethod() { } } dynamic dictionary = new DynamicDictionary<FooClass>(); dictionary.foo = new FooClass(); dictionary.foo2 = new FooClass(); dictionary.foo3 = DateTime.Now; <--throws exception since DateTime is not FooClass What I'd like is to be able to have Visual Studio Intellisense work when referencing a method of one of the dictionary entries

Why does storing a Nancy.DynamicDictionary in RavenDB only save the property-names and not the property-values?

纵饮孤独 提交于 2019-12-10 22:04:13
问题 I am trying to save (RavenDB build 960) the names and values of form data items passed into a Nancy Module via its built in Request.Form . If I save a straightforward instance of a dynamic object (with test properties and values) then everything works and both the property names and values are saved. However, if I use Nancy's Request.Form then only the dynamic property names are saved. I understand that I will have to deal with further issues to do with restoring the correct types when

C# monkey patching - is it possible?

巧了我就是萌 提交于 2019-12-10 19:23:52
问题 Is it possible to write a C# assembly which when loaded will inject a method into a class from another assembly? If yes, will the injected method be available from languages using DLR, like IronPython? namespace IronPython.Runtime { public class Bytes : IList<byte>, ICodeFormattable, IExpressionSerializable { internal byte[] _bytes; //I WANT TO INJECT THIS METHOD public byte[] getbytes() { return _bytes; } } } I need that method, and I would like to avoid recompiling IronPython if possible.

IL / CLR / DLR References?

让人想犯罪 __ 提交于 2019-12-10 18:31:42
问题 I'm wanting to learn more about IL and CLR / DLR under the hood. A friend of mine recommended the book "Inside Microsoft .NET IL Assembler", but since it came out in 2002 I fear it's pretty out of date at this point. Does anyone have any more up-to-date books or websites that can be used by someone who understands .NET languages to learn more about the inner workings of IL and the CLR? 回答1: Perhaps my answer is a bit late now, but the book "MS Press - Inside Microsoft .NET IL Assembler" is

Dynamic C# object used in C++/CLI

﹥>﹥吖頭↗ 提交于 2019-12-10 18:03:33
问题 I'm currently building a c++/cli interop library. The library will be consumed by c# and vb.net applications, and I would like to make use of .Net 4 dynamic typing. I have a configuration module that uses dynamic member access to refer to configuration keys, this works fine in c# but is giving me trouble in c++/cli (not entirely unexpected) Is there any way to use this library in C++/CLI (e.g. by invoking TryGetMember() directly or something)? If the C++/CLI library then passes the dynamic

Is IronPython usable as a replacement for CPython?

前提是你 提交于 2019-12-10 17:18:49
问题 Has IronPython gotten to a point where you can just drop it in as a replacement for CPython? To clarify: I mean can IronPython run applications originally written for CPython (no .NET involved, of course) 回答1: Yes, pretty much, at least on Windows with "real" (Microsoft) .NET underneath. If you're depending on C-coded extensions, chances are that ironclad can bail you out; you get 2.6 support, just about every CPython standard library or third-party extension module (maybe not trivial for