{"id":42494040,"url":"https://github.com/simplic/simplic-dlr","last_synced_at":"2026-01-28T12:36:21.132Z","repository":{"id":103996921,"uuid":"45927688","full_name":"simplic/simplic-dlr","owner":"simplic","description":"Provides classes and methods to easily integrate dlr languages like IronPython into your application without loosing flexibility.","archived":false,"fork":false,"pushed_at":"2020-10-05T18:16:36.000Z","size":5171,"stargazers_count":3,"open_issues_count":3,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-01-14T08:33:49.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-11-10T17:15:56.000Z","updated_at":"2020-10-05T18:16:37.000Z","dependencies_parsed_at":"2023-06-03T02:00:11.937Z","dependency_job_id":null,"html_url":"https://github.com/simplic/simplic-dlr","commit_stats":null,"previous_names":["simplicbe/simplic.dlr"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/simplic/simplic-dlr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplic%2Fsimplic-dlr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplic%2Fsimplic-dlr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplic%2Fsimplic-dlr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplic%2Fsimplic-dlr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplic","download_url":"https://codeload.github.com/simplic/simplic-dlr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplic%2Fsimplic-dlr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28845281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T10:53:21.605Z","status":"ssl_error","status_checked_at":"2026-01-28T10:53:20.789Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-28T12:36:20.212Z","updated_at":"2026-01-28T12:36:21.126Z","avatar_url":"https://github.com/simplic.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simplic.Dlr\n\nSimplic.Dlr is a library to use the Microsoft Dlr in a very simple and efficient way, without loosing flexibility.\nThe library provides the following functions:\n\n* Very easy usage of the Microsoft Dlr and IronPython without loosing flexibility: `DlrHost`\n* Integrated Dlr-Class to interact between C# and Python class: `DlrClass`\n  * Easily write wrappers of IronPython classes to use them as a .Net class\n* Access dlr variables easily over the integrated `DlrScriptScope`\n* Easily write your own script import resolver, to load scripts and even package from the database or any other source: `IDlrImportResolver`\n* Precompile code for easy and faster usage\n* Cache scripts/statements for faster execution\n* Simple using/importing all dlls which are loaded into the current `AppDomain`. So all assemblies will automatically registered in the current ScriptEngine.\n\n## Installation\n\n### Compile\n\nJust clone the current repository and open the *Simplic.Dlr* solution in the *src* directory. After compiling \njust copy all needed assemblies (Simplic.Dlr, IronPython.dll, Microsoft.Scripting, ...).\n\n_Be sure you use the IronPython dlls from the `dependencies` directory._\n\n### Nuget [not up-to-date]\n\nYou can find the newest and stable version at nuget.\n\n[![NuGet Status](http://img.shields.io/nuget/v/Simplic.Dlr.svg?style=flat)](https://www.nuget.org/packages/Simplic.Dlr/)\n\n_Please use a self compiled version. Or download from releases._\n\n## Samples\n\nA list of samples can be found in the `src/Samples` directory of the repository.\n\n## Getting started:\n\nInstall `Simplic.Dlr` by compiling on your own or using [nuget](https://www.nuget.org/packages/Simplic.Dlr/).\n\n### Initialize Simplic.Dlr\n\nTo use Simplic.Dlr you always need to create a `DlrHost`. A `DlrHost` will always be initialized with a specific language:\n\n    var host = new DlrHost\u003cIronPythonLanguage\u003e(new IronPythonLanguage());\n    \nTha's all you need to initialize the following component:\n\n1. ScriptEngine\n2. ScriptRuntime\n3. Default scope\n\n### Execute IronPython code\n\nTo execute a line of IronPython code just use default scope and execute the script directly:\n\n```csharp\nhost.DefaultScope.Execute(\"print 'Hello World'\");\n```\n\n### Set search paths for modules\n\nThe host provides methods to add and remove search paths very easily\n\n*Add search path to the host*\n\n```csharp\nhost.AddSearchPath(\"C:\\\\Python\\\\lib\")\n```\n\n*Remove search path from the host*\n\n```csharp\nif (host.RemoveSearchPath('C:\\\\Python\\\\lib'))\n{\n    // Removes successfully        \n}\n```\n\n### Create an instance of an IronPython class in C# and access it's member\n\n```csharp\nhost.DefaultScope.Execute(\"class TestClass(object):\\r\\n\"\n    + \"    var1 = ''\\r\\n\"\n    + \"    def doPrint(self, txt):\\r\\n\"\n    + \"        print txt\\r\\n\"\n    + \"\"\n    + \"    def doPrintVar(self):\\r\\n\"\n    + \"        print self.var1\\r\\n\");\n\n// Call via name of the method\nvar instance = host.DefaultScope.CreateClassInstance(\"TestClass\");\ninstance.CallMethod(\"doPrint\", \"Text to print?\");\n\n// Call directly over the embedded dynamic keyword\ndynamic dynInstance = instance;\ndynInstance.doPrint(\"Text 2 to print!\");\n\n// Set variable an print out\ninstance.SetMember(\"var1\", \"Variable content 1.\");\ninstance.CallMethod(\"doPrintVar\");\n\ndynInstance.var1 = \"Variable content 2.\";\ndynInstance.doPrintVar();\n```\n\n### Create a custom import source\n\nTo create a custom import source, you jsut have to do few things.\n\n1. Create a class which inherits from `IDlrImportResolver`\n2. Implement `GetModuleInformation` which should return a `ResolvedType.None` if nothing exists, `ResolvedType.Module` if it's a module. If it is a package, return `ResolvedType.Package`\n3. Register your created resolver using the Dlr-Host: `\u003c\u003cyour host\u003e\u003e.AddImportResolver(new \u003c\u003cYour import resolver\u003e\u003e());`\n\nFor more information take a look at: `Sample.ImportResolver`. This shows how to load embedded scripts from a project using `IDlrImportResolver`.\n\n### Create a c# wrapper for IronPython classes\n\n```csharp\n/// \u003csummary\u003e\n/// Simple wrapper class\n/// \u003c/summary\u003e\npublic class MathClass : DlrClass\n{\n    /// \u003csummary\u003e\n    /// Create math class\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"scriptScope\"\u003e\u003c/param\u003e\n    /// \u003cparam name=\"className\"\u003e\u003c/param\u003e\n    /// \u003cparam name=\"parameter\"\u003e\u003c/param\u003e\n    internal MathClass(DlrScriptScope scriptScope, params object[] parameter)\n        : base(scriptScope, \"MathClass\", parameter)\n    {\n\n    }\n\n    /// \u003csummary\u003e\n    /// Add data\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"x\"\u003ex to add\u003c/param\u003e\n    /// \u003cparam name=\"y\"\u003ey to add\u003c/param\u003e\n    /// \u003creturns\u003ereturns x + y\u003c/returns\u003e\n    public int Add(int x, int y)\n    {\n        return CallFunction(\"add\", x, y);\n    }\n\n    /// \u003csummary\u003e\n    /// Subtract data\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"x\"\u003ex value\u003c/param\u003e\n    /// \u003cparam name=\"y\"\u003ey to substract from x\u003c/param\u003e\n    /// \u003creturns\u003ereturns x - y\u003c/returns\u003e\n    public int Sub(int x, int y)\n    {\n        return CallFunction(\"sub\", x, y);\n    }\n}\n\nclass Program\n{\n    static void Main(string[] args)\n    {\n        // Create simple host environment\n        var host = new DlrHost\u003cIronPythonLanguage\u003e(new IronPythonLanguage());\n\n        // Define class\n        host.DefaultScope.Execute(\"class MathClass(object):\\r\\n\"\n            + \"\"\n            + \"    def add(self, x, y):\\r\\n\"\n            + \"        return x + y\\r\\n\"\n            + \"\"\n            + \"    def sub(self, x, y):\\r\\n\"\n            + \"        return x - y\\r\\n\");\n\n        // Use Math-class\n        var cl = new MathClass(host.DefaultScope);\n\n        // Call c# -\u003e python\n        Console.WriteLine(\"Add: 5 + 100 = \" + cl.Add(5, 100));\n        Console.WriteLine(\"Sub: 90 - 14 = \" + cl.Sub(90, 40));\n\n        Console.ReadLine();\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplic%2Fsimplic-dlr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplic%2Fsimplic-dlr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplic%2Fsimplic-dlr/lists"}