dynamic-language-runtime

Is it possible to load and execute C# snippets using DLR?

眉间皱痕 提交于 2019-12-03 07:03:43
The majority of material I have found regarding DLR is related to IronPython. Can you parse and execute C# using DLR? If so is there over head that would prevent you from attempting this on a web server with about 30 users? More specifically I would like to script the configuration of my workflow objects when a user first initiates a workflow. Depending on conditions that change through out the year workflows may start at different steps, hence running configuration scripts seems like a good way to handle the variation. It sounds like you're really talking about the C# "compiler as a service"

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

和自甴很熟 提交于 2019-12-03 06:49:52
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? - restrict the number of threads created by a script? - detect deadlocked scripts? I think such fine

Call-site explanation?

浪尽此生 提交于 2019-12-03 05:06:48
问题 scaning the internet , im having trouble understanding in a simple manner - the term call-site (@dlr). ive been reading here that CallSite is : one site says The location in which the method is called. one book say : call site . This is the sort of atom of the DLR - the smallest piece of codewhich can be considered as a single unit. One expression may contain a lot of call sites, but the behavioris built up in the natural way, evaluating one call site at a time. For the rest of the discussion

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

吃可爱长大的小学妹 提交于 2019-12-03 04:28:58
Closed . This question needs to be more focused. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it focuses on one problem only by editing this post . 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? Either or both :) I wouldn't claim to know a specific "purpose" for IronPython but it certainly can be used to write applications, and it can

Print out Linq Expression Tree Hierarchy

陌路散爱 提交于 2019-12-02 19:27:04
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://incrediblejourneysintotheknown.blogspot.com/2009/02/displaying-nested-evaluation-tree-from.html I then discovered the DLR

Call-site explanation?

僤鯓⒐⒋嵵緔 提交于 2019-12-02 18:22:18
scaning the internet , im having trouble understanding in a simple manner - the term call-site (@dlr). ive been reading here that CallSite is : one site says The location in which the method is called. one book say : call site . This is the sort of atom of the DLR - the smallest piece of codewhich can be considered as a single unit. One expression may contain a lot of call sites, but the behavioris built up in the natural way, evaluating one call site at a time. For the rest of the discussion, we'll onlyconsider a single call site at a time. It's going to be useful to have a small example of a

IronPython DLR; passing parameters to compiled code?

半腔热情 提交于 2019-12-02 03:34:04
问题 I'm currently doing the following to create and execute a simple python calculation, using DLR: ScriptRuntime runtime = Python.CreateRuntime(); ScriptEngine engine = runtime.GetEngine("py"); MemoryStream ms = new MemoryStream(); runtime.IO.SetOutput(ms, new StreamWriter(ms)); ScriptSource ss = engine.CreateScriptSourceFromString("print 1+1", SourceCodeKind.InteractiveCode); CompiledCode cc = ss.Compile(); cc.Execute(); int length = (int)ms.Length; Byte[] bytes = new Byte[length]; ms.Seek(0,

IronPython DLR; passing parameters to compiled code?

僤鯓⒐⒋嵵緔 提交于 2019-12-02 03:23:21
I'm currently doing the following to create and execute a simple python calculation, using DLR: ScriptRuntime runtime = Python.CreateRuntime(); ScriptEngine engine = runtime.GetEngine("py"); MemoryStream ms = new MemoryStream(); runtime.IO.SetOutput(ms, new StreamWriter(ms)); ScriptSource ss = engine.CreateScriptSourceFromString("print 1+1", SourceCodeKind.InteractiveCode); CompiledCode cc = ss.Compile(); cc.Execute(); int length = (int)ms.Length; Byte[] bytes = new Byte[length]; ms.Seek(0, SeekOrigin.Begin); ms.Read(bytes, 0, (int)ms.Length); string result = Encoding.GetEncoding("utf-8")

Use DLR to run code generated with CompileAssemblyFromSource?

假装没事ソ 提交于 2019-12-01 18:11:20
问题 Following up on this excellent answer, I'm wondering if the DLR using the dynamic keyword can allow a less verbose way of writing code for the generated assembly. For example, can the aforementioned answer's code: using (Microsoft.CSharp.CSharpCodeProvider foo = new Microsoft.CSharp.CSharpCodeProvider()) { var res = foo.CompileAssemblyFromSource( new System.CodeDom.Compiler.CompilerParameters() { GenerateInMemory = true }, "public class FooClass { public string Execute() { return \"output!\";

How do you implement C#4's IDynamicObject interface?

≡放荡痞女 提交于 2019-11-30 09:41:31
To implement "method-missing"-semantics and such in C# 4.0, you have to implement IDynamicObject: public interface IDynamicObject { MetaObject GetMetaObject(Expression parameter); } As far as I can figure out IDynamicObject is actually part of the DLR, so it is not new. But I have not been able to find much documentation on it. There are some very simple example implementations out there (f.x. here and here ), but could anyone point me to more complete implementations or some real documentation? Especially, how exactly are you supposed to handle the "parameter"-parameter? The short answer is