{"id":23858741,"url":"https://github.com/legendaryb/calamity","last_synced_at":"2026-05-30T10:30:16.614Z","repository":{"id":46003890,"uuid":"358419836","full_name":"LegendaryB/Calamity","owner":"LegendaryB","description":"A (mini) plugin framework for .NET applications. ","archived":false,"fork":false,"pushed_at":"2024-01-13T13:36:59.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-17T23:41:50.676Z","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/LegendaryB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-04-15T23:32:18.000Z","updated_at":"2021-11-21T12:42:42.000Z","dependencies_parsed_at":"2023-12-19T14:31:11.695Z","dependency_job_id":"960fc8d0-c065-4809-9efe-d91f52af85af","html_url":"https://github.com/LegendaryB/Calamity","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2FCalamity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2FCalamity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2FCalamity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2FCalamity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LegendaryB","download_url":"https://codeload.github.com/LegendaryB/Calamity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240163511,"owners_count":19758023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-01-03T03:17:17.538Z","updated_at":"2026-05-30T10:30:16.579Z","avatar_url":"https://github.com/LegendaryB.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿﻿﻿﻿\u003ch1 align=\"center\"\u003eCalamity\u003c/h1\u003e\u003cdiv align=\"center\"\u003e\n\n[![forthebadge](https://forthebadge.com/images/badges/fuck-it-ship-it.svg)](https://forthebadge.com)\n[![forthebadge](https://forthebadge.com/images/badges/made-with-c-sharp.svg)](https://forthebadge.com)\n\n[![GitHub license](https://img.shields.io/github/license/LegendaryB/Calamity.svg?longCache=true\u0026style=flat-square)](https://github.com/LegendaryB/Calamity/blob/master/LICENSE.md)\n[![Nuget](https://img.shields.io/nuget/v/Calamity.svg?style=flat-square)](https://www.nuget.org/packages/Calamity/)\n\nA (mini) plugin framework for .NET applications.\n\u003cbr\u003e\n\u003cbr\u003e\n\u003csub\u003eBuilt with ❤︎ by Daniel Belz\u003c/sub\u003e\n\u003c/div\u003e\u003cbr\u003e\n\n## Getting started\n\n### Configuration\nThe static `PluginLoaderOptions` class contains properties for the configuration of Calamity. The table should be self explaining.\n|Property|Description|Default value|\n|---|---|---|\n|LoggerFactory|Factory to provide a logger for the internal library types.|NullLogger|\n|TypeActivator|The default `ITypeActivator` which is used to create object instances. |.NET Framework Activator|\n|PreferAssembliesFromHost|Flag to indicate if the plugin should prefer assemblies from the host.|true|\n\n### Loading a plugin from a assembly\nTo load a plugin from a assembly you need to use the static `PluginLoaderFactory` class. The method `CreateLoaderFor\u003c\u003e` will return a generic `IPluginLoader` instance to you. This instance holds all metadata which is then required to create a instance of the plugin. After setting several properties on your `IPluginLoader` instance you can finally use the `Build` method. If you don't specify an alternate `ITypeActivator` implementation the default one from the `PluginLoaderOptions` will be used instead.\n\n```csharp\nclass Program\n{\n    static void Main()\n    {\n        var path = @\"C:\\MyPluginAssembly.dll\";\n        \n        // Will create a instance of a type which implements ITestPlugin and uses the default ITypeActivator.\n        var instance = PluginLoaderFactory\n            .CreateLoaderFor\u003cITestPlugin\u003e(path)\n            .Build();\n            \n        // Will create a instance of a type which implements ITestPlugin and uses the specified ITypeActivator.\n        var instance = PluginLoaderFactory\n            .CreateLoaderFor\u003cITestPlugin\u003e(path)\n            .Build(new MyTypeActivator());  \n            \n        // Will create a instance of a type which implements ITestPlugin and uses the default ITypeActivator in combination with constructor parameters.\n        var instance = PluginLoaderFactory\n            .CreateLoaderFor\u003cITestPlugin\u003e(path)\n            .AddConstructorParameters(\"param1\", \"param2\")\n            .Build();\n    }\n}\n```\n\n### Creating a ITypeActivator implementation\nA `ITypeActivator` instance is used to create a instance of an object from a type. To use a custom `ITypeActivator` you can set it global via the `PluginLoaderOptions.TypeActivator` property or give a instance as a parameter into the `IPluginLoader.Build` method.\n\n```csharp\nclass Program\n{\n    // Inherit from ITypeActivator interface and implement it\n    public class MyTypeActivator : ITypeActivator\n    {\n        public TInterface CreateInstance\u003cTInterface\u003e(Type implementationType, object[] args) \n            where TInterface : class\n        {\n            // Create the instance of the object\n            return Activator.CreateInstance(implementationType, args) as TInterface;\n        }\n    }\n\n    static void Main()\n    {\n        var path = @\"C:\\MyPluginAssembly.dll\";\n        \n        var myTypeActivator = new MyTypeActivator();\n\n        // Will create a instance of a type which implements ITestPlugin and uses the custom ITypeActivator.\n        var instance = PluginLoaderFactory\n            .CreateLoaderFor\u003cITestPlugin\u003e(path)\n            .Build(myTypeActivator);\n\n        // .. or set it global\n        PluginLoaderOptions.TypeActivator = myTypeActivator;\n\n        // Will create a instance of a type which implements ITestPlugin and uses the custom ITypeActivator specified in the options.\n        var instance = PluginLoaderFactory\n            .CreateLoaderFor\u003cITestPlugin\u003e(path)\n            .Build();\n    }\n}\n```\n\n\n## Contributing\n\n__Contributions are always welcome!__  \nWhen you send me a pull request please make sure to add some information regarding your changes, improvements or bugfixes.\n\n## License\n\nThis project is licensed under the MIT license - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flegendaryb%2Fcalamity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flegendaryb%2Fcalamity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flegendaryb%2Fcalamity/lists"}