├── .gitattributes ├── .github └── dependabot.yml ├── .gitignore ├── Akka.DI.AutoFac.sln ├── LICENSE ├── RELEASE_NOTES.md ├── Readme.md ├── build-system ├── README.md ├── azure-pipeline.template.yaml ├── linux-pr-validation.yaml ├── nightly-builds.yaml ├── windows-pr-validation.yaml └── windows-release.yaml ├── build.cmd ├── build.fsx ├── build.ps1 ├── build.sh ├── docs ├── api │ └── index.md ├── articles │ ├── index.md │ └── toc.yml ├── docfx.json ├── images │ └── icon.png ├── index.md ├── toc.yml └── web.config ├── serve-docs.cmd ├── serve-docs.ps1 └── src ├── Akka.DI.AutoFac.Tests ├── Akka.DI.AutoFac.Tests.csproj └── AutoFacDependencyResolverSpecs.cs ├── Akka.DI.AutoFac.sln ├── Akka.DI.AutoFac.sln.DotSettings ├── Akka.DI.AutoFac ├── ActorSystemExtensions.cs ├── Akka.DI.AutoFac.csproj └── AutoFacDependencyResolver.cs └── common.props /.gitattributes: -------------------------------------------------------------------------------- 1 | # Explicitly declare files that should always be converted to LF regardless of platform 2 | *.dotsettings text eol=lf 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | ignore: 9 | - dependency-name: Akka.TestKit.Xunit2 10 | versions: 11 | - 1.4.16 12 | - 1.4.17 13 | - dependency-name: Akka.DI.TestKit 14 | versions: 15 | - 1.4.16 16 | - 1.4.17 17 | - dependency-name: Akka.DI.Core 18 | versions: 19 | - 1.4.16 20 | - 1.4.17 21 | - dependency-name: Microsoft.NET.Test.Sdk 22 | versions: 23 | - 16.8.3 24 | - 16.9.1 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Custom 2 | tools/ 3 | build/ 4 | .nuget/ 5 | .dotnet/ 6 | .idea/ 7 | .[Dd][Ss]_[Ss]tore 8 | 9 | ## Ignore Visual Studio temporary files, build results, and 10 | ## files generated by popular Visual Studio add-ons. 11 | ## 12 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 13 | 14 | # User-specific files 15 | *.suo 16 | *.user 17 | *.userosscache 18 | *.sln.docstates 19 | 20 | # User-specific files (MonoDevelop/Xamarin Studio) 21 | *.userprefs 22 | 23 | # Build results 24 | [Dd]ebug/ 25 | [Dd]ebugPublic/ 26 | [Rr]elease/ 27 | [Rr]eleases/ 28 | x64/ 29 | x86/ 30 | bld/ 31 | [Bb]in/ 32 | [Oo]bj/ 33 | [Ll]og/ 34 | 35 | #FAKE 36 | .fake 37 | tools/ 38 | 39 | #DocFx output 40 | _site/ 41 | 42 | # Visual Studio 2015 cache/options directory 43 | .vs/ 44 | # Uncomment if you have tasks that create the project's static files in wwwroot 45 | #wwwroot/ 46 | 47 | # MSTest test Results 48 | [Tt]est[Rr]esult*/ 49 | [Bb]uild[Ll]og.* 50 | 51 | # NUNIT 52 | *.VisualState.xml 53 | TestResult.xml 54 | 55 | # Build Results of an ATL Project 56 | [Dd]ebugPS/ 57 | [Rr]eleasePS/ 58 | dlldata.c 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | **/Properties/launchSettings.json 65 | 66 | *_i.c 67 | *_p.c 68 | *_i.h 69 | *.ilk 70 | *.meta 71 | *.obj 72 | *.pch 73 | *.pdb 74 | *.pgc 75 | *.pgd 76 | *.rsp 77 | *.sbr 78 | *.tlb 79 | *.tli 80 | *.tlh 81 | *.tmp 82 | *.tmp_proj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # Visual Studio code coverage results 132 | *.coverage 133 | *.coveragexml 134 | 135 | # NCrunch 136 | _NCrunch_* 137 | .*crunch*.local.xml 138 | nCrunchTemp_* 139 | 140 | # MightyMoose 141 | *.mm.* 142 | AutoTest.Net/ 143 | 144 | # Web workbench (sass) 145 | .sass-cache/ 146 | 147 | # Installshield output folder 148 | [Ee]xpress/ 149 | 150 | # DocProject is a documentation generator add-in 151 | DocProject/buildhelp/ 152 | DocProject/Help/*.HxT 153 | DocProject/Help/*.HxC 154 | DocProject/Help/*.hhc 155 | DocProject/Help/*.hhk 156 | DocProject/Help/*.hhp 157 | DocProject/Help/Html2 158 | DocProject/Help/html 159 | 160 | # Click-Once directory 161 | publish/ 162 | 163 | # Publish Web Output 164 | *.[Pp]ublish.xml 165 | *.azurePubxml 166 | # TODO: Comment the next line if you want to checkin your web deploy settings 167 | # but database connection strings (with potential passwords) will be unencrypted 168 | *.pubxml 169 | *.publishproj 170 | 171 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 172 | # checkin your Azure Web App publish settings, but sensitive information contained 173 | # in these scripts will be unencrypted 174 | PublishScripts/ 175 | 176 | # NuGet Packages 177 | *.nupkg 178 | # The packages folder can be ignored because of Package Restore 179 | **/packages/* 180 | # except build/, which is used as an MSBuild target. 181 | !**/packages/build/ 182 | # Uncomment if necessary however generally it will be regenerated when needed 183 | #!**/packages/repositories.config 184 | # NuGet v3's project.json files produces more ignorable files 185 | *.nuget.props 186 | *.nuget.targets 187 | 188 | # Microsoft Azure Build Output 189 | csx/ 190 | *.build.csdef 191 | 192 | # Microsoft Azure Emulator 193 | ecf/ 194 | rcf/ 195 | 196 | # Windows Store app package directories and files 197 | AppPackages/ 198 | BundleArtifacts/ 199 | Package.StoreAssociation.xml 200 | _pkginfo.txt 201 | 202 | # Visual Studio cache files 203 | # files ending in .cache can be ignored 204 | *.[Cc]ache 205 | # but keep track of directories ending in .cache 206 | !*.[Cc]ache/ 207 | 208 | # Others 209 | ClientBin/ 210 | ~$* 211 | *~ 212 | *.dbmdl 213 | *.dbproj.schemaview 214 | *.jfm 215 | *.pfx 216 | *.publishsettings 217 | orleans.codegen.cs 218 | 219 | # Since there are multiple workflows, uncomment next line to ignore bower_components 220 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 221 | #bower_components/ 222 | 223 | # RIA/Silverlight projects 224 | Generated_Code/ 225 | 226 | # Backup & report files from converting an old project file 227 | # to a newer Visual Studio version. Backup files are not needed, 228 | # because we have git ;-) 229 | _UpgradeReport_Files/ 230 | Backup*/ 231 | UpgradeLog*.XML 232 | UpgradeLog*.htm 233 | 234 | # SQL Server files 235 | *.mdf 236 | *.ldf 237 | *.ndf 238 | 239 | # Business Intelligence projects 240 | *.rdl.data 241 | *.bim.layout 242 | *.bim_*.settings 243 | 244 | # Microsoft Fakes 245 | FakesAssemblies/ 246 | 247 | # GhostDoc plugin setting file 248 | *.GhostDoc.xml 249 | 250 | # Node.js Tools for Visual Studio 251 | .ntvs_analysis.dat 252 | node_modules/ 253 | 254 | # Typescript v1 declaration files 255 | typings/ 256 | 257 | # Visual Studio 6 build log 258 | *.plg 259 | 260 | # Visual Studio 6 workspace options file 261 | *.opt 262 | 263 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 264 | *.vbw 265 | 266 | # Visual Studio LightSwitch build output 267 | **/*.HTMLClient/GeneratedArtifacts 268 | **/*.DesktopClient/GeneratedArtifacts 269 | **/*.DesktopClient/ModelManifest.xml 270 | **/*.Server/GeneratedArtifacts 271 | **/*.Server/ModelManifest.xml 272 | _Pvt_Extensions 273 | 274 | # Paket dependency manager 275 | .paket/paket.exe 276 | paket-files/ 277 | 278 | # FAKE - F# Make 279 | .fake/ 280 | 281 | # JetBrains Rider 282 | .idea/ 283 | *.sln.iml 284 | 285 | # CodeRush 286 | .cr/ 287 | 288 | # Python Tools for Visual Studio (PTVS) 289 | __pycache__/ 290 | *.pyc 291 | 292 | # Cake - Uncomment if you are using it 293 | # tools/** 294 | # !tools/packages.config 295 | 296 | # Telerik's JustMock configuration file 297 | *.jmconfig 298 | 299 | # BizTalk build output 300 | *.btp.cs 301 | *.btm.cs 302 | *.odx.cs 303 | *.xsd.cs 304 | -------------------------------------------------------------------------------- /Akka.DI.AutoFac.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.14 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.DI.AutoFac", "src\Akka.DI.AutoFac\Akka.DI.AutoFac.csproj", "{E945AABA-2779-41E8-9B43-8898FFD64F22}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.DI.AutoFac.Tests", "src\Akka.DI.AutoFac.Tests\Akka.DI.AutoFac.Tests.csproj", "{0F9B9BC6-9F86-40E8-BA9B-D27BF3AC7970}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{79D71264-186B-4F62-8930-35DD9ECCAF3B}" 11 | ProjectSection(SolutionItems) = preProject 12 | build.cmd = build.cmd 13 | build.fsx = build.fsx 14 | build.ps1 = build.ps1 15 | build.sh = build.sh 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {E945AABA-2779-41E8-9B43-8898FFD64F22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {E945AABA-2779-41E8-9B43-8898FFD64F22}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {E945AABA-2779-41E8-9B43-8898FFD64F22}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {E945AABA-2779-41E8-9B43-8898FFD64F22}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {0F9B9BC6-9F86-40E8-BA9B-D27BF3AC7970}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {0F9B9BC6-9F86-40E8-BA9B-D27BF3AC7970}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {0F9B9BC6-9F86-40E8-BA9B-D27BF3AC7970}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {0F9B9BC6-9F86-40E8-BA9B-D27BF3AC7970}.Release|Any CPU.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(ExtensibilityGlobals) = postSolution 37 | SolutionGuid = {B99E6BB8-642A-4A68-86DF-69567CBA700A} 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2015-2017 {user} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /RELEASE_NOTES.md: -------------------------------------------------------------------------------- 1 | #### 1.4.27 November 10 2021 #### 2 | Akka.NET v1.4.27 support and Autofac 6.3.0. 3 | 4 | **Please note that Akka.DI.Autofac and all other Akka.DI. plugins are deprecated** going forward. Please use [Akka.DependencyInjection instead](https://getakka.net/articles/actors/dependency-injection.html) going forward. 5 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Akka.DI.Autofac [Deprecated] 2 | 3 | ## Please note that Akka.DI.Autofac and all other Akka.DI plugins are deprecated going forward. Please use [Akka.DependencyInjection instead](https://getakka.net/articles/actors/dependency-injection.html) going forward. 4 | 5 | **Actor Producer Extension** backed by the [Autofac](https://github.com/autofac/Autofac) Dependency Injection Container for the [Akka.NET](https://github.com/akkadotnet/akka.net) framework. 6 | 7 | ## What is it? 8 | 9 | **Akka.DI.Autofac** is an **ActorSystem extension** for the Akka.NET framework that provides an alternative to the basic capabilities of [Props](https://getakka.net/api/Akka.Actor.Props.html) when you have Actors with multiple dependencies. 10 | 11 | If Autofac is your IoC container of choice and your actors have dependencies that make using the factory method provided by Props prohibitive and code maintenance is an important concern then this is the extension for you. 12 | 13 | ## How to you use it? 14 | 15 | The best way to understand how to use it is by example. If you are already considering this extension then we will assume that you know how how to use the [Autofac](https://github.com/autofac/Autofac) container. This example is demonstrating a system using [ConsistentHashing](http://getakka.net/docs/working-with-actors/Routers#consistenthashing) routing along with this extension. 16 | 17 | Start by creating your builder, registering your actors and dependencies, and build your container. 18 | 19 | ```csharp 20 | // Setup Autofac 21 | ContainerBuilder builder = new ContainerBuilder(); 22 | builder.RegisterType().As(); 23 | builder.RegisterType(); 24 | IContainer container = builder.Build(); 25 | ``` 26 | 27 | Next you have to create your ```ActorSystem``` and inject that system reference along with the container reference into a new instance of the ```AutoFacDependencyResolver```. 28 | 29 | ```csharp 30 | // Create the ActorSystem 31 | using (var system = ActorSystem.Create("MySystem")) 32 | { 33 | // Create the dependency resolver 34 | IDependencyResolver resolver = new AutoFacDependencyResolver(container, system); 35 | 36 | // we'll fill in the rest in the following steps 37 | } 38 | ``` 39 | 40 | To register the actors with the system use method ```Akka.Actor.Props Create()``` of the ```IDependencyResolver``` interface implemented by the ```AutoFacDependencyResolver```. 41 | 42 | ```csharp 43 | // Register the actors with the system 44 | system.ActorOf(resolver.Create(), "Worker1"); 45 | system.ActorOf(resolver.Create(), "Worker2"); 46 | ``` 47 | 48 | Finally create your router, message and send the message to the router. 49 | 50 | ```csharp 51 | // Create the router 52 | IActorRef router = system.ActorOf(Props.Empty.WithRouter(new ConsistentHashingGroup(config))); 53 | 54 | // Create the message to send 55 | TypedActorMessage message = new TypedActorMessage 56 | { 57 | Id = 1, 58 | Name = Guid.NewGuid().ToString() 59 | }; 60 | 61 | // Send the message to the router 62 | router.Tell(message); 63 | ``` 64 | 65 | The resulting code should look similar to the the following: 66 | 67 | ```csharp 68 | // Setup Autofac 69 | ContainerBuilder builder = new ContainerBuilder(); 70 | builder.RegisterType().As(); 71 | builder.RegisterType(); 72 | IContainer container = builder.Build(); 73 | 74 | // Create the ActorSystem 75 | using (var system = ActorSystem.Create("MySystem")) 76 | { 77 | // Create the dependency resolver 78 | IDependencyResolver resolver = new AutoFacDependencyResolver(container, system); 79 | 80 | // Register the actors with the system 81 | system.ActorOf(resolver.Create(), "Worker1"); 82 | system.ActorOf(resolver.Create(), "Worker2"); 83 | 84 | // Create the router 85 | IActorRef router = system.ActorOf(Props.Empty.WithRouter(new ConsistentHashingGroup(config))); 86 | 87 | // Create the message to send 88 | TypedActorMessage message = new TypedActorMessage 89 | { 90 | Id = 1, 91 | Name = Guid.NewGuid().ToString() 92 | }; 93 | 94 | // Send the message to the router 95 | router.Tell(message); 96 | } 97 | ``` 98 | -------------------------------------------------------------------------------- /build-system/README.md: -------------------------------------------------------------------------------- 1 | # Azure Pipelines Build Files 2 | These `.yaml` files are used by Windows Azure DevOps Pipelines to help execute the following types of builds: 3 | 4 | - Pull request validation on Linux (Mono / .NET Core) 5 | - Pull request validation on Windows (.NET Framework / .NET Core) 6 | - NuGet releases with automatic release notes posted to a Github Release repository. 7 | 8 | **NOTE**: you will need to change some of the pipeline variables inside the `windows-release.yaml` for your specific project and you will also want to create variable groups with your signing and NuGet push information. -------------------------------------------------------------------------------- /build-system/azure-pipeline.template.yaml: -------------------------------------------------------------------------------- 1 | parameters: 2 | name: '' 3 | vmImage: '' 4 | scriptFileName: '' 5 | scriptArgs: 'all' 6 | timeoutInMinutes: 120 7 | outputDirectory: 'bin/nuget' 8 | 9 | jobs: 10 | - job: ${{ parameters.name }} 11 | timeoutInMinutes: ${{ parameters.timeoutInMinutes }} 12 | pool: 13 | vmImage: ${{ parameters.vmImage }} 14 | steps: 15 | - checkout: self # self represents the repo where the initial Pipelines YAML file was found 16 | clean: false # whether to fetch clean each time 17 | submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules 18 | persistCredentials: true 19 | # Linux or macOS 20 | - task: Bash@3 21 | displayName: Linux / OSX Build 22 | inputs: 23 | filePath: ${{ parameters.scriptFileName }} 24 | arguments: ${{ parameters.scriptArgs }} 25 | continueOnError: true 26 | condition: in( variables['Agent.OS'], 'Linux', 'Darwin' ) 27 | # Windows 28 | - task: BatchScript@1 29 | displayName: Windows Build 30 | inputs: 31 | filename: ${{ parameters.scriptFileName }} 32 | arguments: ${{ parameters.scriptArgs }} 33 | continueOnError: true 34 | condition: eq( variables['Agent.OS'], 'Windows_NT' ) 35 | - task: PublishTestResults@2 36 | inputs: 37 | testRunner: VSTest 38 | testResultsFiles: '**/*.trx' #TestResults folder usually 39 | testRunTitle: ${{ parameters.name }} 40 | mergeTestResults: true 41 | - task: CopyFiles@2 42 | displayName: 'Copy Build Output' 43 | inputs: 44 | sourceFolder: ${{ parameters.outputDirectory }} 45 | contents: '**\*' 46 | targetFolder: $(Build.ArtifactStagingDirectory) 47 | continueOnError: boolean # 'true' if future steps should run even if this step fails; defaults to 'false' 48 | - task: PublishBuildArtifacts@1 49 | inputs: 50 | pathtoPublish: '$(Build.ArtifactStagingDirectory)' 51 | artifactName: ${{ parameters.name }} 52 | - script: 'echo 1>&2' 53 | failOnStderr: true 54 | displayName: 'If above is partially succeeded, then fail' 55 | condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues') -------------------------------------------------------------------------------- /build-system/linux-pr-validation.yaml: -------------------------------------------------------------------------------- 1 | # Pull request validation for Linux against the `dev` and `master` branches 2 | # See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for reference 3 | trigger: 4 | branches: 5 | include: 6 | - dev 7 | - master 8 | 9 | name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) 10 | 11 | pr: 12 | autoCancel: true # indicates whether additional pushes to a PR should cancel in-progress runs for the same PR. Defaults to true 13 | branches: 14 | include: [ dev, master ] # branch names which will trigger a build 15 | 16 | jobs: 17 | - template: azure-pipeline.template.yaml 18 | parameters: 19 | name: Ubuntu 20 | vmImage: 'ubuntu-16.04' 21 | scriptFileName: ./build.sh 22 | scriptArgs: all -------------------------------------------------------------------------------- /build-system/nightly-builds.yaml: -------------------------------------------------------------------------------- 1 | # Release task for PbLib projects 2 | # See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for reference 3 | 4 | pool: 5 | vmImage: vs2017-win2016 6 | demands: Cmd 7 | 8 | trigger: none 9 | pr: none 10 | 11 | schedules: 12 | - cron: "0 0 * * *" 13 | displayName: Daily midnight build 14 | branches: 15 | include: 16 | - dev 17 | 18 | variables: 19 | - group: nugetKeys #create this group with SECRET variables `nugetKey` 20 | 21 | steps: 22 | - task: BatchScript@1 23 | displayName: 'FAKE Build' 24 | inputs: 25 | filename: build.cmd 26 | arguments: 'Nuget nugetprerelease=dev nugetpublishurl=$(nightlyUrl) nugetkey=$(nightlyKey)' -------------------------------------------------------------------------------- /build-system/windows-pr-validation.yaml: -------------------------------------------------------------------------------- 1 | # Pull request validation for Windows against the `dev` and `master` branches 2 | # See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for reference 3 | trigger: 4 | branches: 5 | include: 6 | - dev 7 | - master 8 | 9 | pr: 10 | autoCancel: true # indicates whether additional pushes to a PR should cancel in-progress runs for the same PR. Defaults to true 11 | branches: 12 | include: [ dev, master ] # branch names which will trigger a build 13 | 14 | name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) 15 | 16 | jobs: 17 | - template: azure-pipeline.template.yaml 18 | parameters: 19 | name: Windows 20 | vmImage: 'vs2017-win2016' 21 | scriptFileName: build.cmd 22 | scriptArgs: all -------------------------------------------------------------------------------- /build-system/windows-release.yaml: -------------------------------------------------------------------------------- 1 | # Release task for PbLib projects 2 | # See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for reference 3 | 4 | pool: 5 | vmImage: vs2017-win2016 6 | demands: Cmd 7 | 8 | trigger: 9 | branches: 10 | include: 11 | - refs/tags/* 12 | pr: none 13 | 14 | variables: 15 | - group: nugetKeys #create this group with SECRET variables `nugetKey` 16 | - name: githubConnectionName 17 | value: AkkaDotNet_Releases #replace this 18 | - name: projectName 19 | value: Akka.DI.Autofac #replace this 20 | - name: githubRepositoryName 21 | value: akkadotnet/Akka.DI.Autofac #replace this 22 | 23 | steps: 24 | - task: BatchScript@1 25 | displayName: 'FAKE Build' 26 | inputs: 27 | filename: build.cmd 28 | arguments: 'All nugetpublishurl=https://www.nuget.org/api/v2/package nugetkey=$(nugetKey)' 29 | 30 | - task: GitHubRelease@0 31 | displayName: 'GitHub release (create)' 32 | inputs: 33 | gitHubConnection: $(githubConnectionName) 34 | repositoryName: $(githubRepositoryName) 35 | title: '$(projectName) v$(Build.SourceBranchName)' 36 | releaseNotesFile: 'RELEASE_NOTES.md' 37 | assets: | 38 | bin\nuget\*.nupkg -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | PowerShell.exe -file "build.ps1" %* -------------------------------------------------------------------------------- /build.fsx: -------------------------------------------------------------------------------- 1 | #I @"tools/FAKE/tools" 2 | #r "FakeLib.dll" 3 | 4 | open System 5 | open System.IO 6 | open System.Text 7 | 8 | open Fake 9 | open Fake.DotNetCli 10 | open Fake.DocFxHelper 11 | 12 | // Information about the project for Nuget and Assembly info files 13 | let product = "Akka.DI.Autofac" 14 | let configuration = "Release" 15 | 16 | // Read release notes and version 17 | let solutionFile = FindFirstMatchingFile "*.sln" __SOURCE_DIRECTORY__ // dynamically look up the solution 18 | let buildNumber = environVarOrDefault "BUILD_NUMBER" "0" 19 | let hasTeamCity = (not (buildNumber = "0")) // check if we have the TeamCity environment variable for build # set 20 | let preReleaseVersionSuffix = "beta" + (if (not (buildNumber = "0")) then (buildNumber) else DateTime.UtcNow.Ticks.ToString()) 21 | 22 | let releaseNotes = 23 | File.ReadLines (__SOURCE_DIRECTORY__ @@ "RELEASE_NOTES.md") 24 | |> ReleaseNotesHelper.parseReleaseNotes 25 | 26 | let versionFromReleaseNotes = 27 | match releaseNotes.SemVer.PreRelease with 28 | | Some r -> r.Origin 29 | | None -> "" 30 | 31 | let versionSuffix = 32 | match (getBuildParam "nugetprerelease") with 33 | | "dev" -> preReleaseVersionSuffix 34 | | "" -> versionFromReleaseNotes 35 | | str -> str 36 | 37 | // Directories 38 | let toolsDir = __SOURCE_DIRECTORY__ @@ "tools" 39 | let output = __SOURCE_DIRECTORY__ @@ "bin" 40 | let outputTests = __SOURCE_DIRECTORY__ @@ "TestResults" 41 | let outputPerfTests = __SOURCE_DIRECTORY__ @@ "PerfResults" 42 | let outputNuGet = output @@ "nuget" 43 | 44 | Target "Clean" (fun _ -> 45 | ActivateFinalTarget "KillCreatedProcesses" 46 | 47 | CleanDir output 48 | CleanDir outputTests 49 | CleanDir outputPerfTests 50 | CleanDir outputNuGet 51 | CleanDir "docs/_site" 52 | ) 53 | 54 | Target "AssemblyInfo" (fun _ -> 55 | XmlPokeInnerText "./src/common.props" "//Project/PropertyGroup/VersionPrefix" releaseNotes.AssemblyVersion 56 | XmlPokeInnerText "./src/common.props" "//Project/PropertyGroup/PackageReleaseNotes" (releaseNotes.Notes |> String.concat "\n") 57 | ) 58 | 59 | Target "Build" (fun _ -> 60 | DotNetCli.Build 61 | (fun p -> 62 | { p with 63 | Project = solutionFile 64 | Configuration = configuration }) // "Rebuild" 65 | ) 66 | 67 | 68 | //-------------------------------------------------------------------------------- 69 | // Tests targets 70 | //-------------------------------------------------------------------------------- 71 | module internal ResultHandling = 72 | let (|OK|Failure|) = function 73 | | 0 -> OK 74 | | x -> Failure x 75 | 76 | let buildErrorMessage = function 77 | | OK -> None 78 | | Failure errorCode -> 79 | Some (sprintf "xUnit2 reported an error (Error Code %d)" errorCode) 80 | 81 | let failBuildWithMessage = function 82 | | DontFailBuild -> traceError 83 | | _ -> (fun m -> raise(FailedTestsException m)) 84 | 85 | let failBuildIfXUnitReportedError errorLevel = 86 | buildErrorMessage 87 | >> Option.iter (failBuildWithMessage errorLevel) 88 | 89 | Target "RunTests" (fun _ -> 90 | let projects = 91 | match (isWindows) with 92 | | true -> !! "./src/**/*.Tests.csproj" 93 | | _ -> !! "./src/**/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here 94 | 95 | let runSingleProject project = 96 | let arguments = 97 | match (hasTeamCity) with 98 | | true -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --results-directory %s -- -parallel none -teamcity" (outputTests)) 99 | | false -> (sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --results-directory %s -- -parallel none" (outputTests)) 100 | 101 | let result = ExecProcess(fun info -> 102 | info.FileName <- "dotnet" 103 | info.WorkingDirectory <- (Directory.GetParent project).FullName 104 | info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0) 105 | 106 | ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result 107 | 108 | projects |> Seq.iter (log) 109 | projects |> Seq.iter (runSingleProject) 110 | ) 111 | 112 | //-------------------------------------------------------------------------------- 113 | // Nuget targets 114 | //-------------------------------------------------------------------------------- 115 | 116 | let overrideVersionSuffix (project:string) = 117 | match project with 118 | | _ -> versionSuffix // add additional matches to publish different versions for different projects in solution 119 | Target "CreateNuget" (fun _ -> 120 | let projects = !! "src/**/*.csproj" 121 | -- "src/**/*Tests.csproj" // Don't publish unit tests 122 | -- "src/**/*Tests*.csproj" 123 | 124 | let runSingleProject project = 125 | DotNetCli.Pack 126 | (fun p -> 127 | { p with 128 | Project = project 129 | Configuration = configuration 130 | AdditionalArgs = ["--include-symbols --no-build"] 131 | VersionSuffix = overrideVersionSuffix project 132 | OutputPath = outputNuGet }) 133 | 134 | projects |> Seq.iter (runSingleProject) 135 | ) 136 | 137 | Target "PublishNuget" (fun _ -> 138 | let projects = !! "./bin/nuget/*.nupkg" -- "./bin/nuget/*.symbols.nupkg" 139 | let apiKey = getBuildParamOrDefault "nugetkey" "" 140 | let source = getBuildParamOrDefault "nugetpublishurl" "" 141 | let symbolSource = getBuildParamOrDefault "symbolspublishurl" "" 142 | let shouldPublishSymbolsPackages = not (symbolSource = "") 143 | 144 | if (not (source = "") && not (apiKey = "") && shouldPublishSymbolsPackages) then 145 | let runSingleProject project = 146 | DotNetCli.RunCommand 147 | (fun p -> 148 | { p with 149 | TimeOut = TimeSpan.FromMinutes 10. }) 150 | (sprintf "nuget push %s --api-key %s --source %s --symbol-source %s" project apiKey source symbolSource) 151 | 152 | projects |> Seq.iter (runSingleProject) 153 | else if (not (source = "") && not (apiKey = "") && not shouldPublishSymbolsPackages) then 154 | let runSingleProject project = 155 | DotNetCli.RunCommand 156 | (fun p -> 157 | { p with 158 | TimeOut = TimeSpan.FromMinutes 10. }) 159 | (sprintf "nuget push %s --api-key %s --source %s" project apiKey source) 160 | 161 | projects |> Seq.iter (runSingleProject) 162 | ) 163 | 164 | //-------------------------------------------------------------------------------- 165 | // Documentation 166 | //-------------------------------------------------------------------------------- 167 | Target "DocFx" (fun _ -> 168 | DotNetCli.Restore (fun p -> { p with Project = solutionFile }) 169 | DotNetCli.Build (fun p -> { p with Project = solutionFile; Configuration = configuration }) 170 | 171 | let docsPath = "./docs" 172 | 173 | DocFx (fun p -> 174 | { p with 175 | Timeout = TimeSpan.FromMinutes 30.0; 176 | WorkingDirectory = docsPath; 177 | DocFxJson = docsPath @@ "docfx.json" }) 178 | ) 179 | 180 | //-------------------------------------------------------------------------------- 181 | // Cleanup 182 | //-------------------------------------------------------------------------------- 183 | 184 | FinalTarget "KillCreatedProcesses" (fun _ -> 185 | log "Shutting down dotnet build-server" 186 | let result = ExecProcess(fun info -> 187 | info.FileName <- "dotnet" 188 | info.WorkingDirectory <- __SOURCE_DIRECTORY__ 189 | info.Arguments <- "build-server shutdown") (System.TimeSpan.FromMinutes 2.0) 190 | if result <> 0 then failwithf "dotnet build-server shutdown failed" 191 | ) 192 | 193 | //-------------------------------------------------------------------------------- 194 | // Help 195 | //-------------------------------------------------------------------------------- 196 | 197 | Target "Help" <| fun _ -> 198 | List.iter printfn [ 199 | "usage:" 200 | "./build.ps1 [target]" 201 | "" 202 | " Targets for building:" 203 | " * Build Builds" 204 | " * Nuget Create and optionally publish nugets packages" 205 | " * SignPackages Signs all NuGet packages, provided that the following arguments are passed into the script: SignClientSecret={secret} and SignClientUser={username}" 206 | " * RunTests Runs tests" 207 | " * All Builds, run tests, creates and optionally publish nuget packages" 208 | " * DocFx Creates a DocFx-based website for this solution" 209 | "" 210 | " Other Targets" 211 | " * Help Display this help" 212 | ""] 213 | 214 | //-------------------------------------------------------------------------------- 215 | // Target dependencies 216 | //-------------------------------------------------------------------------------- 217 | 218 | Target "BuildRelease" DoNothing 219 | Target "All" DoNothing 220 | Target "Nuget" DoNothing 221 | 222 | // build dependencies 223 | "Clean" ==> "AssemblyInfo" ==> "Build" ==> "BuildRelease" 224 | 225 | // tests dependencies 226 | "Build" ==> "RunTests" 227 | 228 | // nuget dependencies 229 | "Clean" ==> "Build" ==> "CreateNuget" 230 | "CreateNuget" ==> "PublishNuget" ==> "Nuget" 231 | 232 | // docs 233 | "Clean" ==> "BuildRelease" ==> "Docfx" 234 | 235 | // all 236 | "BuildRelease" ==> "All" 237 | "RunTests" ==> "All" 238 | "Nuget" ==> "All" 239 | 240 | RunTargetOrDefault "Help" -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | This is a Powershell script to bootstrap a Fake build. 4 | .DESCRIPTION 5 | This Powershell script will download NuGet if missing, restore NuGet tools (including Fake) 6 | and execute your Fake build script with the parameters you provide. 7 | .PARAMETER Target 8 | The build script target to run. 9 | .PARAMETER Configuration 10 | The build configuration to use. 11 | .PARAMETER Verbosity 12 | Specifies the amount of information to be displayed. 13 | .PARAMETER WhatIf 14 | Performs a dry run of the build script. 15 | No tasks will be executed. 16 | .PARAMETER ScriptArgs 17 | Remaining arguments are added here. 18 | #> 19 | 20 | [CmdletBinding()] 21 | Param( 22 | [string]$Target = "Default", 23 | [ValidateSet("Release", "Debug")] 24 | [string]$Configuration = "Release", 25 | [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] 26 | [string]$Verbosity = "Verbose", 27 | [switch]$WhatIf, 28 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] 29 | [string[]]$ScriptArgs 30 | ) 31 | 32 | $FakeVersion = "4.61.2" 33 | $DotNetChannel = "LTS"; 34 | $DotNetVersion = "3.1.100"; 35 | $DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; 36 | $NugetVersion = "4.1.0"; 37 | $NugetUrl = "https://dist.nuget.org/win-x86-commandline/v$NugetVersion/nuget.exe" 38 | $ProtobufVersion = "3.4.0" 39 | $DocfxVersion = "2.49.0" 40 | 41 | # Make sure tools folder exists 42 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 43 | $ToolPath = Join-Path $PSScriptRoot "tools" 44 | if (!(Test-Path $ToolPath)) { 45 | Write-Verbose "Creating tools directory..." 46 | New-Item -Path $ToolPath -Type directory | out-null 47 | } 48 | 49 | ########################################################################### 50 | # INSTALL .NET CORE CLI 51 | ########################################################################### 52 | 53 | Function Remove-PathVariable([string]$VariableToRemove) 54 | { 55 | $path = [Environment]::GetEnvironmentVariable("PATH", "User") 56 | if ($path -ne $null) 57 | { 58 | $newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove } 59 | [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") 60 | } 61 | 62 | $path = [Environment]::GetEnvironmentVariable("PATH", "Process") 63 | if ($path -ne $null) 64 | { 65 | $newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove } 66 | [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") 67 | } 68 | } 69 | 70 | # Get .NET Core CLI path if installed. 71 | $FoundDotNetCliVersion = $null; 72 | if (Get-Command dotnet -ErrorAction SilentlyContinue) { 73 | $FoundDotNetCliVersion = dotnet --version; 74 | $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 75 | $env:DOTNET_CLI_TELEMETRY_OPTOUT=1 76 | } 77 | 78 | if($FoundDotNetCliVersion -ne $DotNetVersion) { 79 | $InstallPath = Join-Path $PSScriptRoot ".dotnet" 80 | if (!(Test-Path $InstallPath)) { 81 | mkdir -Force $InstallPath | Out-Null; 82 | } 83 | (New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1"); 84 | & $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath -Architecture x64; 85 | 86 | Remove-PathVariable "$InstallPath" 87 | $env:PATH = "$InstallPath;$env:PATH" 88 | $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 89 | $env:DOTNET_CLI_TELEMETRY_OPTOUT=1 90 | $env:DOTNET_ROOT=$InstallPath 91 | } 92 | 93 | ########################################################################### 94 | # INSTALL NUGET 95 | ########################################################################### 96 | 97 | # Make sure nuget.exe exists. 98 | $NugetPath = Join-Path $ToolPath "nuget.exe" 99 | if (!(Test-Path $NugetPath)) { 100 | Write-Host "Downloading NuGet.exe..." 101 | (New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath); 102 | } 103 | 104 | ########################################################################### 105 | # INSTALL FAKE 106 | ########################################################################### 107 | # Make sure Fake has been installed. 108 | 109 | $FakeExePath = Join-Path $ToolPath "FAKE/tools/FAKE.exe" 110 | if (!(Test-Path $FakeExePath)) { 111 | Write-Host "Installing Fake..." 112 | Invoke-Expression "&`"$NugetPath`" install Fake -ExcludeVersion -Version $FakeVersion -OutputDirectory `"$ToolPath`"" | Out-Null; 113 | if ($LASTEXITCODE -ne 0) { 114 | Throw "An error occured while restoring Fake from NuGet." 115 | } 116 | } 117 | 118 | ########################################################################### 119 | # Docfx 120 | ########################################################################### 121 | 122 | # Make sure Docfx has been installed. 123 | $DocfxExePath = Join-Path $ToolPath "docfx.console/tools/docfx.exe" 124 | if (!(Test-Path $DocfxExePath)) { 125 | Write-Host "Installing Docfx..." 126 | Invoke-Expression "&`"$NugetPath`" install docfx.console -ExcludeVersion -Version $DocfxVersion -OutputDirectory `"$ToolPath`"" | Out-Null; 127 | if ($LASTEXITCODE -ne 0) { 128 | Throw "An error occured while restoring docfx.console from NuGet." 129 | } 130 | } 131 | 132 | ########################################################################### 133 | # SignTool 134 | ########################################################################### 135 | 136 | # Make sure the SignClient has been installed 137 | if (Get-Command signclient -ErrorAction SilentlyContinue) { 138 | Write-Host "Found SignClient. Skipping install." 139 | } 140 | else{ 141 | $SignClientFolder = Join-Path $ToolPath "signclient" 142 | Write-Host "SignClient not found. Installing to ... $SignClientFolder" 143 | dotnet tool install SignClient --version 1.0.82 --tool-path "$SignClientFolder" 144 | } 145 | 146 | ########################################################################### 147 | # RUN BUILD SCRIPT 148 | ########################################################################### 149 | 150 | # Build the argument list. 151 | $Arguments = @{ 152 | target=$Target; 153 | configuration=$Configuration; 154 | verbosity=$Verbosity; 155 | dryrun=$WhatIf; 156 | }.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value }; 157 | 158 | # Start Fake 159 | Write-Host "Running build script..." 160 | Invoke-Expression "$FakeExePath `"build.fsx`" $ScriptArgs $Arguments" 161 | 162 | exit $LASTEXITCODE 163 | # SIG # Begin signature block 164 | # MIIgTwYJKoZIhvcNAQcCoIIgQDCCIDwCAQExDzANBglghkgBZQMEAgEFADB5Bgor 165 | # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG 166 | # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDy+m5x/ontiIGy 167 | # a2+Kn4J7jbsGsFWkLaQLK39iFQNsb6CCDiIwggO3MIICn6ADAgECAhAM5+DlF9hG 168 | # /o/lYPwb8D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lzVpGqhH6lbGeasS2GeBhN9/CTyU5rgmLCC9PbMoifdf/yLil4Qf 184 | # 6WXvh+DfwWdJs13rsgkq6ybteL59PyvztyY1bV+JAbZJW58BBZurPSXBzLZ/wvFv 185 | # hsb6ZGjrgS2U60K3+owe3WLxvlBnt2y98/Efaww2BxZ/N3ypW2168RJGYIPXJwS+ 186 | # S86XvsNnKmgR34DnDDNmvxMNFG7zfx9jEB76jRslbWyPpbdhAbHSoyahEHGdreLD 187 | # +cOZUbcrBwjOLuZQsqf6CkUvovDyMIIFLzCCBBegAwIBAgIQDGOJqewvySRbpPsq 188 | # IflH5DANBgkqhkiG9w0BAQsFADByMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGln 189 | # aUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMTEwLwYDVQQDEyhE 190 | # aWdpQ2VydCBTSEEyIEFzc3VyZWQgSUQgQ29kZSBTaWduaW5nIENBMB4XDTE3MDEw 191 | # NjAwMDAwMFoXDTIwMDExNTEyMDAwMFowbDELMAkGA1UEBhMCVVMxEzARBgNVBAgT 192 | # CkNhbGlmb3JuaWExFDASBgNVBAcTC0xvcyBBbmdlbGVzMRgwFgYDVQQKEw9QZXRh 193 | # YnJpZGdlLCBMTEMxGDAWBgNVBAMTD1BldGFicmlkZ2UsIExMQzCCASIwDQYJKoZI 194 | # hvcNAQEBBQADggEPADCCAQoCggEBAJriBjrKlrcxMnq3l2fLb5lQjuc6+J5r8cm6 195 | # J1IlK+BLcf0WnLxOJRBRhHXzdNkiCUJsLw2qE8Adfq0XpfxgQjTSk9Mbn4w7U7wk 196 | # 9/GMsripQZ8qIiQw479XuhQkKqa7A4W4gPSNpanDP93VXQ1rq2QJbYVSG3QG2xhT 197 | # YJQrtYICZUTAX5545iktupiwJcKalr3QK7qrqNlX+D9Io83gapXTTxJcnLQQ49+P 198 | # zg4k84dBsx3ZKRwlQfyay42+vPZzoBqAl3GB5PFhjN1nGYJDOny3OeEbl2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gEF 229 | # BQcBAQRtMGswJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBD 230 | # BggrBgEFBQcwAoY3aHR0cDovL2NhY2VydHMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0 231 | # QXNzdXJlZElEUm9vdENBLmNydDCBgQYDVR0fBHoweDA6oDigNoY0aHR0cDovL2Ny 232 | # bDQuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0QXNzdXJlZElEUm9vdENBLmNybDA6oDig 233 | # NoY0aHR0cDovL2NybDMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0QXNzdXJlZElEUm9v 234 | # dENBLmNybDBPBgNVHSAESDBGMDgGCmCGSAGG/WwAAgQwKjAoBggrBgEFBQcCARYc 235 | # aHR0cHM6Ly93d3cuZGlnaWNlcnQuY29tL0NQUzAKBghghkgBhv1sAzAdBgNVHQ4E 236 | # FgQUWsS5eyoKo6XqcQPAYPkt9mV1DlgwHwYDVR0jBBgwFoAUReuir/SSy4IxLVGL 237 | # p6chnfNtyA8wDQYJKoZIhvcNAQELBQADggEBAD7sDVoks/Mi0RXILHwlKXaoHV0c 238 | # LToaxO8wYdd+C2D9wz0PxK+L/e8q3yBVN7Dh9tGSdQ9RtG6ljlriXiSBThCk7j9x 239 | # jmMOE0ut119EefM2FAaK95xGTlz/kLEbBw6RFfu6r7VRwo0kriTGxycqoSkoGjpx 240 | # KAI8LpGjwCUR4pwUR6F6aGivm6dcIFzZcbEMj7uo+MUSaJ/PQMtARKUT8OZkDCUI 241 | # QjKyNookAv4vcn4c10lFluhZHen6dGRrsutmQ9qzsIzV6Q3d9gEgzpkxYz0IGhiz 242 | # gZtPxpMQBvwHgfqL2vmCSfdibqFT+hKUGIUukpHqaGxEMrJmoecYpJpkUe8xghGD 243 | # MIIRfwIBATCBhjByMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5j 244 | # MRkwFwYDVQQLExB3d3cuZGlnaW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dPuXciaC1TjqAlxa+DPIhAP 306 | # dc9xck4Krd9AOly3UeGheRTGTSQjMF287DxgaqwvB8z98OpH2YhQXv1mblZhJymJ 307 | # hFHmgudGUP2UKiyn5HU+upgPhH+fMRTWrdXyZMt7HgXQhBlyF/EXBu89zdZN7wZC 308 | # /aJTKk+FHcQdPK/P2qwQ9d2srOlW/5MCAwEAAaOCAc4wggHKMB0GA1UdDgQWBBT0 309 | # tuEgHf4prtLkYaWyoiWyyBc1bjAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd 310 | # 823IDzASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjATBgNVHSUE 311 | # DDAKBggrBgEFBQcDCDB5BggrBgEFBQcBAQRtMGswJAYIKwYBBQUHMAGGGGh0dHA6 312 | # Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBDBggrBgEFBQcwAoY3aHR0cDovL2NhY2VydHMu 313 | # ZGlnaWNlcnQuY29tL0RpZ2lDZXJ0QXNzdXJlZElEUm9vdENBLmNydDCBgQYDVR0f 314 | # BHoweDA6oDigNoY0aHR0cDovL2NybDQuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0QXNz 315 | # dXJlZElEUm9vdENBLmNybDA6oDigNoY0aHR0cDovL2NybDMuZGlnaWNlcnQuY29t 316 | # L0RpZ2lDZXJ0QXNzdXJlZElEUm9vdENBLmNybDBQBgNVHSAESTBHMDgGCmCGSAGG 317 | # /WwAAgQwKjAoBggrBgEFBQcCARYcaHR0cHM6Ly93d3cuZGlnaWNlcnQuY29tL0NQ 318 | # UzALBglghkgBhv1sBwEwDQYJKoZIhvcNAQELBQADggEBAHGVEulRh1Zpze/d2nyq 319 | # Y3qzeM8GN0CE70uEv8rPAwL9xafDDiBCLK938ysfDCFaKrcFNB1qrpn4J6Jmvwmq 320 | # YN92pDqTD/iy0dh8GWLoXoIlHsS6HHssIeLWWywUNUMEaLLbdQLgcseY1jxk5R9I 321 | # EBhfiThhTWJGJIdjjJFSLK8pieV4H9YLFKWA1xJHcLN11ZOFk362kmf7U2GJqPVr 322 | # lsD0WGkNfMgBsbkodbeZY4UijGHKeZR+WfyMD+NvtQEmtmyl7odRIeRYYJu6DC0r 323 | # baLEfrvEJStHAgh8Sa4TtuF8QkIoxhhWz0E0tmZdtnR79VYzIi8iNrJLokqV2PWm 324 | # jlIxggJNMIICSQIBATCBhjByMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNl 325 | # cnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMTEwLwYDVQQDEyhEaWdp 326 | # Q2VydCBTSEEyIEFzc3VyZWQgSUQgVGltZXN0YW1waW5nIENBAhAJwPxGyARCE7VZ 327 | # i68oT05BMA0GCWCGSAFlAwQCAQUAoIGYMBoGCSqGSIb3DQEJAzENBgsqhkiG9w0B 328 | # CRABBDAcBgkqhkiG9w0BCQUxDxcNMTkwMzE1MTYwMDU3WjArBgsqhkiG9w0BCRAC 329 | # DDEcMBowGDAWBBRAAZFHXJiJHeuhBK9HCRtettTLyzAvBgkqhkiG9w0BCQQxIgQg 330 | # jLu5eXUI0j43Sq/ZJ76+UJmWF/2Amb+YAcVtGZhRJKowDQYJKoZIhvcNAQEBBQAE 331 | # ggEAQBQNwdmatbURcWuntIUvk18FZGGLRA3bT0kNXN0pwwwopQlr4G6WbL8C8oSw 332 | # 0KUbWa3VonUYHemc6ZYgSOaa07X9dMoEWdgf9Jy7LDFZQCYBkI7034x0ujyTAZ6U 333 | # KtqQupuRPdLAsCb67KB6DR6lIuP1hj1yolPb9uyqEsH1JJqusTiirZvO1UvNVtHU 334 | # ljscye8j2SiO8UNLhYHL1me43S4NmqgLkaDvIE8lVx8GtyFyGRdFZYTzAufXTR9H 335 | # HK8lsD0ekQiOpaAIw/MfhEgTej1Z3L686Z0xwBVyH988UA9lVbXdDZWS3odGd2CT 336 | # /JdEUFIMzW5J8N+QntZ/Fjua/A== 337 | # SIG # End signature block 338 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ########################################################################## 3 | # This is the Fake bootstrapper script for Linux and OS X. 4 | ########################################################################## 5 | 6 | # Define directories. 7 | SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 8 | TOOLS_DIR=$SCRIPT_DIR/tools 9 | SIGNCLIENT_DIR=$TOOLS_DIR/signclient 10 | NUGET_EXE=$TOOLS_DIR/nuget.exe 11 | NUGET_URL=https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe 12 | FAKE_VERSION=4.61.2 13 | FAKE_EXE=$TOOLS_DIR/FAKE/tools/FAKE.exe 14 | DOTNET_VERSION=3.1.100 15 | DOTNET_INSTALLER_URL=https://dot.net/v1/dotnet-install.sh 16 | DOTNET_CHANNEL=LTS; 17 | DOCFX_VERSION=2.49.0 18 | DOCFX_EXE=$TOOLS_DIR/docfx.console/tools/docfx.exe 19 | 20 | # Define default arguments. 21 | TARGET="Default" 22 | CONFIGURATION="Release" 23 | VERBOSITY="verbose" 24 | DRYRUN= 25 | SCRIPT_ARGUMENTS=() 26 | 27 | # Parse arguments. 28 | for i in "$@"; do 29 | case $1 in 30 | -t|--target) TARGET="$2"; shift ;; 31 | -c|--configuration) CONFIGURATION="$2"; shift ;; 32 | -v|--verbosity) VERBOSITY="$2"; shift ;; 33 | -d|--dryrun) DRYRUN="-dryrun" ;; 34 | --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; 35 | *) SCRIPT_ARGUMENTS+=("$1") ;; 36 | esac 37 | shift 38 | done 39 | 40 | # Make sure the tools folder exist. 41 | if [ ! -d "$TOOLS_DIR" ]; then 42 | mkdir "$TOOLS_DIR" 43 | fi 44 | 45 | ########################################################################### 46 | # INSTALL .NET CORE CLI 47 | ########################################################################### 48 | 49 | echo "Installing .NET CLI..." 50 | if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then 51 | mkdir "$SCRIPT_DIR/.dotnet" 52 | fi 53 | curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" $DOTNET_INSTALLER_URL 54 | bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --channel $DOTNET_CHANNEL --install-dir .dotnet --no-path 55 | export PATH="$SCRIPT_DIR/.dotnet":$PATH 56 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 57 | export DOTNET_CLI_TELEMETRY_OPTOUT=1 58 | chmod -R 0755 ".dotnet" 59 | "$SCRIPT_DIR/.dotnet/dotnet" --info 60 | 61 | 62 | ########################################################################### 63 | # INSTALL NUGET 64 | ########################################################################### 65 | 66 | # Download NuGet if it does not exist. 67 | if [ ! -f "$NUGET_EXE" ]; then 68 | echo "Downloading NuGet..." 69 | curl -Lsfo "$NUGET_EXE" $NUGET_URL 70 | if [ $? -ne 0 ]; then 71 | echo "An error occured while downloading nuget.exe." 72 | exit 1 73 | fi 74 | fi 75 | 76 | ########################################################################### 77 | # INSTALL FAKE 78 | ########################################################################### 79 | 80 | if [ ! -f "$FAKE_EXE" ]; then 81 | mono "$NUGET_EXE" install Fake -ExcludeVersion -Version $FAKE_VERSION -OutputDirectory "$TOOLS_DIR" 82 | if [ $? -ne 0 ]; then 83 | echo "An error occured while installing Cake." 84 | exit 1 85 | fi 86 | fi 87 | 88 | # Make sure that Fake has been installed. 89 | if [ ! -f "$FAKE_EXE" ]; then 90 | echo "Could not find Fake.exe at '$FAKE_EXE'." 91 | exit 1 92 | fi 93 | 94 | ########################################################################### 95 | # INSTALL DOCFX 96 | ########################################################################### 97 | if [ ! -f "$DOCFX_EXE" ]; then 98 | mono "$NUGET_EXE" install docfx.console -ExcludeVersion -Version $DOCFX_VERSION -OutputDirectory "$TOOLS_DIR" 99 | if [ $? -ne 0 ]; then 100 | echo "An error occured while installing DocFx." 101 | exit 1 102 | fi 103 | fi 104 | 105 | # Make sure that DocFx has been installed. 106 | if [ ! -f "$DOCFX_EXE" ]; then 107 | echo "Could not find docfx.exe at '$DOCFX_EXE'." 108 | exit 1 109 | fi 110 | 111 | ########################################################################### 112 | # INSTALL SignTool 113 | ########################################################################### 114 | if [ ! -f "$SIGNTOOL_EXE" ]; then 115 | "$SCRIPT_DIR/.dotnet/dotnet" tool install SignClient --version 1.0.82 --tool-path "$SIGNCLIENT_DIR" 116 | if [ $? -ne 0 ]; then 117 | echo "SignClient already installed." 118 | fi 119 | fi 120 | 121 | 122 | ########################################################################### 123 | # WORKAROUND FOR MONO 124 | ########################################################################### 125 | export FrameworkPathOverride=/usr/lib/mono/4.5/ 126 | 127 | ########################################################################### 128 | # RUN BUILD SCRIPT 129 | ########################################################################### 130 | 131 | # Start Fake 132 | exec mono "$FAKE_EXE" build.fsx "${SCRIPT_ARGUMENTS[@]}" --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN 133 | -------------------------------------------------------------------------------- /docs/api/index.md: -------------------------------------------------------------------------------- 1 | # API Docs -------------------------------------------------------------------------------- /docs/articles/index.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Article text goes here. -------------------------------------------------------------------------------- /docs/articles/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Introduction 2 | href: index.md -------------------------------------------------------------------------------- /docs/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": [ "**/*.csproj" ], 7 | "exclude": [ 8 | "**/obj/**", 9 | "**/bin/**", 10 | "_site/**", 11 | "**/*Tests*.csproj", 12 | "**/*Tests.*.csproj" 13 | ], 14 | "src": "../src" 15 | } 16 | ], 17 | "dest": "api" 18 | } 19 | ], 20 | "build": { 21 | "content": [ 22 | { 23 | "files": [ 24 | "api/**.yml", 25 | "api/index.md" 26 | ] 27 | }, 28 | { 29 | "files": [ 30 | "articles/**.md", 31 | "articles/**/toc.yml", 32 | "toc.yml", 33 | "*.md" 34 | ], 35 | "exclude": [ 36 | "obj/**", 37 | "_site/**" 38 | ] 39 | }, 40 | ], 41 | "resource": [ 42 | { 43 | "files": [ 44 | "images/**", 45 | "web.config", 46 | ], 47 | "exclude": [ 48 | "obj/**", 49 | "_site/**" 50 | ] 51 | } 52 | ], 53 | "sitemap": { 54 | "baseUrl": "https://yoursite.github.io/" 55 | }, 56 | "dest": "_site", 57 | "globalMetadata": { 58 | "_appTitle": "Akka.DI.AutoFac", 59 | "_disableContribution": "true", 60 | "_appLogoPath": "/images/icon.png", 61 | }, 62 | "globalMetadataFiles": [], 63 | "fileMetadataFiles": [], 64 | "template": [ 65 | "default", 66 | "template" 67 | ], 68 | "postProcessors": ["ExtractSearchIndex"], 69 | "noLangKeyword": false 70 | } 71 | } -------------------------------------------------------------------------------- /docs/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akkadotnet/Akka.DI.AutoFac/dac52edb3ef71dd1c55c517def88b68e2662dd31/docs/images/icon.png -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Introduction to My Project -------------------------------------------------------------------------------- /docs/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Home 2 | href: index.md 3 | - name: Documentation 4 | href: articles/ 5 | - name: API Reference 6 | href: api/ -------------------------------------------------------------------------------- /docs/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /serve-docs.cmd: -------------------------------------------------------------------------------- 1 | PowerShell.exe -file "serve-docs.ps1" %* .\docs\docfx.json --serve -p 8090 -------------------------------------------------------------------------------- /serve-docs.ps1: -------------------------------------------------------------------------------- 1 | # docfx.ps1 2 | $VisualStudioVersion = "15.0"; 3 | $DotnetSDKVersion = "2.0.0"; 4 | 5 | # Get dotnet paths 6 | $MSBuildExtensionsPath = "C:\Program Files\dotnet\sdk\" + $DotnetSDKVersion; 7 | $MSBuildSDKsPath = $MSBuildExtensionsPath + "\SDKs"; 8 | 9 | # Get Visual Studio install path 10 | $VSINSTALLDIR = $(Get-ItemProperty "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7").$VisualStudioVersion; 11 | 12 | # Add Visual Studio environment variables 13 | $env:VisualStudioVersion = $VisualStudioVersion; 14 | $env:VSINSTALLDIR = $VSINSTALLDIR; 15 | 16 | # Add dotnet environment variables 17 | $env:MSBuildExtensionsPath = $MSBuildExtensionsPath; 18 | $env:MSBuildSDKsPath = $MSBuildSDKsPath; 19 | 20 | # Build our docs 21 | & .\tools\docfx.console\tools\docfx @args -------------------------------------------------------------------------------- /src/Akka.DI.AutoFac.Tests/Akka.DI.AutoFac.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(NetFrameworkTestVersion);$(NetCoreTestVersion) 5 | 6 | 7 | 8 | 9 | $(NetCoreTestVersion) 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Akka.DI.AutoFac.Tests/AutoFacDependencyResolverSpecs.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2009-2016 Lightbend Inc. 4 | // Copyright (C) 2013-2016 Akka.NET project 5 | // 6 | //----------------------------------------------------------------------- 7 | 8 | using System; 9 | using System.Diagnostics; 10 | using Akka.Actor; 11 | using Akka.DI.Core; 12 | using Akka.DI.TestKit; 13 | using Autofac; 14 | 15 | namespace Akka.DI.AutoFac.Tests 16 | { 17 | public class AutoFacDependencyResolverSpec : DiResolverSpec 18 | { 19 | protected override object NewDiContainer() 20 | { 21 | var builder = new ContainerBuilder(); 22 | return builder; 23 | } 24 | 25 | protected override IDependencyResolver NewDependencyResolver(object diContainer, ActorSystem system) 26 | { 27 | var builder = ToBuilder(diContainer); 28 | var container = builder.Build(); 29 | return new AutoFacDependencyResolver(container, system); 30 | } 31 | 32 | private static ContainerBuilder ToBuilder(object diContainer) 33 | { 34 | var builder = diContainer as ContainerBuilder; 35 | Debug.Assert(builder != null, "builder != null"); 36 | return builder; 37 | } 38 | 39 | protected override void Bind(object diContainer, Func generator) 40 | { 41 | var builder = ToBuilder(diContainer); 42 | builder.Register(c => generator.Invoke()).As(); 43 | } 44 | 45 | protected override void Bind(object diContainer) 46 | { 47 | var builder = ToBuilder(diContainer); 48 | builder.RegisterType(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Akka.DI.AutoFac.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2046 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{248C7292-293B-41E1-9E3D-FD09D1D20D30}" 7 | ProjectSection(SolutionItems) = preProject 8 | ..\build.fsx = ..\build.fsx 9 | EndProjectSection 10 | EndProject 11 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.DI.AutoFac", "Akka.DI.AutoFac\Akka.DI.AutoFac.csproj", "{88854526-09D3-4F15-98F8-060838D958D1}" 12 | EndProject 13 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.DI.AutoFac.Tests", "Akka.DI.AutoFac.Tests\Akka.DI.AutoFac.Tests.csproj", "{81AADD01-5545-4409-B20C-AA85956E588B}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {88854526-09D3-4F15-98F8-060838D958D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {88854526-09D3-4F15-98F8-060838D958D1}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {88854526-09D3-4F15-98F8-060838D958D1}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {88854526-09D3-4F15-98F8-060838D958D1}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {81AADD01-5545-4409-B20C-AA85956E588B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {81AADD01-5545-4409-B20C-AA85956E588B}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {81AADD01-5545-4409-B20C-AA85956E588B}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {81AADD01-5545-4409-B20C-AA85956E588B}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {446A85DC-A1AF-478E-ADDB-FF491E7B4373} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /src/Akka.DI.AutoFac.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True -------------------------------------------------------------------------------- /src/Akka.DI.AutoFac/ActorSystemExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Akka.DI.AutoFac; 3 | using Akka.DI.Core; 4 | using Autofac; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace Akka.Actor 8 | { 9 | /// 10 | /// Extension methods for to configure Autofac 11 | /// 12 | public static class ActorSystemExtensions 13 | { 14 | /// 15 | /// Creates a new instance of the class 16 | /// associated with the 17 | /// 18 | /// The actor system to plug into 19 | /// The container used to resolve references 20 | /// 21 | /// If the parameter is null. 22 | /// 23 | public static ActorSystem UseAutofac(this ActorSystem system, ILifetimeScope container) 24 | { 25 | UseAutofac(system, container, out _); 26 | return system; 27 | } 28 | 29 | /// 30 | /// Creates a new instance of the class 31 | /// associated with the 32 | /// 33 | /// The actor system to plug into 34 | /// The container used to resolve references 35 | /// The Autofac dependency resolver instance created 36 | /// 37 | /// If the parameter is null. 38 | /// 39 | public static ActorSystem UseAutofac(this ActorSystem system, ILifetimeScope container, out IDependencyResolver dependencyResolver) 40 | { 41 | if (container == null) throw new ArgumentNullException(nameof(container)); 42 | 43 | dependencyResolver = new AutoFacDependencyResolver(container, system); 44 | return system; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Akka.DI.AutoFac/Akka.DI.AutoFac.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Akka.DI.AutoFac 6 | AutoFac Dependency Injection (DI) support for Akka.NET 7 | $(NetStandardLibVersion) 8 | akka;actors;actor model;Akka;concurrency;autofac 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Akka.DI.AutoFac/AutoFacDependencyResolver.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2009-2016 Lightbend Inc. 4 | // Copyright (C) 2013-2016 Akka.NET project 5 | // 6 | //----------------------------------------------------------------------- 7 | 8 | using System; 9 | using System.Collections.Concurrent; 10 | using System.Linq; 11 | using System.Runtime.CompilerServices; 12 | using Akka.Actor; 13 | using Akka.DI.Core; 14 | using Autofac; 15 | 16 | namespace Akka.DI.AutoFac 17 | { 18 | /// 19 | /// Provides services to the extension system 20 | /// used to create actors using the AutoFac IoC container. 21 | /// 22 | public class AutoFacDependencyResolver : IDependencyResolver, INoSerializationVerificationNeeded 23 | { 24 | private ILifetimeScope container; 25 | private ConcurrentDictionary typeCache; 26 | private ActorSystem system; 27 | private ConditionalWeakTable references; 28 | 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | /// The container used to resolve references 33 | /// The actor system to plug into 34 | /// 35 | /// Either the or the was null. 36 | /// 37 | public AutoFacDependencyResolver(ILifetimeScope container, ActorSystem system) 38 | { 39 | if (system == null) throw new ArgumentNullException("system"); 40 | if (container == null) throw new ArgumentNullException("container"); 41 | this.container = container; 42 | typeCache = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); 43 | this.system = system; 44 | this.system.AddDependencyResolver(this); 45 | this.references = new ConditionalWeakTable(); 46 | } 47 | 48 | /// 49 | /// Retrieves an actor's type with the specified name 50 | /// 51 | /// The name of the actor to retrieve 52 | /// The type with the specified actor name 53 | public Type GetType(string actorName) 54 | { 55 | typeCache. 56 | TryAdd(actorName, 57 | actorName.GetTypeValue() ?? 58 | container. 59 | ComponentRegistry. 60 | Registrations. 61 | Where(registration => registration.Activator.LimitType. 62 | Name.Equals(actorName, StringComparison.OrdinalIgnoreCase)). 63 | Select(registration => registration.Activator.LimitType). 64 | FirstOrDefault()); 65 | 66 | return typeCache[actorName]; 67 | } 68 | 69 | /// 70 | /// Creates a delegate factory used to create actors based on their type 71 | /// 72 | /// The type of actor that the factory builds 73 | /// A delegate factory used to create actors 74 | public Func CreateActorFactory(Type actorType) 75 | { 76 | return () => 77 | { 78 | var scope = container.BeginLifetimeScope(); 79 | var actor = (ActorBase)scope.Resolve(actorType); 80 | references.Add(actor, scope); 81 | return actor; 82 | }; 83 | } 84 | 85 | /// 86 | /// Used to register the configuration for an actor of the specified type 87 | /// 88 | /// The type of actor the configuration is based 89 | /// The configuration object for the given actor type 90 | public Props Create() where TActor : ActorBase 91 | { 92 | return Create(typeof(TActor)); 93 | } 94 | 95 | /// 96 | /// Used to register the configuration for an actor of the specified type 97 | /// 98 | /// The of actor the configuration is based 99 | /// The configuration object for the given actor type 100 | public virtual Props Create(Type actorType) 101 | { 102 | return system.GetExtension().Props(actorType); 103 | } 104 | 105 | /// 106 | /// Signals the container to release it's reference to the actor. 107 | /// 108 | /// The actor to remove from the container 109 | public void Release(ActorBase actor) 110 | { 111 | ILifetimeScope scope; 112 | 113 | if (references.TryGetValue(actor, out scope)) 114 | { 115 | scope.Dispose(); 116 | references.Remove(actor); 117 | } 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/common.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright © 2013-2020 Akka.NET Team 4 | Akka.NET Team 5 | 1.4.1 6 | Akka.NET v1.4.1 support. 7 | http://getakka.net/images/akkalogo.png 8 | https://github.com/akkadotnet/Akka.DI.AutoFac 9 | https://github.com/akkadotnet/Akka.DI.AutoFac/blob/master/LICENSE 10 | $(NoWarn);CS1591 11 | 12 | 13 | 1.4.27 14 | 2.4.1 15 | 17.0.0 16 | 1.2.2 17 | netcoreapp3.1 18 | net461 19 | netstandard2.0 20 | 21 | 22 | 23 | true 24 | 25 | true 26 | 27 | true 28 | snupkg 29 | 30 | 31 | 32 | 33 | --------------------------------------------------------------------------------