Repository: weikio/PluginFramework Branch: master Commit: 5414bf718ef3 Files: 206 Total size: 403.6 KB Directory structure: gitextract_7nw5d5uj/ ├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── THIRD-PARTY-NOTICES.txt ├── docs/ │ ├── logo.pdn │ └── logo_transparent_color.pdn ├── global.json ├── samples/ │ ├── BlazorApp/ │ │ ├── App.razor │ │ ├── BlazorApp.csproj │ │ ├── Data/ │ │ │ ├── WeatherForecast.cs │ │ │ └── WeatherForecastService.cs │ │ ├── Pages/ │ │ │ ├── Counter.razor │ │ │ ├── Error.razor │ │ │ ├── FetchData.razor │ │ │ ├── Index.razor │ │ │ └── _Host.cshtml │ │ ├── Program.cs │ │ ├── Shared/ │ │ │ ├── MainLayout.razor │ │ │ ├── NavMenu.razor │ │ │ └── SurveyPrompt.razor │ │ ├── Startup.cs │ │ ├── _Imports.razor │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot/ │ │ └── css/ │ │ ├── open-iconic/ │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font/ │ │ │ └── fonts/ │ │ │ └── open-iconic.otf │ │ └── site.css │ ├── ConsoleApp/ │ │ ├── ConsoleApp.csproj │ │ ├── FirstPlugin.cs │ │ ├── MyPlugin.cs │ │ ├── Program.cs │ │ └── SecondPlugin.cs │ ├── Shared/ │ │ ├── Weikio.PluginFramework.Samples.Shared/ │ │ │ ├── IMyPlugin.cs │ │ │ ├── IOperator.cs │ │ │ ├── IPlugin.cs │ │ │ ├── RemainderOperator.cs │ │ │ └── Weikio.PluginFramework.Samples.Shared.csproj │ │ └── Weikio.PluginFramework.Samples.SharedPlugins/ │ │ ├── MinusOperator.cs │ │ ├── MultiplyOperator.cs │ │ ├── SecondSharedPlugin.cs │ │ ├── SumOperator.cs │ │ └── Weikio.PluginFramework.Samples.SharedPlugins.csproj │ ├── WebApp/ │ │ ├── Controllers/ │ │ │ └── CalculatorController.cs │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── WebApp.csproj │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ ├── WebAppPluginsLibrary/ │ │ ├── CustomPlugin.cs │ │ └── WebAppPluginsLibrary.csproj │ ├── WebAppWithAppSettings/ │ │ ├── Controllers/ │ │ │ └── CalculatorController.cs │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── WebAppWithAppSettings.csproj │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ ├── WebAppWithDelegate/ │ │ ├── Controllers/ │ │ │ └── DelegateController.cs │ │ ├── ExternalService.cs │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── WebAppWithDelegate.csproj │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ ├── WebAppWithNuget/ │ │ ├── Controllers/ │ │ │ └── CalculatorController.cs │ │ ├── NugetLogger.cs │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── WebAppWithNuget.csproj │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ ├── WebAppWithRoslyn/ │ │ ├── Controllers/ │ │ │ └── RoslynController.cs │ │ ├── ExternalService.cs │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── WebAppWithRoslyn.csproj │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ ├── WinFormsApp/ │ │ ├── DivideOperator.cs │ │ ├── Form1.Designer.cs │ │ ├── Form1.cs │ │ ├── Form1.resx │ │ ├── Program.cs │ │ └── WinFormsApp.csproj │ ├── WinFormsPluginsLibrary/ │ │ ├── LabelPlugin.Designer.cs │ │ ├── LabelPlugin.cs │ │ ├── LabelPlugin.resx │ │ ├── TestPlugin.Designer.cs │ │ ├── TestPlugin.cs │ │ ├── TestPlugin.resx │ │ └── WinFormsPluginsLibrary.csproj │ └── WpfApp/ │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── DivideOperator.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WpfApp.csproj ├── src/ │ ├── PluginFramework.sln │ ├── Weikio.PluginFramework/ │ │ ├── Catalogs/ │ │ │ ├── AssemblyPluginCatalog.cs │ │ │ ├── AssemblyPluginCatalogOptions.cs │ │ │ ├── CompositePluginCatalog.cs │ │ │ ├── Delegates/ │ │ │ │ ├── ConversionRule.cs │ │ │ │ ├── DelegateCatalog.cs │ │ │ │ ├── DelegatePluginCatalogOptions.cs │ │ │ │ └── ParameterConversion.cs │ │ │ ├── EmptyPluginCatalog.cs │ │ │ ├── FolderPluginCatalog.cs │ │ │ ├── FolderPluginCatalogOptions.cs │ │ │ ├── TypePluginCatalog.cs │ │ │ └── TypePluginCatalogOptions.cs │ │ ├── Context/ │ │ │ ├── MetadataTypeFindingContext.cs │ │ │ ├── PluginAssemblyLoadContext.cs │ │ │ ├── PluginLoadContextOptions.cs │ │ │ ├── RuntimeAssemblyHint.cs │ │ │ └── UseHostApplicationAssembliesEnum.cs │ │ ├── TypeFinding/ │ │ │ ├── ITypeFindingContext.cs │ │ │ ├── TypeFinder.cs │ │ │ ├── TypeFinderCriteria.cs │ │ │ ├── TypeFinderCriteriaBuilder.cs │ │ │ └── TypeFinderOptions.cs │ │ └── Weikio.PluginFramework.csproj │ ├── Weikio.PluginFramework.Abstractions/ │ │ ├── IPluginCatalog.cs │ │ ├── IPluginCatalogExtensions.cs │ │ ├── Plugin.cs │ │ ├── PluginFrameworkOptions.cs │ │ ├── PluginNameOptions.cs │ │ └── Weikio.PluginFramework.Abstractions.csproj │ ├── Weikio.PluginFramework.AspNetCore/ │ │ ├── DefaultPluginOption.cs │ │ ├── PluginExtensions.cs │ │ ├── PluginFrameworkInitializer.cs │ │ ├── PluginProvider.cs │ │ ├── ServiceCollectionExtensions.cs │ │ ├── ServiceProviderExtensions.cs │ │ └── Weikio.PluginFramework.AspNetCore.csproj │ ├── Weikio.PluginFramework.Catalogs.NuGet/ │ │ ├── NugetFeedPluginCatalog.cs │ │ ├── NugetFeedPluginCatalogOptions.cs │ │ ├── NugetPackagePluginCatalog.cs │ │ ├── NugetPluginCatalogOptions.cs │ │ └── Weikio.PluginFramework.Catalogs.NuGet.csproj │ ├── Weikio.PluginFramework.Catalogs.Roslyn/ │ │ ├── InvalidCodeException.cs │ │ ├── RegularInitializer.cs │ │ ├── RoslynPluginCatalog.cs │ │ ├── RoslynPluginCatalogOptions.cs │ │ ├── ScriptInitializer.cs │ │ └── Weikio.PluginFramework.Catalogs.Roslyn.csproj │ └── Weikio.PluginFramework.Configuration/ │ ├── CatalogConfiguration.cs │ ├── Converters/ │ │ ├── AssemblyCatalogConfigurationCoverter.cs │ │ ├── FolderCatalogConfigurationConverter.cs │ │ └── IConfigurationToCatalogConverter.cs │ ├── Providers/ │ │ ├── IPluginCatalogConfigurationLoader.cs │ │ └── PluginCatalogConfigurationLoader.cs │ └── Weikio.PluginFramework.Configuration.csproj └── tests/ ├── Assemblies/ │ ├── JsonNetNew/ │ │ ├── JsonNetNew.csproj │ │ └── NewJsonResolver.cs │ ├── JsonNetOld/ │ │ ├── JsonNetOld.csproj │ │ └── OldJsonResolver.cs │ ├── TestAssembly1/ │ │ ├── FirstPlugin.cs │ │ ├── INotPluginInterface.cs │ │ ├── NotAPlugin.cs │ │ └── TestAssembly1.csproj │ ├── TestAssembly2/ │ │ ├── SecondPlugin.cs │ │ └── TestAssembly2.csproj │ ├── TestAssembly3/ │ │ ├── TestAssembly3.csproj │ │ └── ThirdAddon.cs │ └── TestIntefaces/ │ ├── ICommand.cs │ ├── IJsonVersionResolver.cs │ └── TestIntefaces.csproj ├── integration/ │ ├── WebSites/ │ │ └── PluginFrameworkTestBed/ │ │ ├── Controllers/ │ │ │ └── WeatherForecastController.cs │ │ ├── PluginFrameworkTestBed.csproj │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── WeatherForecast.cs │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ ├── Weikio.PluginFramework.AspNetCore.IntegrationTests/ │ │ ├── DefaultPluginTypeTests.cs │ │ ├── TestBase.cs │ │ ├── Weikio.PluginFramework.AspNetCore.IntegrationTests.csproj │ │ └── xunit.runner.json │ └── Weikio.PluginFramework.Catalogs.NuGet.Tests/ │ ├── NotThreadSafeResourceCollection.cs │ ├── NuGet.Config │ ├── NugetFeedPluginCatalogTests.cs │ ├── NugetPackagePluginCatalogTests.cs │ └── Weikio.PluginFramework.Catalogs.NuGet.Tests.csproj └── unit/ ├── Weikio.PluginFramework.Catalogs.Roslyn.Tests/ │ ├── RegularInitializerTests.cs │ ├── RoslynPluginCatalogTests.cs │ ├── ScriptInitializerTests.cs │ ├── TestHelpers.cs │ └── Weikio.PluginFramework.Catalogs.Roslyn.Tests.csproj └── Weikio.PluginFramework.Tests/ ├── AssemblyPluginCatalogTests.cs ├── DefaultOptionsTests.cs ├── DelegateCatalogTests.cs ├── FolderCatalogTests.cs ├── NotThreadSafeResourceCollection.cs ├── Plugins/ │ ├── AbstractPluginWithAttribute.cs │ ├── AnotherPluginWithAttribute.cs │ ├── MyPluginAttribute.cs │ ├── PluginWithAttribute.cs │ ├── TypePlugin.cs │ └── TypePluginWithName.cs ├── TagTests.cs ├── TypeFinderTests.cs ├── TypePluginCatalogTests.cs └── Weikio.PluginFramework.Tests.csproj ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root=true # EditorConfig is awesome:http://EditorConfig.org # top-most EditorConfig file root = true # Don't use tabs for indentation. [*] indent_style=space charset=utf-8 end_of_line=crlf trim_trailing_whitespace=false insert_final_newline=false indent_size=4 # Microsoft .NET properties csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion dotnet_style_require_accessibility_modifiers=for_non_interface_members:hint # ReSharper properties resharper_autodetect_indent_settings=true resharper_blank_lines_after_control_transfer_statements=1 resharper_blank_lines_around_block_case_section=1 resharper_blank_lines_around_single_line_local_method=1 resharper_blank_lines_before_block_statements=1 resharper_blank_lines_before_control_transfer_statements=1 resharper_blank_lines_before_multiline_statements=1 resharper_blank_lines_before_single_line_comment=1 resharper_braces_for_for=required resharper_braces_for_foreach=required resharper_braces_for_ifelse=required resharper_braces_for_while=required resharper_csharp_keep_blank_lines_in_code=1 resharper_csharp_keep_blank_lines_in_declarations=1 resharper_csharp_max_line_length=160 resharper_enforce_line_ending_style=true resharper_keep_existing_embedded_arrangement=false resharper_place_simple_embedded_statement_on_same_line=False resharper_use_indent_from_vs=false resharper_space_within_single_line_array_initializer_braces=true resharper_accessor_owner_body=accessors_with_block_body # ReSharper inspection severities resharper_convert_to_null_coalescing_compound_assignment_highlighting=hint resharper_enforce_foreach_statement_braces_highlighting=error resharper_enforce_for_statement_braces_highlighting=error resharper_enforce_if_statement_braces_highlighting=error resharper_enforce_while_statement_braces_highlighting=error resharper_identifier_typo_highlighting=none resharper_redundant_base_qualifier_highlighting=warning resharper_web_config_module_not_resolved_highlighting=warning resharper_web_config_type_not_resolved_highlighting=warning resharper_web_config_wrong_module_highlighting=warning # (Please don't specify an indent_size here; that has too many unintended consequences.) # Code files [*.{cs,csx,vb,vbx}] indent_size=4 insert_final_newline=true # Xml project files [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] indent_size=2 # Xml config files [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] indent_size=2 # JSON files [*.json] indent_size=2 # Dotnet code style settings: [*.{cs,vb}] # Sort using and Import directives with System.* appearing first dotnet_sort_system_directives_first=true # Avoid "this." and "Me." if not necessary dotnet_style_qualification_for_field=false:error dotnet_style_qualification_for_property=false:error dotnet_style_qualification_for_method=false:error dotnet_style_qualification_for_event=false:error # Use language keywords instead of framework type names for type references dotnet_style_predefined_type_for_locals_parameters_members=true:suggestion dotnet_style_predefined_type_for_member_access=true:suggestion # Suggest more modern language features when available dotnet_style_object_initializer=true:suggestion dotnet_style_collection_initializer=true:suggestion dotnet_style_coalesce_expression=true:suggestion dotnet_style_null_propagation=true:suggestion dotnet_style_explicit_tuple_names=true:suggestion dotnet_naming_rule.private_members_with_underscore.symbols=private_fields dotnet_naming_rule.private_members_with_underscore.style=prefix_underscore dotnet_naming_rule.private_members_with_underscore.severity=suggestion dotnet_naming_symbols.private_fields.applicable_kinds=field dotnet_naming_symbols.private_fields.applicable_accessibilities=private dotnet_naming_style.prefix_underscore.capitalization=camel_case dotnet_naming_style.prefix_underscore.required_prefix=_ # CSharp code style settings: [*.cs] # Prefer "var" everywhere csharp_style_var_for_built_in_types=true:error csharp_style_var_when_type_is_apparent=true:error csharp_style_var_elsewhere=true:error # Prefer method-like constructs to have a block body csharp_style_expression_bodied_methods=false:none csharp_style_expression_bodied_constructors=false:none csharp_style_expression_bodied_operators=false:none # Prefer property-like constructs to have an expression-body csharp_style_expression_bodied_properties=true:none csharp_style_expression_bodied_indexers=true:none csharp_style_expression_bodied_accessors=true:none # Suggest more modern language features when available csharp_style_pattern_matching_over_is_with_cast_check=true:suggestion csharp_style_pattern_matching_over_as_with_null_check=true:suggestion csharp_style_inlined_variable_declaration=true:suggestion csharp_style_throw_expression=true:suggestion csharp_style_conditional_delegate_call=true:suggestion # Newline settings csharp_new_line_before_open_brace=all csharp_new_line_before_else=true csharp_new_line_before_catch=true csharp_new_line_before_finally=true csharp_new_line_before_members_in_object_initializers=true csharp_new_line_before_members_in_anonymous_types=true csharp_new_line_between_query_expression_clauses=true csharp_preserve_single_line_statements=false csharp_preserve_single_line_blocks=true [{.eslintrc,.babelrc,.stylelintrc,jest.config,*.uproject,*.bowerrc,*.jsb3,*.jsb2,*.json}] indent_style=space indent_size=2 [*.{appxmanifest,asax,ascx,aspx,build,cs,cshtml,dtd,master,nuspec,razor,resw,resx,skin,vb,xaml,xamlx,xoml,xsd}] indent_style=space indent_size=4 tab_width=4 ================================================ FILE: .gitignore ================================================ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.suo *.user *.userosscache *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ # Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ # Visual Studio 2017 auto generated files Generated\ Files/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUNIT *.VisualState.xml TestResult.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c # Benchmark Results BenchmarkDotNet.Artifacts/ # .NET Core project.lock.json project.fragment.lock.json artifacts/ **/Properties/launchSettings.json # StyleCop StyleCopReport.xml # Files built by Visual Studio *_i.c *_p.c *_i.h *.ilk *.meta *.obj *.iobj *.pch *.pdb *.ipdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opendb *.opensdf *.sdf *.cachefile *.VC.db *.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx *.sap # Visual Studio Trace Files *.e2e # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # JustCode is a .NET coding add-in .JustCode # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # AxoCover is a Code Coverage Tool .axoCover/* !.axoCover/settings.json # Visual Studio code coverage results *.coverage *.coveragexml # NCrunch _NCrunch_* .*crunch*.local.xml nCrunchTemp_* # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # Note: Comment the next line if you want to checkin your web deploy settings, # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to # checkin your Azure Web App publish settings, but sensitive information contained # in these scripts will be unencrypted PublishScripts/ # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. !**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/[Pp]ackages/repositories.config # NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets # Microsoft Azure Build Output csx/ *.build.csdef # Microsoft Azure Emulator ecf/ rcf/ # Windows Store app package directories and files AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache !*.[Cc]ache/ # Others ClientBin/ ~$* *~ *.dbmdl *.dbproj.schemaview *.jfm *.pfx *.publishsettings orleans.codegen.cs # Including strong name files can present a security risk # (https://github.com/github/gitignore/pull/2483#issue-259490424) #*.snk # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm ServiceFabricBackup/ *.rptproj.bak # SQL Server files *.mdf *.ldf *.ndf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings *.rptproj.rsuser # Microsoft Fakes FakesAssemblies/ # GhostDoc plugin setting file *.GhostDoc.xml # Node.js Tools for Visual Studio .ntvs_analysis.dat node_modules/ # Visual Studio 6 build log *.plg # Visual Studio 6 workspace options file *.opt # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) *.vbw # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/ModelManifest.xml **/*.Server/GeneratedArtifacts **/*.Server/ModelManifest.xml _Pvt_Extensions # Paket dependency manager .paket/paket.exe paket-files/ # FAKE - F# Make .fake/ # JetBrains Rider .idea/ *.sln.iml # CodeRush .cr/ # Python Tools for Visual Studio (PTVS) __pycache__/ *.pyc # Cake - Uncomment if you are using it # tools/** # !tools/packages.config # Tabs Studio *.tss # Telerik's JustMock configuration file *.jmconfig # BizTalk build output *.btp.cs *.btm.cs *.odx.cs *.xsd.cs # OpenCover UI analysis results OpenCover/ # Azure Stream Analytics local run output ASALocalRun/ # MSBuild Binary and Structured Log *.binlog # NVidia Nsight GPU debugger configuration file *.nvuser # MFractors (Xamarin productivity tool) working folder .mfractor/ ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2019 Weik.io Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ Plugin Framework Logo # Plugin Framework for .NET Core [![NuGet Version](https://img.shields.io/nuget/v/Weikio.PluginFramework.svg?style=flat&label=Weikio.PluginFramework)](https://www.nuget.org/packages/Weikio.PluginFramework/) With Plugin Framework for .NET Core, everything is a plugin! Plugin Framework is a **plugin platform** for .NET Core applications, including **ASP.NET Core, Blazor, WPF, Windows Forms and Console apps**. It is light-weight and easy to integrate and supports multiple different plugin catalogs, including .NET assemblies, **Nuget packages** and **Roslyn scripts**. ### Main Features Here are some of the main features of Plugin Framework: * Everything is a plugin! Deliver plugins as Nuget-packages, .NET assemblies, Roslyn scripts and more. * Easy integration into a new or an existing .NET Core application. * Automatic dependency management. * Handles platform specific runtime DLLs and native DLLs when using Nuget-packages. * MIT-licensed, commercial support available. ## Quickstart: Plugin Framework & ASP.NET Core Plugin Framework is available from Nuget as a .NET Core 3.1 package. There's a separate package which makes it easier to work with plugins in an ASP.NET Core app: [![NuGet Version](https://img.shields.io/nuget/v/Weikio.PluginFramework.AspNetCore.svg?style=flat&label=Weikio.PluginFramework.AspNetCore)](https://www.nuget.org/packages/Weikio.PluginFramework.AspNetCore/) ``` Install-Package Weikio.PluginFramework.AspNetCore ``` Using Plugin Framework can be as easy as adding a single new line into ConfigureServices: ``` services.AddPluginFramework(@".\myplugins"); ``` The code finds all the plugins (types that implement the custom IOperator-interface) from the myplugins-folder. The plugins can be used in a controller using constructor injection: ``` public CalculatorController(IEnumerable operator) { _operators = operators; } ``` Alternatively, you can provide multiple plugin locations using catalogs: ``` var folderPluginCatalog = new FolderPluginCatalog(@".\myplugins", type => { type.Implements(); }); var anotherPluginCatalog = new FolderPluginCatalog(@".\morePlugins", type => { type.Implements(); }); services.AddPluginFramework() .AddPluginCatalog(folderPluginCatalog) .AddPluginCatalog(anotherPluginCatalog) .AddPluginType(); ``` ## Samples The following Plugin Framework samples are available from GitHub: #### [Plugin Framework & .NET Console Application](https://github.com/weikio/PluginFramework/tree/master/samples/ConsoleApp) #### [Plugin Framework & ASP.NET Core](https://github.com/weikio/PluginFramework/tree/master/samples/WebApp) #### [Plugin Framework & Blazor](https://github.com/weikio/PluginFramework/tree/master/samples/BlazorApp) #### [Plugin Framework & WPF App](https://github.com/weikio/PluginFramework/tree/master/samples/WpfApp) #### [Plugin Framework & WinForms App](https://github.com/weikio/PluginFramework/tree/master/samples/WinFormsApp) #### [Nuget & Plugin Framework & ASP.NET Core](https://github.com/weikio/PluginFramework/tree/master/samples/WebAppWithNuget) #### [Roslyn & Plugin Framework & ASP.NET Core](https://github.com/weikio/PluginFramework/tree/master/samples/WebAppWithRoslyn) #### [Delegates & Plugin Framework & ASP.NET Core](https://github.com/weikio/PluginFramework/tree/master/samples/WebAppWithDelegate) #### [Tagging & WinForms App](https://github.com/weikio/PluginFramework/tree/master/samples/WinFormsApp) #### [AppSettings.json & ASP.NET Core](https://github.com/weikio/PluginFramework/tree/master/samples/WebAppWithAppSettings) ## Background and introduction For more details related to Plugin Framework's background, please see the following [introduction article from InfoQ](https://www.infoq.com/articles/Plugin-Framework-DotNet/). ## Main concepts Using Plugin Framework concentrates around two concepts: **Plugins** and **Plugin Catalogs**. ### Plugin Plugins are software programs, which provide extensions to an application. Plugins are designed to work with a single application. This app is often called the **host application**. The host application is designed in such a way that it can locate and run plugins dynamically, runtime. **The application works without the plugins, the plugins can't work without the host application.** The host application defines the specifications for the plugins. In some applications a plugin can add new functionality into the UI. In other apps, plugins are used to distribute logs into multiple different systems. The host application defines what kind of extensions it supports. Plugin-based software architecture can help in the following scenarios: * Adding new features to application after the release * Splitting large systems into smaller parts * Updating always-on software system without restarting it Plugins are dynamic, and they are often only loaded when the application needs them. Plugins are not usually compiled as part of the system but distributed as separate packages (assemblies, Nuget packages). In the context of the Plugin Framework, **plugin is a single .NET Type**. What makes a plugin? As described previously, it depends on the host application. For some applications a plugin is a type which implements a specific interface. In some applications a plugin is a type which has a single public method called Run. Attributes are often used to indicate the plugins and that is also supported by Plugin Framework. From the Plugin Framework's point of view anything or everything can be a plugin. As mentioned, in Plugin Framework a single plugin is a .NET Type. Even though Plugin Framework's ASP.NET Core support makes it easy to instantiate and use plugins in services and controllers through dependency injection (IServiceProvider), Plugin Framework itself doesn't provide any built-in mechanisms for creating instances (objects) from the plugins (types). In some cases Activator.CreateInstance is all that is needed and in some cases it is best to hook Plugin Framework with the app's DI-system. The requirements are host application specific. In Plugin Framework, each Plugin is composed of the following information: * Type * Plugin name * Plugin version ### Plugin Catalogs Plugin Framework contains a concept called "Catalog". A single assembly can be a catalog. A .NET type can be a catalog. Folders with dlls are often used as catalogs and Plugin Framework also supports Nuget packages, Nuget feeds and Roslyn scripts as Plugin catalogs. Multiple catalogs are often combined into a single Composite catalog. Each catalog contains 0-n plugins. Plugin Framework provides the following officially supported catalogs: * Type * Assembly * Folder * Delegate (Action or a Func) ([Documentation](https://github.com/weikio/PluginFramework/wiki/Delegate-Plugin-Catalog)) * Roslyn script ([Nuget: Weikio.PluginFramework.Catalogs.Roslyn](https://www.nuget.org/packages/Weikio.PluginFramework.Catalogs.Roslyn/), [Documentation](https://github.com/weikio/PluginFramework/wiki/Roslyn-Plugin-Catalog)) * Nuget package ([Nuget: Weikio.PluginFramework.Catalogs.Nuget](https://www.nuget.org/packages/Weikio.PluginFramework.Catalogs.Nuget/)) * Nuget feed ([Nuget: Weikio.PluginFramework.Catalogs.Nuget](https://www.nuget.org/packages/Weikio.PluginFramework.Catalogs.Nuget/)) ## Source code Source code for Plugin Framework is available from [GitHub](https://github.com/weikio/PluginFramework). ## Support & Build by Plugin Framework is build by [Adafy](https://adafy.com). Adafy also provides commercial support for the framework. ![Adafy Logo](docs/Adafy_logo_256.png) Adafy is a Finnish software development house, focusing on Microsoft technologies. ## Constributors Thanks to the following contributors who have helped with the project: #### [@panoukos41](https://github.com/panoukos41) ## License Plugin Framework is available as an open source, MIT-licensed project. ================================================ FILE: THIRD-PARTY-NOTICES.txt ================================================ Plugin Framework uses third-party libraries or other resources that may be distributed under licenses different than the Plugin Framework software. In the event that we accidentally failed to list a required notice, please bring it to our attention. Post an issue or email us: info@weik.io License notice for Minver ------------------------------------ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. License notice for ASP.NET Core ------------------------------------ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: global.json ================================================ { "sdk": { "version": "6.0.420" } } ================================================ FILE: samples/BlazorApp/App.razor ================================================ 

Sorry, there's nothing at this address.

================================================ FILE: samples/BlazorApp/BlazorApp.csproj ================================================ netcoreapp3.1 Never ================================================ FILE: samples/BlazorApp/Data/WeatherForecast.cs ================================================ using System; namespace BlazorApp.Data { public class WeatherForecast { public DateTime Date { get; set; } public int TemperatureC { get; set; } public int TemperatureF => 32 + (int) (TemperatureC / 0.5556); public string Summary { get; set; } } } ================================================ FILE: samples/BlazorApp/Data/WeatherForecastService.cs ================================================ using System; using System.Linq; using System.Threading.Tasks; namespace BlazorApp.Data { public class WeatherForecastService { private static readonly string[] Summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; public Task GetForecastAsync(DateTime startDate) { var rng = new Random(); return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = startDate.AddDays(index), TemperatureC = rng.Next(-20, 55), Summary = Summaries[rng.Next(Summaries.Length)] }).ToArray()); } } } ================================================ FILE: samples/BlazorApp/Pages/Counter.razor ================================================ @page "/counter" @implements Weikio.PluginFramework.Samples.Shared.IWidget

Current count: @currentCount

@code { private int currentCount = 0; private void IncrementCount() { currentCount++; } public string Title { get { return "Counter Widget"; } } } ================================================ FILE: samples/BlazorApp/Pages/Error.razor ================================================ @page "/error"

Error.

An error occurred while processing your request.

Development Mode

Swapping to Development environment will display more detailed information about the error that occurred.

The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app.

================================================ FILE: samples/BlazorApp/Pages/FetchData.razor ================================================ @page "/fetchdata" @implements Weikio.PluginFramework.Samples.Shared.IWidget @using BlazorApp.Data @inject WeatherForecastService ForecastService @if (forecasts == null) {

Loading...

} else { @foreach (var forecast in forecasts) { }
Date Temp. (C) Temp. (F) Summary
@forecast.Date.ToShortDateString() @forecast.TemperatureC @forecast.TemperatureF @forecast.Summary
} @code { private WeatherForecast[] forecasts; protected override async Task OnInitializedAsync() { forecasts = await ForecastService.GetForecastAsync(DateTime.Now); } public string Title { get; } = "Weather forecasts"; } ================================================ FILE: samples/BlazorApp/Pages/Index.razor ================================================ @page "/" @using Weikio.PluginFramework.Samples.Shared

Widget dashboard

@foreach (var widget in Widgets) {

@widget.Title


@RenderWidget(widget)
}
@code{ [Inject] public IEnumerable Widgets { get; set; } private RenderFragment RenderWidget(IWidget widget) { return new RenderFragment(builder => { builder.OpenComponent(0, widget.GetType()); builder.CloseComponent(); }); } } ================================================ FILE: samples/BlazorApp/Pages/_Host.cshtml ================================================ @page "/" @namespace BlazorApp.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = null; } BlazorApp
An error has occurred. This application may no longer respond until reloaded. An unhandled exception has occurred. See browser dev tools for details. Reload 🗙
================================================ FILE: samples/BlazorApp/Program.cs ================================================ using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace BlazorApp { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); } } ================================================ FILE: samples/BlazorApp/Shared/MainLayout.razor ================================================ @inherits LayoutComponentBase
@Body
================================================ FILE: samples/BlazorApp/Shared/NavMenu.razor ================================================ 
@code { private bool collapseNavMenu = true; private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; private void ToggleNavMenu() { collapseNavMenu = !collapseNavMenu; } } ================================================ FILE: samples/BlazorApp/Shared/SurveyPrompt.razor ================================================ @implements Weikio.PluginFramework.Samples.Shared.IWidget @code { public string Title { get; } = "Surveys"; } ================================================ FILE: samples/BlazorApp/Startup.cs ================================================ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using BlazorApp.Data; using Microsoft.CodeAnalysis; using Weikio.PluginFramework.Samples.Shared; namespace BlazorApp { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.AddServerSideBlazor(); services.AddSingleton(); services.AddPluginFramework(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); } } } ================================================ FILE: samples/BlazorApp/_Imports.razor ================================================ @using System.Net.Http @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Components.Authorization @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web @using Microsoft.JSInterop @using BlazorApp @using BlazorApp.Shared ================================================ FILE: samples/BlazorApp/appsettings.Development.json ================================================ { "DetailedErrors": true, "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } } } ================================================ FILE: samples/BlazorApp/appsettings.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*" } ================================================ FILE: samples/BlazorApp/wwwroot/css/open-iconic/FONT-LICENSE ================================================ SIL OPEN FONT LICENSE Version 1.1 Copyright (c) 2014 Waybury PREAMBLE The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. DEFINITIONS "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. "Reserved Font Name" refers to any names specified as such after the copyright statement(s). "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. PERMISSION & CONDITIONS Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. TERMINATION This license becomes null and void if any of the above conditions are not met. DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. ================================================ FILE: samples/BlazorApp/wwwroot/css/open-iconic/ICON-LICENSE ================================================ The MIT License (MIT) Copyright (c) 2014 Waybury Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: samples/BlazorApp/wwwroot/css/open-iconic/README.md ================================================ [Open Iconic v1.1.1](http://useiconic.com/open) =========== ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) ## What's in Open Iconic? * 223 icons designed to be legible down to 8 pixels * Super-light SVG files - 61.8 for the entire set * SVG sprite—the modern replacement for icon fonts * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. ## Getting Started #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. ### General Usage #### Using Open Iconic's SVGs We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). ``` icon name ``` #### Using Open Iconic's SVG Sprite Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* ``` ``` Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. ``` .icon { width: 16px; height: 16px; } ``` Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. ``` .icon-account-login { fill: #f00; } ``` To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). #### Using Open Iconic's Icon Font... ##### …with Bootstrap You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` ``` ``` ``` ``` ##### …with Foundation You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` ``` ``` ``` ``` ##### …on its own You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` ``` ``` ``` ``` ## License ### Icons All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). ### Fonts All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). ================================================ FILE: samples/BlazorApp/wwwroot/css/site.css ================================================ @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); html, body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; } a, .btn-link { color: #0366d6; } .btn-primary { color: #fff; background-color: #1b6ec2; border-color: #1861ac; } app { position: relative; display: flex; flex-direction: column; } .top-row { height: 3.5rem; display: flex; align-items: center; } .main { flex: 1; } .main .top-row { background-color: #f7f7f7; border-bottom: 1px solid #d6d5d5; justify-content: flex-end; } .main .top-row > a, .main .top-row .btn-link { white-space: nowrap; margin-left: 1.5rem; } .main .top-row a:first-child { overflow: hidden; text-overflow: ellipsis; } .sidebar { background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); } .sidebar .top-row { background-color: rgba(0,0,0,0.4); } .sidebar .navbar-brand { font-size: 1.1rem; } .sidebar .oi { width: 2rem; font-size: 1.1rem; vertical-align: text-top; top: -2px; } .sidebar .nav-item { font-size: 0.9rem; padding-bottom: 0.5rem; } .sidebar .nav-item:first-of-type { padding-top: 1rem; } .sidebar .nav-item:last-of-type { padding-bottom: 1rem; } .sidebar .nav-item a { color: #d7d7d7; border-radius: 4px; height: 3rem; display: flex; align-items: center; line-height: 3rem; } .sidebar .nav-item a.active { background-color: rgba(255,255,255,0.25); color: white; } .sidebar .nav-item a:hover { background-color: rgba(255,255,255,0.1); color: white; } .content { padding-top: 1.1rem; } .navbar-toggler { background-color: rgba(255, 255, 255, 0.1); } .valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; } .invalid { outline: 1px solid red; } .validation-message { color: red; } #blazor-error-ui { background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; } #blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; } @media (max-width: 767.98px) { .main .top-row:not(.auth) { display: none; } .main .top-row.auth { justify-content: space-between; } .main .top-row a, .main .top-row .btn-link { margin-left: 0; } } @media (min-width: 768px) { app { flex-direction: row; } .sidebar { width: 250px; height: 100vh; position: sticky; top: 0; } .main .top-row { position: sticky; top: 0; } .main > div { padding-left: 2rem !important; padding-right: 1.5rem !important; } .navbar-toggler { display: none; } .sidebar .collapse { /* Never collapse the sidebar for wide screens */ display: block; } } .widget { border: 1px solid #ccc; margin: 10px; padding: 10px; } ================================================ FILE: samples/ConsoleApp/ConsoleApp.csproj ================================================ Exe netcoreapp3.1 ================================================ FILE: samples/ConsoleApp/FirstPlugin.cs ================================================ using System; using Weikio.PluginFramework.Samples.Shared; namespace ConsoleApp { public class FirstPlugin : IPlugin { public void Run() { Console.WriteLine("First plugin"); } } } ================================================ FILE: samples/ConsoleApp/MyPlugin.cs ================================================ using System; using Weikio.PluginFramework.Samples.Shared; namespace ConsoleApp { public class MyPlugin : IMyPlugin { public void Run() { Console.WriteLine("My plugin which implements IMyPlugin"); } } } ================================================ FILE: samples/ConsoleApp/Program.cs ================================================ using System; using System.Threading.Tasks; using Weikio.PluginFramework.Samples.Shared; using Weikio.PluginFramework.Abstractions; using Weikio.PluginFramework.Catalogs; namespace ConsoleApp { class Program { static async Task Main(string[] args) { await AssemblyCatalogSample(); await TypeCatalogSample(); await CompositeCatalogSample(); } private static async Task AssemblyCatalogSample() { Console.WriteLine("Assembly catalog sample"); // 1. Create a new plugin catalog from the current assembly var assemblyPluginCatalog = new AssemblyPluginCatalog(typeof(Program).Assembly, type => typeof(IPlugin).IsAssignableFrom(type)); // 2. Initialize the catalog await assemblyPluginCatalog.Initialize(); // 3. Get the plugins from the catalog var assemplyPlugins = assemblyPluginCatalog.GetPlugins(); foreach (var plugin in assemplyPlugins) { var inst = (IPlugin) Activator.CreateInstance(plugin); inst.Run(); } } private static async Task TypeCatalogSample() { Console.WriteLine("Type catalog sample"); var typePluginCatalog = new TypePluginCatalog(typeof(FirstPlugin)); await typePluginCatalog.Initialize(); var typePlugin = typePluginCatalog.Get(); var pluginInstance = (IPlugin) Activator.CreateInstance(typePlugin); pluginInstance.Run(); } private static async Task CompositeCatalogSample() { Console.WriteLine("Composite catalog sample"); // 1. Create a new plugin catalog from the current assembly var assemblyPluginCatalog = new AssemblyPluginCatalog(typeof(Program).Assembly, type => typeof(IPlugin).IsAssignableFrom(type)); // 2. Also create a new plugin catalog from a type var typePluginCatalog = new TypePluginCatalog(typeof(MyPlugin)); // 3. Then combine the catalogs into a composite catalog var compositeCatalog = new CompositePluginCatalog(assemblyPluginCatalog, typePluginCatalog); // 4. Initialize the composite catalog await compositeCatalog.Initialize(); // 5. Get the plugins from the catalog var assemplyPlugins = compositeCatalog.GetPlugins(); foreach (var plugin in assemplyPlugins) { if (plugin.Type.Name == "MyPlugin") { var inst = (IMyPlugin) Activator.CreateInstance(plugin); inst.Run(); } else { var inst = (IPlugin) Activator.CreateInstance(plugin); inst.Run(); } } } } } ================================================ FILE: samples/ConsoleApp/SecondPlugin.cs ================================================ using System; using Weikio.PluginFramework.Samples.Shared; namespace ConsoleApp { public class SecondPlugin : IPlugin { public void Run() { Console.WriteLine("Second plugin"); } } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.Shared/IMyPlugin.cs ================================================ namespace Weikio.PluginFramework.Samples.Shared { public interface IMyPlugin { void Run(); } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.Shared/IOperator.cs ================================================ namespace Weikio.PluginFramework.Samples.Shared { public interface IOperator { int Calculate(int x, int y); } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.Shared/IPlugin.cs ================================================ using System; namespace Weikio.PluginFramework.Samples.Shared { public interface IPlugin { void Run(); } public interface IOutPlugin { string Get(); } public interface IWidget { string Title { get; } } public interface IDialog { void Show(); } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.Shared/RemainderOperator.cs ================================================ namespace Weikio.PluginFramework.Samples.Shared { public class RemainderOperator : IOperator { public int Calculate(int x, int y) { return x % y; } } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.Shared/Weikio.PluginFramework.Samples.Shared.csproj ================================================ netcoreapp3.1 true true Plugin Framework shared sample Plugin Framework shared sample Plugin Framework shared sample Weikio.PluginFramework.Samples.Shared Weikio.PluginFramework.Samples.Shared Weikio.PluginFramework.Samples.Shared plugins;addons;plugin framework;samples ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.SharedPlugins/MinusOperator.cs ================================================ using Weikio.PluginFramework.Samples.Shared; namespace Weikio.PluginFramework.Samples.SharedPlugins { public class MinusOperator : IOperator { public int Calculate(int x, int y) { return x - y; } } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.SharedPlugins/MultiplyOperator.cs ================================================ using System.ComponentModel; using Weikio.PluginFramework.Samples.Shared; namespace Weikio.PluginFramework.Samples.SharedPlugins { [DisplayName("The multiplier plugin")] public class MultiplyOperator : IOperator { public int Calculate(int x, int y) { return x * y; } } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.SharedPlugins/SecondSharedPlugin.cs ================================================ using System; using Weikio.PluginFramework.Samples.Shared; namespace Weikio.PluginFramework.Samples.SharedPlugins { public class SecondSharedPlugin : IOutPlugin { public string Get() { return "Second shared plugin"; } } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.SharedPlugins/SumOperator.cs ================================================ using Weikio.PluginFramework.Samples.Shared; namespace Weikio.PluginFramework.Samples.SharedPlugins { public class SumOperator : IOperator { public int Calculate(int x, int y) { return x + y; } } } ================================================ FILE: samples/Shared/Weikio.PluginFramework.Samples.SharedPlugins/Weikio.PluginFramework.Samples.SharedPlugins.csproj ================================================ netcoreapp3.1 true true Plugin Framework shared sample plugins Plugin Framework shared sample plugins Plugin Framework shared sample plugins Weikio.PluginFramework.Samples.SharedPlugins Weikio.PluginFramework.Samples.SharedPlugins Weikio.PluginFramework.Samples.SharedPlugins plugins;addons;plugin framework;samples ================================================ FILE: samples/WebApp/Controllers/CalculatorController.cs ================================================ using System.Collections.Generic; using System.Linq; using System.Text.Json; using Microsoft.AspNetCore.Mvc; using Weikio.PluginFramework.Samples.Shared; using Weikio.PluginFramework.Abstractions; namespace WebApp.Controllers { [ApiController] [Route("[controller]")] public class CalculatorController : ControllerBase { private readonly IEnumerable _operators; private readonly IEnumerable _plugins; private readonly IOperator _defaultOperator; public CalculatorController(IEnumerable operators, IEnumerable plugins, IOperator defaultOperator) { _operators = operators; _plugins = plugins; _defaultOperator = defaultOperator; } [HttpGet] public string Get() { return JsonSerializer.Serialize(new { allPlugins = _plugins.Select(p => p.ToString()), operators = _operators.Select(o => o.GetType().Name), defaultOperator = _defaultOperator.GetType().Name }, new JsonSerializerOptions { WriteIndented = true}); } } } ================================================ FILE: samples/WebApp/Program.cs ================================================ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; namespace WebApp { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); } } ================================================ FILE: samples/WebApp/Startup.cs ================================================ using System.Collections.Generic; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Weikio.PluginFramework.Samples.Shared; using Weikio.PluginFramework.Abstractions; using Weikio.PluginFramework.AspNetCore; using Weikio.PluginFramework.Catalogs; using Weikio.PluginFramework.Samples.SharedPlugins; namespace WebApp { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var folderPluginCatalog = new FolderPluginCatalog(@"..\Shared\Weikio.PluginFramework.Samples.SharedPlugins\bin\debug\netcoreapp3.1", type => { type.Implements(); }); services.AddPluginFramework() .AddPluginCatalog(folderPluginCatalog) .AddPluginType(configureDefault: option => { option.DefaultType = (provider, types) => typeof(SumOperator); }); // Alternatively // services.AddPluginFramework(@"..\Shared\Weikio.PluginFramework.Samples.SharedPlugins\bin\debug\netcoreapp3.1"); // Default plugin type returned can be optionally configured with DefaultType function //services.AddPluginFramework() // .AddPluginCatalog(folderPluginCatalog) // .AddPluginType(configureDefault: option => // { // option.DefaultType = (serviceProvider, implementingTypes) => typeof(MultiplyOperator); // }); // Alternatively default plugin type can be also configured with Configure and provided with the same DefaultType function //services.Configure(nameof(IOperator), option => // option.DefaultType = (serviceProvider, implementingTypes) => typeof(MultiplyOperator)); services.AddControllers(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } } ================================================ FILE: samples/WebApp/WebApp.csproj ================================================ netcoreapp3.1 Never ================================================ FILE: samples/WebApp/appsettings.Development.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } } } ================================================ FILE: samples/WebApp/appsettings.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*" } ================================================ FILE: samples/WebAppPluginsLibrary/CustomPlugin.cs ================================================ using System; namespace WebAppPluginsLibrary { public class CustomPlugin { } } ================================================ FILE: samples/WebAppPluginsLibrary/WebAppPluginsLibrary.csproj ================================================ netstandard2.0 ================================================ FILE: samples/WebAppWithAppSettings/Controllers/CalculatorController.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Weikio.PluginFramework.Abstractions; using Weikio.PluginFramework.AspNetCore; using Weikio.PluginFramework.Samples.Shared; namespace WebAppWithAppSettings.Controllers { [ApiController] [Route("[controller]")] public class CalculatorController : ControllerBase { private readonly IEnumerable _plugins; private readonly IServiceProvider _serviceProvider; private readonly PluginProvider _pluginProvider; public CalculatorController(IEnumerable plugins, IServiceProvider serviceProvider, PluginProvider pluginProvider) { _plugins = plugins; _serviceProvider = serviceProvider; _pluginProvider = pluginProvider; } [HttpGet] public string Get() { var result = new StringBuilder(); result.AppendLine("All:"); foreach (var plugin in _plugins) { result.AppendLine($"{plugin.Name}: {plugin.Version}, Tags: {string.Join(", ", plugin.Tags)}"); } var mathPlugins = _pluginProvider.GetByTag("MathOperator"); var value1 = 10; var value2 = 20; result.AppendLine($"Math operations with values {value1} and {value2}"); foreach (var mathPlugin in mathPlugins) { var mathPluginInstance = _serviceProvider.Create(mathPlugin); var mathResult = mathPluginInstance.Calculate(value1, value2); result.AppendLine($"{mathPlugin.Name}: {mathResult}"); } return result.ToString(); } } } ================================================ FILE: samples/WebAppWithAppSettings/Program.cs ================================================ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; namespace WebAppWithAppSettings { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); } } ================================================ FILE: samples/WebAppWithAppSettings/Startup.cs ================================================ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Weikio.PluginFramework.Samples.Shared; using Weikio.PluginFramework.TypeFinding; namespace WebAppWithAppSettings { public class Startup { public void ConfigureServices(IServiceCollection services) { TypeFinderOptions.Defaults.TypeFinderCriterias.Add(TypeFinderCriteriaBuilder.Create().Implements().Tag("MathOperator")); TypeFinderOptions.Defaults.TypeFinderCriterias.Add(TypeFinderCriteriaBuilder.Create().Tag("All")); services.AddPluginFramework(); services.AddControllers(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } } ================================================ FILE: samples/WebAppWithAppSettings/WebAppWithAppSettings.csproj ================================================ netcoreapp3.1 Never ================================================ FILE: samples/WebAppWithAppSettings/appsettings.Development.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } } } ================================================ FILE: samples/WebAppWithAppSettings/appsettings.json ================================================ { "PluginFramework": { "Catalogs": [ { "Type": "Folder", "Path": "..\\Shared\\Weikio.PluginFramework.Samples.SharedPlugins\\bin\\debug\\netcoreapp3.1" }, { "Type": "Assembly", "Path": ".\\bin\\Debug\\netcoreapp3.1\\WebAppPluginsLibrary.dll" } ] } } ================================================ FILE: samples/WebAppWithDelegate/Controllers/DelegateController.cs ================================================ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Weikio.PluginFramework.Abstractions; namespace WebAppWithDelegate.Controllers { [ApiController] [Route("[controller]")] public class DelegateController : ControllerBase { private readonly IPluginCatalog _pluginCatalog; private readonly IServiceProvider _sp; public DelegateController(IPluginCatalog pluginCatalog, IServiceProvider serviceProvider) { _pluginCatalog = pluginCatalog; _sp = serviceProvider; } [HttpGet] public string Get() { var actionPlugin = _pluginCatalog.Get("MyActionPlugin", Version.Parse("1.0.0.0")); var funcPlugin = _pluginCatalog.Get("MyFuncPlugin", Version.Parse("1.0.0.0")); var funcExternalServicePlugin = _pluginCatalog.Get("MyExternalServicePlugin", Version.Parse("1.0.0.0")); dynamic action = _sp.Create(actionPlugin); dynamic func = _sp.Create(funcPlugin); dynamic external = _sp.Create(funcExternalServicePlugin); var s = new List() { "Hello from controller" }; action.Run(s); var result = func.Run(s); // Conversion rules are used to convert the func's string parameter into a property and to convert the ExternalService into a constructor parameter. external.S = result; result = external.Run(); return result; } } } ================================================ FILE: samples/WebAppWithDelegate/ExternalService.cs ================================================ namespace WebAppWithDelegate { public class ExternalService { public string GetWords() { return "Hello from external service"; } } } ================================================ FILE: samples/WebAppWithDelegate/Program.cs ================================================ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; namespace WebAppWithDelegate { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); } } ================================================ FILE: samples/WebAppWithDelegate/Startup.cs ================================================ using System; using System.Collections.Generic; using System.Reflection; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Weikio.PluginFramework.Catalogs; using Weikio.PluginFramework.Catalogs.Delegates; namespace WebAppWithDelegate { public class Startup { // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // 1. Create a Plugin Catalog from an Action var actionDelegate = new Action>(s => { s.Add("Hello from action"); }); var actionCatalog = new DelegatePluginCatalog(actionDelegate, "MyActionPlugin"); // 2. Create an another catalog from a Func var funcDelegate = new Func, string>(s => { s.Add("Hello from func"); return string.Join(Environment.NewLine, s); }); var funcCatalog = new DelegatePluginCatalog(funcDelegate, "MyFuncPlugin"); // 3. Create a third catalog to show how constructor injection and parameters can be used var funcWithExternalService = new Func((s, service) => { var words = service.GetWords(); s = s + Environment.NewLine + words; return s; }); var funcWithExternalServiceCatalog = new DelegatePluginCatalog(funcWithExternalService, pluginName: "MyExternalServicePlugin", // 4. Use conversion rules to indicate that ExternalService should be a constructor parameter and the string should be a property conversionRules: new List() { // Rules can target parameter types new DelegateConversionRule(info => info.ParameterType == typeof(ExternalService), nfo => new ParameterConversion() { ToConstructor = true }), // Conversions based on the parameter names also work new DelegateConversionRule(info => info.Name == "s", nfo => new ParameterConversion() { ToPublicProperty = true }), }); services.AddPluginFramework() .AddPluginCatalog(new CompositePluginCatalog(actionCatalog, funcCatalog, funcWithExternalServiceCatalog)); services.AddSingleton(); services.AddControllers(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } } ================================================ FILE: samples/WebAppWithDelegate/WebAppWithDelegate.csproj ================================================ netcoreapp3.1 Never ================================================ FILE: samples/WebAppWithDelegate/appsettings.Development.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } } } ================================================ FILE: samples/WebAppWithDelegate/appsettings.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*" } ================================================ FILE: samples/WebAppWithNuget/Controllers/CalculatorController.cs ================================================ using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Weikio.PluginFramework.Abstractions; using Weikio.PluginFramework.Samples.Shared; namespace WebAppWithNuget.Controllers { [ApiController] [Route("[controller]")] public class CalculatorController : ControllerBase { private readonly IEnumerable _operators; private readonly IEnumerable _plugins; public CalculatorController(IEnumerable operators, IEnumerable plugins, IOperator myOperator) { _operators = operators; _plugins = plugins; } [HttpGet] public string Get() { var pluginsList = string.Join(", ", _plugins); return pluginsList; } } } ================================================ FILE: samples/WebAppWithNuget/NugetLogger.cs ================================================ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NuGet.Common; using LogLevel = NuGet.Common.LogLevel; namespace WebAppWithNuget { public class NugetLogger : LoggerBase { private readonly ILogger _logger; public NugetLogger(IServiceCollection serviceCollection) { var provider = serviceCollection.BuildServiceProvider(); _logger = (ILogger) provider.GetService(typeof(ILogger)); } public override void Log(ILogMessage message) { switch (message.Level) { case LogLevel.Debug: _logger.LogDebug(message.ToString()); break; case LogLevel.Verbose: _logger.LogTrace(message.ToString()); break; case LogLevel.Information: _logger.LogInformation(message.ToString()); break; case LogLevel.Minimal: _logger.LogTrace(message.ToString()); break; case LogLevel.Warning: _logger.LogWarning(message.ToString()); break; case LogLevel.Error: _logger.LogError(message.ToString()); break; } } public override Task LogAsync(ILogMessage message) { Log(message); return Task.CompletedTask; } } } ================================================ FILE: samples/WebAppWithNuget/Program.cs ================================================ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace WebAppWithNuget { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); } } ================================================ FILE: samples/WebAppWithNuget/Startup.cs ================================================ using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Weikio.PluginFramework.Catalogs; using Weikio.PluginFramework.Catalogs.NuGet; using Weikio.PluginFramework.Samples.Shared; namespace WebAppWithNuget { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { NugetPluginCatalogOptions.Defaults.LoggerFactory = () => new NugetLogger(services); var options = new NugetPluginCatalogOptions { ForcePackageCaching = true, CustomPackagesFolder = Path.Combine(Path.GetTempPath(), "NugetPackagePluginCatalog", "Sample") }; var nugetCatalog = new NugetPackagePluginCatalog("Weikio.PluginFramework.Samples.SharedPlugins", includePrerelease: true, configureFinder: finder => { finder.Implements(); }, options: options); services.AddPluginFramework() .AddPluginCatalog(nugetCatalog) .AddPluginType(); services.AddControllers(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } } ================================================ FILE: samples/WebAppWithNuget/WebAppWithNuget.csproj ================================================ netcoreapp3.1 ================================================ FILE: samples/WebAppWithNuget/appsettings.Development.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } } } ================================================ FILE: samples/WebAppWithNuget/appsettings.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*" } ================================================ FILE: samples/WebAppWithRoslyn/Controllers/RoslynController.cs ================================================ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Weikio.PluginFramework.Abstractions; namespace WebAppWithRoslyn.Controllers { [ApiController] [Route("[controller]")] public class RoslynController : ControllerBase { private readonly IPluginCatalog _pluginCatalog; private readonly IServiceProvider _sp; public RoslynController(IPluginCatalog pluginCatalog, IServiceProvider sp) { _pluginCatalog = pluginCatalog; _sp = sp; } [HttpGet] public async Task Get() { var scriptPlugin = _pluginCatalog.GetPlugins().First(); dynamic scriptInstance = Activator.CreateInstance(scriptPlugin); var scriptResult = await scriptInstance.Run(); var typePlugin = _pluginCatalog.Get("MyPlugin", Version.Parse("1.5.0.0")); dynamic typeInstance = typePlugin.Create(_sp); var typeResult = typeInstance.RunThings(); var result = new StringBuilder(); result.AppendLine(scriptResult); result.AppendLine(typeResult); return result.ToString(); } } } ================================================ FILE: samples/WebAppWithRoslyn/ExternalService.cs ================================================ namespace WebAppWithRoslyn { public class ExternalService { public string DoWork() { return "External service did some work"; } } } ================================================ FILE: samples/WebAppWithRoslyn/Program.cs ================================================ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; namespace WebAppWithRoslyn { public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); } } ================================================ FILE: samples/WebAppWithRoslyn/Startup.cs ================================================ using System; using System.Collections.Generic; using System.Reflection; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Weikio.PluginFramework.Catalogs; using Weikio.PluginFramework.Catalogs.Roslyn; namespace WebAppWithRoslyn { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // First we create a Roslyn Plugin Catalog which uses the scripting version of C#/Roslyn var script = "var x = \"Hello from Roslyn Plugin\"; return x;"; var roslynScriptCatalog = new RoslynPluginCatalog(script); // We also create an another Roslyn Plugin Catalog to show how to create a plugin from a class. // This catalog also uses dependency injection, external references and additional namespaces. var code = @"public class MyClass { private ExternalService _service; public MyClass(ExternalService service) { _service = service; } public string RunThings() { var result = JsonConvert.SerializeObject(15); result += _service.DoWork(); return result; } }"; var options = new RoslynPluginCatalogOptions() { PluginName = "MyPlugin", PluginVersion = new Version("1.5.0.0"), AdditionalReferences = new List() { typeof(Newtonsoft.Json.JsonConvert).Assembly, typeof(ExternalService).Assembly }, AdditionalNamespaces = new List() { "Newtonsoft.Json", "WebAppWithRoslyn" } }; var roslynCodeCatalog = new RoslynPluginCatalog(code, options); services.AddPluginFramework() .AddPluginCatalog(new CompositePluginCatalog(roslynScriptCatalog, roslynCodeCatalog)); services.AddSingleton(); services.AddControllers(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } } ================================================ FILE: samples/WebAppWithRoslyn/WebAppWithRoslyn.csproj ================================================ netcoreapp3.1 Never ================================================ FILE: samples/WebAppWithRoslyn/appsettings.Development.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } } } ================================================ FILE: samples/WebAppWithRoslyn/appsettings.json ================================================ { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*" } ================================================ FILE: samples/WinFormsApp/DivideOperator.cs ================================================ using Weikio.PluginFramework.Samples.Shared; namespace WinFormsApp { public class DivideOperator : IOperator { public int Calculate(int x, int y) { return x / y; } } } ================================================ FILE: samples/WinFormsApp/Form1.Designer.cs ================================================ namespace WinFormsApp { partial class Form1 { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.listBox1 = new System.Windows.Forms.ListBox(); this.button1 = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.dialogPluginsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // listBox1 // this.listBox1.FormattingEnabled = true; this.listBox1.Location = new System.Drawing.Point(12, 123); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(438, 277); this.listBox1.TabIndex = 0; // // button1 // this.button1.Location = new System.Drawing.Point(12, 414); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(102, 24); this.button1.TabIndex = 1; this.button1.Text = "Run Plugin"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(120, 414); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(330, 24); this.textBox1.TabIndex = 2; // // label1 // this.label1.Location = new System.Drawing.Point(12, 101); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(98, 19); this.label1.TabIndex = 3; this.label1.Text = "Plugins:"; // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.dialogPluginsToolStripMenuItem }); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(462, 24); this.menuStrip1.TabIndex = 4; this.menuStrip1.Text = "menuStrip1"; // // dialogPluginsToolStripMenuItem // this.dialogPluginsToolStripMenuItem.Name = "dialogPluginsToolStripMenuItem"; this.dialogPluginsToolStripMenuItem.Size = new System.Drawing.Size(104, 20); this.dialogPluginsToolStripMenuItem.Text = "Dialog Plugins..."; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(462, 450); this.Controls.Add(this.label1); this.Controls.Add(this.textBox1); this.Controls.Add(this.button1); this.Controls.Add(this.listBox1); this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } private System.Windows.Forms.ToolStripMenuItem dialogPluginsToolStripMenuItem; private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.TextBox textBox1; #endregion } } ================================================ FILE: samples/WinFormsApp/Form1.cs ================================================ using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Forms; using Weikio.PluginFramework.Abstractions; using Weikio.PluginFramework.Catalogs; using Weikio.PluginFramework.Catalogs.Delegates; using Weikio.PluginFramework.Samples.Shared; using Weikio.PluginFramework.TypeFinding; namespace WinFormsApp { public partial class Form1 : Form { private CompositePluginCatalog _allPlugins = new CompositePluginCatalog(); public Form1() { InitializeComponent(); } private async void Form1_Load(object sender, EventArgs e) { // Demonstrates how tags can be used with Plugin Framework. // Single _allPlugins catalog is created from multiple different catalogs. All the plugins are tagged. await CreateCatalogs(); // 1. Adds calculation operators using tag 'operator' AddCalculationOperators(); // 2. Adds dialogs using 'dialog' tag AddDialogs(); // 3. Adds buttons using 'button' tag AddButtons(); } private async Task CreateCatalogs() { // 1. Uses folder catalog to add calculation operations inside the app. Mimics the WPF-sample. var folderPluginCatalog = new FolderPluginCatalog(@"..\..\..\..\Shared\Weikio.PluginFramework.Samples.SharedPlugins\bin\debug\netcoreapp3.1", type => { type.Implements().Tag("operator"); }); _allPlugins.AddCatalog(folderPluginCatalog); var assemblyPluginCatalog = new AssemblyPluginCatalog(typeof(Form1).Assembly, builder => { builder.Implements() .Tag("operator"); }); _allPlugins.AddCatalog(assemblyPluginCatalog); // 2. Another folder catalog is used to add other forms inside the app. For each form a button is added into the toolstrip // Note: WinFormsPluginsLibrary must be manually built as it isn't referenced by this sample app var folderCatalog = new FolderPluginCatalog(@"..\..\..\..\WinFormsPluginsLibrary\bin\debug\netcoreapp3.1", type => { type.Implements() .Tag("dialog"); }); _allPlugins.AddCatalog(folderCatalog); // 3. Lastly, DelegateCatalog is used for creating an exit-button var exitAction = new Action(() => { var result = MessageBox.Show("This is also a plugin. Do you want to exit this sample app?", "Exit App?", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } Application.Exit(); }); var exitCatalog = new DelegatePluginCatalog(exitAction, options: new DelegatePluginCatalogOptions(){Tags = new List { "buttons" }} , pluginName: "Exit" ); _allPlugins.AddCatalog(exitCatalog); // Finally the plugin catalog is initialized await _allPlugins.Initialize(); } private void AddCalculationOperators() { var allPlugins = _allPlugins.GetByTag("operator"); foreach (var plugin in allPlugins) { listBox1.Items.Add(plugin); } } private void AddDialogs() { var dialogPlugins = _allPlugins.GetByTag("dialog"); foreach (var dialogPlugin in dialogPlugins) { var menuItem = new ToolStripButton(dialogPlugin.Name, null, (o, args) => { var instance = (IDialog) Activator.CreateInstance(dialogPlugin); instance.Show(); }); dialogPluginsToolStripMenuItem.DropDownItems.Add(menuItem); } } private void AddButtons() { var buttonPlugins = _allPlugins.GetByTag("buttons"); foreach (var buttonPlugin in buttonPlugins) { menuStrip1.Items.Add(new ToolStripButton(buttonPlugin.Name, null, (sender, args) => { dynamic instance = Activator.CreateInstance(buttonPlugin); instance.Run(); })); } } private void button1_Click(object sender, EventArgs e) { var selectedPlugin = listBox1.SelectedItem as Plugin; if (selectedPlugin == null) { return; } var instance = (IOperator) Activator.CreateInstance(selectedPlugin); var result = instance.Calculate(20, 10); textBox1.Text = result.ToString(); } } } ================================================ FILE: samples/WinFormsApp/Form1.resx ================================================  text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 17, 17 ================================================ FILE: samples/WinFormsApp/Program.cs ================================================ using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using Weikio.PluginFramework.Context; namespace WinFormsApp { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } ================================================ FILE: samples/WinFormsApp/WinFormsApp.csproj ================================================  WinExe netcoreapp3.1 true ================================================ FILE: samples/WinFormsPluginsLibrary/LabelPlugin.Designer.cs ================================================ using System.ComponentModel; using System.Drawing; namespace WinFormsPluginsLibrary { partial class LabelPlugin { /// /// Required designer variable. /// private IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(105, 12); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(110, 50); this.button1.TabIndex = 0; this.button1.Text = "Update Label"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // label1 // this.label1.Location = new System.Drawing.Point(90, 88); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(125, 36); this.label1.TabIndex = 1; // // LabelPlugin // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(313, 184); this.Controls.Add(this.label1); this.Controls.Add(this.button1); this.Name = "LabelPlugin"; this.Text = "LabelPlugin"; this.ResumeLayout(false); } private System.Windows.Forms.Label label1; private System.Windows.Forms.Button button1; #endregion } } ================================================ FILE: samples/WinFormsPluginsLibrary/LabelPlugin.cs ================================================ using System; using System.ComponentModel; using System.Windows.Forms; using Weikio.PluginFramework.Samples.Shared; namespace WinFormsPluginsLibrary { public partial class LabelPlugin : Form, IDialog { public LabelPlugin() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { label1.Text = "Another simple example"; } } } ================================================ FILE: samples/WinFormsPluginsLibrary/LabelPlugin.resx ================================================  text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ================================================ FILE: samples/WinFormsPluginsLibrary/TestPlugin.Designer.cs ================================================ using System.ComponentModel; namespace WinFormsPluginsLibrary { partial class TestPlugin { /// /// Required designer variable. /// private IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(118, 86); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(202, 42); this.button1.TabIndex = 0; this.button1.Text = "Say Hello"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // TestPlugin // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(433, 233); this.Controls.Add(this.button1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "TestPlugin"; this.Text = "TestPlugin"; this.ResumeLayout(false); } private System.Windows.Forms.Button button1; #endregion } } ================================================ FILE: samples/WinFormsPluginsLibrary/TestPlugin.cs ================================================ using System; using System.ComponentModel; using System.Windows.Forms; using Weikio.PluginFramework.Samples.Shared; namespace WinFormsPluginsLibrary { [DisplayName("Hello World")] public partial class TestPlugin : Form, IDialog { public TestPlugin() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Hello Plugin Framework"); } } } ================================================ FILE: samples/WinFormsPluginsLibrary/TestPlugin.resx ================================================  text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ================================================ FILE: samples/WinFormsPluginsLibrary/WinFormsPluginsLibrary.csproj ================================================  netcoreapp3.1 true Form Form ================================================ FILE: samples/WpfApp/App.xaml ================================================  ================================================ FILE: samples/WpfApp/App.xaml.cs ================================================ using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Windows; namespace WpfApp { /// /// Interaction logic for App.xaml /// public partial class App : Application { } } ================================================ FILE: samples/WpfApp/AssemblyInfo.cs ================================================ using System.Windows; [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located //(used if a resource is not found in the page, // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located //(used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] ================================================ FILE: samples/WpfApp/DivideOperator.cs ================================================ using Weikio.PluginFramework.Samples.Shared; namespace WpfApp { public class DivideOperator : IOperator { public int Calculate(int x, int y) { return x / y; } } } ================================================ FILE: samples/WpfApp/MainWindow.xaml ================================================