dynamic-language-runtime

Expression.Lambda and query generation at runtime, nested property “Where” example

落爺英雄遲暮 提交于 2019-12-05 03:28:37
I found very nice answer on a question about building Expression Tree for Where query. Expression.Lambda and query generation at runtime, simplest "Where" example Can someone help me and show me how this example could be implemented in the scenario with nested property. I mean instead of: var result = query.Where(item => item.Name == "Soap") With that solution: var item = Expression.Parameter(typeof(Item), "item"); var prop = Expression.Property(item, "Name"); var soap = Expression.Constant("Soap"); var equal = Expression.Equal(prop, soap); var lambda = Expression.Lambda<Func<Item, bool>>

C# DLR, Datatype inference with Dynamic keyword

强颜欢笑 提交于 2019-12-05 00:31:44
问题 Just Asking : Why 'withOffset' variable is inferred as dynamic as Parse method returns Struct ? dynamic str = "22/11/2013 10:31:45 +00:01"; var withOffset = DateTimeOffset.Parse(str); and after explicit cast its back to Struct? dynamic str = "22/11/2013 10:31:45 +00:01"; var withOffset = DateTimeOffset.Parse((string)str); since the return type of DateTimeOffset.Parse is DateTimeOffset, and the compiler must know that. keeping that in mind, what ever method it invoke at runtime, the return is

IronPython exposing .Net type to the runtime engine

只谈情不闲聊 提交于 2019-12-05 00:27:35
问题 I'm looking to expose specific .Net types to the IronPython runtime. I can do this: ScriptEngine engine = Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); engine.Runtime.LoadAssembly(typeof(Program).Assembly); // current assembly with types But that exposes all types to the runtime. Is selective type loading possible? 回答1: No, you must load the entire assembly. This is internally managed by the ScriptDomainManager, which only keeps a list of loaded assemblies, not types. The

C# 3.5 DLR Expression.Dynamic Question

假装没事ソ 提交于 2019-12-04 12:51:26
I have inherited a small scripting language and I am attempting to port it to the DLR so that it is a little easier to manage. So far it has been fairly straight forward. I have run into a problem though attempting to dynamically call members of a variable. The current language runs on .NET and uses a parsing loop and reflection to do this, but I was hoping to get away from that. Here is an example of the script language: string $system1RemoteUri; string $dbconnection = $config.GetDBConnection ("somedb"); float $minBad = 0.998; float $minGood = 0.2; $systen1RemoteURI, $minBad, and $minGood are

Print out Linq Expression Tree Hierarchy

≡放荡痞女 提交于 2019-12-04 08:08:15
问题 The dynamic language runtime (DLR) has some pretty cool code for Expression's, including some very nice code to print out Expression trees which I want to use so that: int a = 1; int b = 2; Expression<Func<int, int>> expression = (c) => a + (b * c) expression.Evaluate(5, stringBuilder) Outputs: (5) => a + (b * c) = 11 Where a = 1 b * c = 10 Where b = 2 c = 5 I found some code on the net to do this but found that it only works if the expressiontakes in no arguments. http:/

DLR return type

跟風遠走 提交于 2019-12-04 04:21:27
I need some DLR help. I am implementing an IDynamicMetaObjectProvider and DynamicMetaObject but I am having some issues getting the expected return type. I am overiding BindInvokeMember in the metaobject, I can see all the args types but no return type. Anyone know how I get to it if possible? I know the return type is dynamic but what if the thing you are invoking is dependent on a return type. I don't know which action to perform in the DynamicMetaObject unless I know the return type the consumer is expecting. Update Two I cant paste my actual code here since it calls all kinds of work stuff

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

爷,独闯天下 提交于 2019-12-04 02:41:22
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 be a poor long term solution? As this is my first time adding scripting to an application though, I'd

Resources to learn how to create a compiler /interpreter for the .NET framework

痞子三分冷 提交于 2019-12-03 17:05:56
I'd like to learn more how to create a language for .NET framework. I think I'd like to build a DLR language. I'm having hard time founding good resources. I found a descent article on MSDN that was written more than a year ago. I also spent couple of hours looking at IronPython source code. Could you please share with your resources on this subject. Thanks Have a look at the links compiled on this blog. http://benjaminnitschke.com/post/2009/03/31/Writing-your-own-programming-language-with-the-DLR-%28Dynamic-Language-Runtime%29.aspx 来源: https://stackoverflow.com/questions/1448643/resources-to

C# DLR, Datatype inference with Dynamic keyword

喜夏-厌秋 提交于 2019-12-03 16:03:00
Just Asking : Why 'withOffset' variable is inferred as dynamic as Parse method returns Struct ? dynamic str = "22/11/2013 10:31:45 +00:01"; var withOffset = DateTimeOffset.Parse(str); and after explicit cast its back to Struct? dynamic str = "22/11/2013 10:31:45 +00:01"; var withOffset = DateTimeOffset.Parse((string)str); since the return type of DateTimeOffset.Parse is DateTimeOffset, and the compiler must know that. keeping that in mind, what ever method it invoke at runtime, the return is always DateTimeOffset. The specs tells Since your method takes dynamic as an argument, it qualifies for

Iron Python : what are good uses for Iron Python [closed]

大兔子大兔子 提交于 2019-12-03 15:46:36
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for. Could you write an app in it? or is it for adding a scripting language to your app? How do you guys use it? 回答1: Either or both :) I wouldn