Showing preview only (579K chars total). Download the full file or copy to clipboard to get everything.
Repository: CatLib/Core
Branch: 2.0
Commit: 98a7b1db446d
Files: 114
Total size: 544.0 KB
Directory structure:
gitextract_rz18cs7b/
├── .dist/
│ ├── CHANGELOG.md
│ ├── LICENSE
│ ├── README.md
│ ├── bucket.json
│ └── netstandard2.0/
│ ├── CatLib.Core.deps.json
│ └── CatLib.Core.pdb
├── .gitattributes
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── ---bug-report.md
│ ├── ---documentation-issue.md
│ ├── ---feature-request.md
│ └── ---support-question.md
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CatLib.Core.sln
├── LICENSE
├── README.md
├── bucket.json
├── build.ps1
└── src/
├── CatLib.Core/
│ ├── CatLib/
│ │ ├── App.cs
│ │ ├── Application.cs
│ │ ├── DebugLevel.cs
│ │ ├── Events/
│ │ │ ├── AfterBootEventArgs.cs
│ │ │ ├── AfterInitEventArgs.cs
│ │ │ ├── AfterTerminateEventArgs.cs
│ │ │ ├── ApplicationEventArgs.cs
│ │ │ ├── ApplicationEvents.cs
│ │ │ ├── BeforeBootEventArgs.cs
│ │ │ ├── BeforeInitEventArgs.cs
│ │ │ ├── BeforeTerminateEventArgs.cs
│ │ │ ├── BootingEventArgs.cs
│ │ │ ├── InitProviderEventArgs.cs
│ │ │ ├── RegisterProviderEventArgs.cs
│ │ │ └── StartCompletedEventArgs.cs
│ │ ├── Facade.cs
│ │ ├── IApplication.cs
│ │ ├── IBootstrap.cs
│ │ ├── IServiceProvider.cs
│ │ ├── ServiceProvider.cs
│ │ └── StartProcess.cs
│ ├── CatLib.Core.csproj
│ ├── Container/
│ │ ├── BindData.cs
│ │ ├── BindDataExtension.cs
│ │ ├── Bindable.cs
│ │ ├── Container.cs
│ │ ├── ContainerExtension.cs
│ │ ├── GivenData.cs
│ │ ├── IBindData.cs
│ │ ├── IBindable.cs
│ │ ├── IContainer.cs
│ │ ├── IGivenData.cs
│ │ ├── IMethodBind.cs
│ │ ├── IParams.cs
│ │ ├── InjectAttribute.cs
│ │ ├── MethodBind.cs
│ │ ├── MethodContainer.cs
│ │ ├── ParamsCollection.cs
│ │ ├── UnresolvableException.cs
│ │ └── VariantAttribute.cs
│ ├── EventDispatcher/
│ │ ├── EventDispatcher.cs
│ │ ├── IEventDispatcher.cs
│ │ └── IStoppableEvent.cs
│ ├── Exception/
│ │ ├── AssertException.cs
│ │ ├── LogicException.cs
│ │ └── RuntimeException.cs
│ ├── IO/
│ │ ├── CombineStream.cs
│ │ ├── RingBufferStream.cs
│ │ ├── SegmentStream.cs
│ │ ├── StreamExtension.cs
│ │ └── WrapperStream.cs
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ └── Util/
│ ├── Arr.cs
│ ├── Guard.cs
│ ├── InternalHelper.cs
│ ├── SortSet.cs
│ └── Str.cs
├── CatLib.Core.Tests/
│ ├── CatLib/
│ │ ├── TestsApplication.cs
│ │ └── TestsFacade.cs
│ ├── CatLib.Core.Tests.csproj
│ ├── Container/
│ │ ├── TestsBindData.cs
│ │ ├── TestsContainer.cs
│ │ └── TestsExtensionContainer.cs
│ ├── EventDispatcher/
│ │ └── TestsEventDispatcher.cs
│ ├── Fixture/
│ │ ├── AbstractClass.cs
│ │ ├── Bar.cs
│ │ ├── Baz.cs
│ │ ├── CircularDependency.cs
│ │ ├── Foo.cs
│ │ ├── FooBar.cs
│ │ ├── Fubar.cs
│ │ ├── FubarChild.cs
│ │ ├── IFoo.cs
│ │ ├── Position.cs
│ │ ├── Quux.cs
│ │ ├── QuuxFoo.cs
│ │ ├── TestEventArgs.cs
│ │ ├── Variant.cs
│ │ └── VariantModel.cs
│ ├── Framework/
│ │ ├── ExpectedExceptionAndMessageAttribute.cs
│ │ ├── TestException.cs
│ │ └── TestMethodIterativeAttribute.cs
│ ├── IO/
│ │ ├── TestsCombineStream.cs
│ │ ├── TestsRingBuffer.cs
│ │ ├── TestsSegmentStream.cs
│ │ └── TestsStreamExtension.cs
│ └── Util/
│ ├── TestsArr.cs
│ ├── TestsGuard.cs
│ ├── TestsSortSet.cs
│ └── TestsStr.cs
├── Directory.Build.props
├── analysis.ruleset
├── analysis.test.ruleset
├── settings.runsettings
└── stylecop.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .dist/CHANGELOG.md
================================================
# Release Notes
## [v2.0.0-alpha.1 (2019-12-04)](https://github.com/CatLib/Core/releases/tag/v2.0.0)
#### Added
- `Inject` allowed to be set to optional.(#253 )
- `Arr.Test` can get matched value of the first match(#280 )
#### Changed
- Comments translated from Chinese into English(#133 )
- Defined Container.Build as a virtual function(#210 )
- Optimizes the constructor of `MethodContainer`(#218 )
- The default project uses the .net standard 2.0(#225 )
- Rename Util helper class to Helper class Change access level to internal.(#230 )
- `Application.IsRegisted` changed(rename) to `IsRegistered`(#226 )
- Use `VariantAttribute` to mark variable types instead of `IVariant`(#232 )
- `Guard` Will be expandable with `Guard.That`(#233 )
- Fixed the problem of container exception stack loss(#234 )
- Adjusted the internal file structure to make it clearer(#236 ).
- Add code analyzers (#206 )
- Refactoring event system (#177 )
- Refactoring `RingBuffer` make it inherit from `Stream`.(#238 )
- Namespace structure adjustment(optimization).(#241 )
- `App` can be extended by `That` (Handler rename to that) and removed `HasHandler` API (#242 )
- Unnecessary inheritance: WrappedStream(#247 )
- Clean up useless comment(#249 ).
- `Guard.Require` can set error messages and internal exceptions(#250).
- Exception class implementation support: SerializationInfo build(#252 ).
- Refactoring unit test, import moq.(#255 )
- `CodeStandardException` replaces to `LogicException`(#257 )
- Exception move to namespace `CatLib.Exception`(#258 )
- `Facade<>.Instance` changed to `Facade<>.That`(#259 )
- `Application.StartProcess` migrate to `StartProcess`(#260 )
- `Arr` optimization, lifting some unnecessary restrictions (#263)
- `Str` optimization, lifting some unnecessary restrictions (#264)
- Refactoring `SortSet`(#265 )
- Removed global params in application constructor. use Application.New() instead.(#267 )
- Containers are no longer thread-safe by default(#270 )
#### Fixed
- Fixed a bug that caused `Arr.Fill` to not work properly under special circumstances. (#255 )
#### Removed
- Removed `ExcludeFromCodeCoverageAttribute` (#229 )
- Removed unnecessary interface design `ISortSet`(#211 ).
- Removed `Version` classes and `Application.Compare` method.(#212).
- Removed `Template` supported(#213 ).
- Removed `FilterChain` supported(#214 ).
- Removed `Enum` supported(#215 ).
- Removed `IAwait` interface(#217 ).
- Removed `Container.Flash` api(#219 ).
- Removed `Arr.Flash` method(#220 ).
- Removed `Dict` helper class(#221 ).
- Removed `ThreadStatic` helper class(#223 ).
- Removed `QuickList` supported(#224 ).
- Removed `Storage` supported(#228 )
- Removed `SystemTime` class(#235 ).
- Removed `ICoroutineInit` feature from core library(#243 ).
- Removed the priority attribute, depending on the loading order(#244 ).
- Removed `Util.Encoding` (#245 ).
- Removed `Str.Encoding`(#246 )
- Removed `IServiceProviderType` feature in core library(#246 ).
- Removed unnecessary extension functions(#247 ).
- Removed `PipelineStream` stream.(#256 )
- Removed all `Obsolete` method and clean code.(#261 )
- Removed `App.Version`.(#266 )
================================================
FILE: .dist/LICENSE
================================================
MIT License
Copyright (c) 2017 CatLib
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: .dist/README.md
================================================
<p align="center"><img width="173" height="57" src="https://catlib.io/imgs/logo-txt.png"></p>
<p align="center">
<a href="https://github.com/Catlib/Core/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" title="license-mit" /></a>
<a href="https://www.nuget.org/packages/catlib.core/"><img src="https://badge.fury.io/nu/catlib.core.svg" title="Nuget Version" /></a>
<a href="https://travis-ci.com/CatLib/Core"><img src="https://travis-ci.com/CatLib/Core.svg?branch=master" title="Build status"/></a>
<a href="https://codecov.io/gh/CatLib/Core">
<img src="https://codecov.io/gh/CatLib/Core/branch/master/graph/badge.svg" alt="Codecov" />
</a>
<a href="https://github.com/CatLib/Core/releases">
<img src="https://img.shields.io/nuget/dt/CatLib.Core.svg" alt="Downloads" />
</a>
</p>
## About CatLib
`CatLib` is the lightweight dependency injection container and helper functions library.
- [Service Provider](https://catlib.io/lasted/architecture/service-provider.html)
- [Application](https://catlib.io/lasted/architecture/application.html)
- [IOC Container](https://catlib.io/lasted/architecture/container.html)
- [Facades](https://catlib.io/lasted/architecture/facade.html)
## Install CatLib Core
**Installed with Nuget**
```PM
$ Install-Package CatLib.Core -Version 2.0.0
```
**Installed with [Bucket](https://github.com/getbucket/bucket)**
```shell
$ bucket require catlib/core
```
**Installed with Github Release**
[Download the latest version](https://github.com/CatLib/Core/releases)。
## Learning CatLib
CatLib has the most extensive and thorough [documentation](https://catlib.io), making it a breeze to get started with the framework.
> 需要中文支持? 请访问[CatLib中文文档](https://zh.catlib.io)。
## Contribution
CatLib is still a young framework, and her growth and your contribution are inseparable. If you want to contribute to the project, please refer to: [CatLib Contribution Guide](https://catlib.io/lasted/contribution.html) Your contribution will be included in the list of contributors,Welcome Pull Request!
## License
The open source license used by CatLib is [MIT license](http://opensource.org/licenses/MIT).
## Support
* email: support@catlib.io
* slack: [catlib.slack](https://catlib.slack.com/messages/internals/)
================================================
FILE: .dist/bucket.json
================================================
{
"name": "catlib/core",
"version": "2.0.0",
"description": "catlib framework is the lightweight dependency injection container and helper functions library.",
"keywords": ["framework", "catlib"],
"license": "MIT",
"homepage": "https://catlib.io",
"support": {
"issues": "https://github.com/CatLib/Core/issues",
"source": "https://github.com/CatLib/Core"
},
"authors": [
{
"name": "Meng han Yu",
"email": "menghanyu1994@gmail.com"
}
]
}
================================================
FILE: .dist/netstandard2.0/CatLib.Core.deps.json
================================================
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"CatLib.Core/0.2.0-alpha.1+37a93a5": {
"dependencies": {
"Microsoft.CodeAnalysis.CSharp": "3.3.1",
"Microsoft.CodeAnalysis.FxCopAnalyzers": "2.9.6",
"NETStandard.Library": "2.0.3",
"SonarAnalyzer.CSharp": "7.17.0.9346",
"StyleCop.Analyzers": "1.1.118"
},
"runtime": {
"CatLib.Core.dll": {}
}
},
"Microsoft.CodeAnalysis.Analyzers/2.9.4": {},
"Microsoft.CodeAnalysis.Common/3.3.1": {
"dependencies": {
"Microsoft.CodeAnalysis.Analyzers": "2.9.4",
"System.Collections.Immutable": "1.5.0",
"System.Memory": "4.5.3",
"System.Reflection.Metadata": "1.6.0",
"System.Runtime.CompilerServices.Unsafe": "4.5.2",
"System.Text.Encoding.CodePages": "4.5.1",
"System.Threading.Tasks.Extensions": "4.5.3"
}
},
"Microsoft.CodeAnalysis.CSharp/3.3.1": {
"dependencies": {
"Microsoft.CodeAnalysis.Common": "3.3.1"
}
},
"Microsoft.CodeAnalysis.FxCopAnalyzers/2.9.6": {
"dependencies": {
"Microsoft.CodeAnalysis.VersionCheckAnalyzer": "2.9.6",
"Microsoft.CodeQuality.Analyzers": "2.9.6",
"Microsoft.NetCore.Analyzers": "2.9.6",
"Microsoft.NetFramework.Analyzers": "2.9.6"
}
},
"Microsoft.CodeAnalysis.VersionCheckAnalyzer/2.9.6": {},
"Microsoft.CodeQuality.Analyzers/2.9.6": {},
"Microsoft.NetCore.Analyzers/2.9.6": {},
"Microsoft.NETCore.Platforms/1.1.0": {},
"Microsoft.NetFramework.Analyzers/2.9.6": {},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"SonarAnalyzer.CSharp/7.17.0.9346": {},
"StyleCop.Analyzers/1.1.118": {},
"System.Buffers/4.4.0": {},
"System.Collections.Immutable/1.5.0": {},
"System.Memory/4.5.3": {
"dependencies": {
"System.Buffers": "4.4.0",
"System.Numerics.Vectors": "4.4.0",
"System.Runtime.CompilerServices.Unsafe": "4.5.2"
}
},
"System.Numerics.Vectors/4.4.0": {},
"System.Reflection.Metadata/1.6.0": {
"dependencies": {
"System.Collections.Immutable": "1.5.0"
}
},
"System.Runtime.CompilerServices.Unsafe/4.5.2": {},
"System.Text.Encoding.CodePages/4.5.1": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "4.5.2"
}
},
"System.Threading.Tasks.Extensions/4.5.3": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "4.5.2"
}
}
}
},
"libraries": {
"CatLib.Core/0.2.0-alpha.1+37a93a5": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.CodeAnalysis.Analyzers/2.9.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-alIJhS0VUg/7x5AsHEoovh/wRZ0RfCSS7k5pDSqpRLTyuMTtRgj6OJJPRApRhJHOGYYsLakf1hKeXFoDwKwNkg==",
"path": "microsoft.codeanalysis.analyzers/2.9.4",
"hashPath": "microsoft.codeanalysis.analyzers.2.9.4.nupkg.sha512"
},
"Microsoft.CodeAnalysis.Common/3.3.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-N5yQdGy+M4kimVG7hwCeGTCfgYjK2o5b/Shumkb/rCC+/SAkvP1HUAYK+vxPFS7dLJNtXLRsmPHKj3fnyNWnrw==",
"path": "microsoft.codeanalysis.common/3.3.1",
"hashPath": "microsoft.codeanalysis.common.3.3.1.nupkg.sha512"
},
"Microsoft.CodeAnalysis.CSharp/3.3.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-WDUIhTHem38H6VJ98x2Ssq0fweakJHnHYl7vbG8ARnsAwLoJKCQCy78EeY1oRrCKG42j0v6JVljKkeqSDA28UA==",
"path": "microsoft.codeanalysis.csharp/3.3.1",
"hashPath": "microsoft.codeanalysis.csharp.3.3.1.nupkg.sha512"
},
"Microsoft.CodeAnalysis.FxCopAnalyzers/2.9.6": {
"type": "package",
"serviceable": true,
"sha512": "sha512-GBZV6P8u3uIXYrlapvbpaaaB5LpF3hk+I2ThIcoVyENr8krNOovFyJhi6FQHgnxd0XLPj9J9Nt35iuqwVe/XJw==",
"path": "microsoft.codeanalysis.fxcopanalyzers/2.9.6",
"hashPath": "microsoft.codeanalysis.fxcopanalyzers.2.9.6.nupkg.sha512"
},
"Microsoft.CodeAnalysis.VersionCheckAnalyzer/2.9.6": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Q5rRN0+9TJsfsXaGKnzDjGkUZ4Rd8ZKmpSND1j49jsmLacCspp4ZaJ31nJn76B/W0qrb4GkEBxKtj3U9lo2gqg==",
"path": "microsoft.codeanalysis.versioncheckanalyzer/2.9.6",
"hashPath": "microsoft.codeanalysis.versioncheckanalyzer.2.9.6.nupkg.sha512"
},
"Microsoft.CodeQuality.Analyzers/2.9.6": {
"type": "package",
"serviceable": true,
"sha512": "sha512-jND04w/FPgfBYKkLLnosmvgHs8NMpMvQ7LQqyiCjMlKOM+MT6edgvTU0vAAowxGuLGceC6pjJm0kUVkG9qT3CQ==",
"path": "microsoft.codequality.analyzers/2.9.6",
"hashPath": "microsoft.codequality.analyzers.2.9.6.nupkg.sha512"
},
"Microsoft.NetCore.Analyzers/2.9.6": {
"type": "package",
"serviceable": true,
"sha512": "sha512-YPcQ+gCt66btt9jNHNi4vrRK6AAP7EIO17quwUeHLUw7vhc6q18r2RYVTLKQvOQuOXs1UEYHArENpppwFP4MLA==",
"path": "microsoft.netcore.analyzers/2.9.6",
"hashPath": "microsoft.netcore.analyzers.2.9.6.nupkg.sha512"
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"Microsoft.NetFramework.Analyzers/2.9.6": {
"type": "package",
"serviceable": true,
"sha512": "sha512-8VyWe53rtUkgJFAkbCZY5KT2t1tEmRrdK1Z+zbyRlzoKVEHyMs0+WNBeJ8d2YB/NjXaYAlaVG2CGZFnQUrwY6A==",
"path": "microsoft.netframework.analyzers/2.9.6",
"hashPath": "microsoft.netframework.analyzers.2.9.6.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
},
"SonarAnalyzer.CSharp/7.17.0.9346": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Fmap0bvZRojVKRSJj8xS3Bqsltmjy6i3bJF2gXMkuKdtFFJeS546RT75G3YN3IDSygrIEyfQdL+s8ep60vzORQ==",
"path": "sonaranalyzer.csharp/7.17.0.9346",
"hashPath": "sonaranalyzer.csharp.7.17.0.9346.nupkg.sha512"
},
"StyleCop.Analyzers/1.1.118": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Onx6ovGSqXSK07n/0eM3ZusiNdB6cIlJdabQhWGgJp3Vooy9AaLS/tigeybOJAobqbtggTamoWndz72JscZBvw==",
"path": "stylecop.analyzers/1.1.118",
"hashPath": "stylecop.analyzers.1.1.118.nupkg.sha512"
},
"System.Buffers/4.4.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-AwarXzzoDwX6BgrhjoJsk6tUezZEozOT5Y9QKF94Gl4JK91I4PIIBkBco9068Y9/Dra8Dkbie99kXB8+1BaYKw==",
"path": "system.buffers/4.4.0",
"hashPath": "system.buffers.4.4.0.nupkg.sha512"
},
"System.Collections.Immutable/1.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-EXKiDFsChZW0RjrZ4FYHu9aW6+P4MCgEDCklsVseRfhoO0F+dXeMSsMRAlVXIo06kGJ/zv+2w1a2uc2+kxxSaQ==",
"path": "system.collections.immutable/1.5.0",
"hashPath": "system.collections.immutable.1.5.0.nupkg.sha512"
},
"System.Memory/4.5.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==",
"path": "system.memory/4.5.3",
"hashPath": "system.memory.4.5.3.nupkg.sha512"
},
"System.Numerics.Vectors/4.4.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-UiLzLW+Lw6HLed1Hcg+8jSRttrbuXv7DANVj0DkL9g6EnnzbL75EB7EWsw5uRbhxd/4YdG8li5XizGWepmG3PQ==",
"path": "system.numerics.vectors/4.4.0",
"hashPath": "system.numerics.vectors.4.4.0.nupkg.sha512"
},
"System.Reflection.Metadata/1.6.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-COC1aiAJjCoA5GBF+QKL2uLqEBew4JsCkQmoHKbN3TlOZKa2fKLz5CpiRQKDz0RsAOEGsVKqOD5bomsXq/4STQ==",
"path": "system.reflection.metadata/1.6.0",
"hashPath": "system.reflection.metadata.1.6.0.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/4.5.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-wprSFgext8cwqymChhrBLu62LMg/1u92bU+VOwyfBimSPVFXtsNqEWC92Pf9ofzJFlk4IHmJA75EDJn1b2goAQ==",
"path": "system.runtime.compilerservices.unsafe/4.5.2",
"hashPath": "system.runtime.compilerservices.unsafe.4.5.2.nupkg.sha512"
},
"System.Text.Encoding.CodePages/4.5.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-4J2JQXbftjPMppIHJ7IC+VXQ9XfEagN92vZZNoG12i+zReYlim5dMoXFC1Zzg7tsnKDM7JPo5bYfFK4Jheq44w==",
"path": "system.text.encoding.codepages/4.5.1",
"hashPath": "system.text.encoding.codepages.4.5.1.nupkg.sha512"
},
"System.Threading.Tasks.Extensions/4.5.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-+MvhNtcvIbqmhANyKu91jQnvIRVSTiaOiFNfKWwXGHG48YAb4I/TyH8spsySiPYla7gKal5ZnF3teJqZAximyQ==",
"path": "system.threading.tasks.extensions/4.5.3",
"hashPath": "system.threading.tasks.extensions.4.5.3.nupkg.sha512"
}
}
}
================================================
FILE: .gitattributes
================================================
src/ export-ignore
*.sln export-ignore
.gitignore export-ignore
.gitattributes export-ignore
*.ps1 export-ignore
.github/ export-ignore
.travis.yml export-ignore
/bucket.json export-ignore
/README.md export-ignore
/CHANGELOG.md export-ignore
/LICENSE export-ignore
================================================
FILE: .github/ISSUE_TEMPLATE/---bug-report.md
================================================
---
name: "\U0001F41B Bug Report"
about: Report a general framework issue. Please ensure your CatLib version is still
supported.
title: "[BUG] Add a placeholder for issues title, ex."
labels: Need Review, bug
assignees: yb199478
---
**CatLib version(s) affected**: x.y.z
#### Description
<!-- A clear and concise description of the problem. -->
#### How to reproduce
<!-- Code and/or config needed to reproduce the problem. -->
#### Possible Solution
<!--- Optional: only if you have suggestions on a fix/reason for the bug -->
#### Additional context
<!-- Optional: any other context about the problem: log messages, screenshots, etc. -->
================================================
FILE: .github/ISSUE_TEMPLATE/---documentation-issue.md
================================================
---
name: "\U0001F4DA Documentation Issue"
about: For documentation issues, open a pull request at https://github.com/catlib/catlib-en.io
title: "[Document] Add a placeholder for issues title, ex."
labels: Document, Need Review
assignees: yb199478
---
The CatLib documentation has its own dedicated repository. Please open a pull request at https://github.com/catlib/catlib-en to correct the issue you have found.
Thanks!
================================================
FILE: .github/ISSUE_TEMPLATE/---feature-request.md
================================================
---
name: "\U0001F4A1 Feature Request"
about: Suggest an idea for this project
title: "[Feature] Suggested as the issues title, ex."
labels: Feature, Need Review
assignees: yb199478
---
If you would like to propose new CatLib features, please make a pull request, or open an issue.
================================================
FILE: .github/ISSUE_TEMPLATE/---support-question.md
================================================
---
name: "\U0001F680 Support Question"
about: This repository is only for for questions about using CatLib and its components.
title: "[Question] Add a placeholder for issues title, ex."
labels: Need Review, question
assignees: yb199478
---
> If you need support, please use the document first: http://catlib.io
**CatLib version(s) affected**: x.y.z
#### Description
<!-- A clear and concise description of the problem. -->
#### What's need help
<!-- Briefly and clearly describe what you need to get help. -->
================================================
FILE: .gitignore
================================================
.vs/
src/*/bin/
src/*/obj/
TestResults/
coverage.json
coverage.opencover.xml
.DS_Store
.idea/
*.sln.DotSettings.user
================================================
FILE: .travis.yml
================================================
language: csharp
mono: none
dotnet: 3.0.100
stages:
- compile
- test
jobs:
include:
- stage: compile
script:
- dotnet build -c Release
- stage: test
script:
- dotnet test -c Release -s src/settings.runsettings /p:CollectCoverage=true /p:CoverletOutputFormat=\"json,teamcity,opencover\" /p:CoverletOutput=\"../../coverage/\" /p:Exclude=[*.Tests]* /p:Threshold=90 /p:ThresholdType=line
after_success:
- bash <(curl -s https://codecov.io/bash) -f coverage/coverage.opencover.xml -t $CODE_COV_TOKEN
================================================
FILE: CHANGELOG.md
================================================
# Release Notes
## [v2.0.0-alpha.1 (2019-12-04)](https://github.com/CatLib/Core/releases/tag/v2.0.0)
#### Added
- `Inject` allowed to be set to optional.(#253 )
- `Arr.Test` can get matched value of the first match(#280 )
#### Changed
- Comments translated from Chinese into English(#133 )
- Defined Container.Build as a virtual function(#210 )
- Optimizes the constructor of `MethodContainer`(#218 )
- The default project uses the .net standard 2.0(#225 )
- Rename Util helper class to Helper class Change access level to internal.(#230 )
- `Application.IsRegisted` changed(rename) to `IsRegistered`(#226 )
- Use `VariantAttribute` to mark variable types instead of `IVariant`(#232 )
- `Guard` Will be expandable with `Guard.That`(#233 )
- Fixed the problem of container exception stack loss(#234 )
- Adjusted the internal file structure to make it clearer(#236 ).
- Add code analyzers (#206 )
- Refactoring event system (#177 )
- Refactoring `RingBuffer` make it inherit from `Stream`.(#238 )
- Namespace structure adjustment(optimization).(#241 )
- `App` can be extended by `That` (Handler rename to that) and removed `HasHandler` API (#242 )
- Unnecessary inheritance: WrappedStream(#247 )
- Clean up useless comment(#249 ).
- `Guard.Require` can set error messages and internal exceptions(#250).
- Exception class implementation support: SerializationInfo build(#252 ).
- Refactoring unit test, import moq.(#255 )
- `CodeStandardException` replaces to `LogicException`(#257 )
- Exception move to namespace `CatLib.Exception`(#258 )
- `Facade<>.Instance` changed to `Facade<>.That`(#259 )
- `Application.StartProcess` migrate to `StartProcess`(#260 )
- `Arr` optimization, lifting some unnecessary restrictions (#263)
- `Str` optimization, lifting some unnecessary restrictions (#264)
- Refactoring `SortSet`(#265 )
- Removed global params in application constructor. use Application.New() instead.(#267 )
- Containers are no longer thread-safe by default(#270 )
#### Fixed
- Fixed a bug that caused `Arr.Fill` to not work properly under special circumstances. (#255 )
#### Removed
- Removed `ExcludeFromCodeCoverageAttribute` (#229 )
- Removed unnecessary interface design `ISortSet`(#211 ).
- Removed `Version` classes and `Application.Compare` method.(#212).
- Removed `Template` supported(#213 ).
- Removed `FilterChain` supported(#214 ).
- Removed `Enum` supported(#215 ).
- Removed `IAwait` interface(#217 ).
- Removed `Container.Flash` api(#219 ).
- Removed `Arr.Flash` method(#220 ).
- Removed `Dict` helper class(#221 ).
- Removed `ThreadStatic` helper class(#223 ).
- Removed `QuickList` supported(#224 ).
- Removed `Storage` supported(#228 )
- Removed `SystemTime` class(#235 ).
- Removed `ICoroutineInit` feature from core library(#243 ).
- Removed the priority attribute, depending on the loading order(#244 ).
- Removed `Util.Encoding` (#245 ).
- Removed `Str.Encoding`(#246 )
- Removed `IServiceProviderType` feature in core library(#246 ).
- Removed unnecessary extension functions(#247 ).
- Removed `PipelineStream` stream.(#256 )
- Removed all `Obsolete` method and clean code.(#261 )
- Removed `App.Version`.(#266 )
================================================
FILE: CatLib.Core.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CatLib.Core", "src\CatLib.Core\CatLib.Core.csproj", "{C99EA95A-3D04-4588-97E5-D81078EE85BD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CatLib.Core.Tests", "src\CatLib.Core.Tests\CatLib.Core.Tests.csproj", "{2E89486C-7A92-4C94-8F3E-D8DC1F5C883B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C99EA95A-3D04-4588-97E5-D81078EE85BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C99EA95A-3D04-4588-97E5-D81078EE85BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C99EA95A-3D04-4588-97E5-D81078EE85BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C99EA95A-3D04-4588-97E5-D81078EE85BD}.Release|Any CPU.Build.0 = Release|Any CPU
{2E89486C-7A92-4C94-8F3E-D8DC1F5C883B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E89486C-7A92-4C94-8F3E-D8DC1F5C883B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E89486C-7A92-4C94-8F3E-D8DC1F5C883B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E89486C-7A92-4C94-8F3E-D8DC1F5C883B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BD9525ED-3010-4A67-B726-6FB2960FEC30}
EndGlobalSection
EndGlobal
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2017 CatLib
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
================================================
<p align="center"><img width="173" height="57" src="https://catlib.io/imgs/logo-txt.png"></p>
<p align="center">
<a href="https://github.com/Catlib/Core/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" title="license-mit" /></a>
<a href="https://www.nuget.org/packages/catlib.core/"><img src="https://badge.fury.io/nu/catlib.core.svg" title="Nuget Version" /></a>
<a href="https://travis-ci.com/CatLib/Core"><img src="https://travis-ci.com/CatLib/Core.svg?branch=master" title="Build status"/></a>
<a href="https://codecov.io/gh/CatLib/Core">
<img src="https://codecov.io/gh/CatLib/Core/branch/master/graph/badge.svg" alt="Codecov" />
</a>
<a href="https://github.com/CatLib/Core/releases">
<img src="https://img.shields.io/nuget/dt/CatLib.Core.svg" alt="Downloads" />
</a>
</p>
## About CatLib
`CatLib` is the lightweight dependency injection container and helper functions library.
- [Service Provider](https://catlib.io/lasted/architecture/service-provider.html)
- [Application](https://catlib.io/lasted/architecture/application.html)
- [IOC Container](https://catlib.io/lasted/architecture/container.html)
- [Facades](https://catlib.io/lasted/architecture/facade.html)
## Install CatLib Core
**Installed with Nuget**
```PM
$ Install-Package CatLib.Core -Version 2.0.0
```
**Installed with [Bucket](https://github.com/getbucket/bucket)**
```shell
$ bucket require catlib/core
```
**Installed with Github Release**
[Download the latest version](https://github.com/CatLib/Core/releases)。
## Learning CatLib
CatLib has the most extensive and thorough [documentation](https://catlib.io), making it a breeze to get started with the framework.
> 需要中文支持? 请访问[CatLib中文文档](https://cn.catlib.io)。
## Contribution
CatLib is still a young framework, and her growth and your contribution are inseparable. If you want to contribute to the project, please refer to: [CatLib Contribution Guide](https://catlib.io/lasted/contribution.html) Your contribution will be included in the list of contributors,Welcome Pull Request!
## License
The open source license used by CatLib is [MIT license](http://opensource.org/licenses/MIT).
## Support
* email: support@catlib.io
* slack: [catlib.slack](https://catlib.slack.com/messages/internals/)
================================================
FILE: bucket.json
================================================
{
"name": "catlib/core",
"version": "2.0.0",
"description": "catlib framework is the lightweight dependency injection container and helper functions library.",
"keywords": ["framework", "catlib"],
"license": "MIT",
"homepage": "https://catlib.io",
"support": {
"issues": "https://github.com/CatLib/Core/issues",
"source": "https://github.com/CatLib/Core"
},
"authors": [
{
"name": "Meng han Yu",
"email": "menghanyu1994@gmail.com"
}
]
}
================================================
FILE: build.ps1
================================================
param(
[string]$version="master-dev"
)
$dist = ".dist"
$root = (Get-Item -Path ".\").FullName
$publishDir = $root + "\src\CatLib.Core\bin\Release\netstandard2.0\publish"
$version = $version.Trim()
$versionParttern = "^v?(?<master>(?<major>\d{1,5})(?<minor>\.\d+)?(?<patch>\.\d+)?(?<revision>\.\d+)?|master)(?<stability>\-(?:stable|beta|b|RC|alpha|a|patch|pl|p|dev)(?:(?:[.-]?\d+)+)?)?(?<build>\+[0-9A-Za-z\-\.]+)?$"
if(!($version -match $versionParttern))
{
throw ("Invalid version, must conform to the semver version: " + $version)
}
if($matches["stability"] -eq $null)
{
$matches["stability"] = "-stable"
}
if($matches["master"] -eq "master")
{
$matches["major"] = "0"
}
if($matches["minor"] -eq $null)
{
$matches["minor"] = ".0"
}
if($matches["patch"] -eq $null)
{
$matches["patch"] = ".0"
}
if($matches["build"] -match "^[0-9a-f]{40}$")
{
$env:CATLIB_COMMIT_SHA = $matches["build"].substring(1).trim()
$matches["build"] = $matches["build"].substring(0, 8)
}
elseif($env:CI_COMMIT_SHA -ne $null)
{
$env:CATLIB_COMMIT_SHA = ($env:CI_COMMIT_SHA).trim()
$matches["build"] = "+" + $env:CATLIB_COMMIT_SHA.substring(0, 7)
}
else
{
$env:CATLIB_COMMIT_SHA = (git rev-parse HEAD).trim()
$matches["build"] = "+" + $env:CATLIB_COMMIT_SHA.substring(0, 7)
}
$major = $matches["major"]
$minor = $matches["minor"]
$assemblyVersion = $major + ".0.0.0"
$versionNormalized = $major + $minor + $matches["patch"] + $matches["revision"] + $matches["stability"] + $matches["build"]
$beginDateTime = ([DateTime] "01/01/2000");
$midnightDateTime = (Get-Date -Hour 0 -Minute 0 -Second 0);
$elapseDay = -1 * (New-TimeSpan -end $beginDateTime).Days
$elapseMidnight = [math]::floor((New-TimeSpan $midnightDateTime -End (Get-Date)).TotalSeconds * 0.5)
$fileVersion = $major + $minor + "." + $elapseDay + "." + $elapseMidnight
dotnet publish src\CatLib.Core\CatLib.Core.csproj -c Release /p:Version=$versionNormalized /p:AssemblyVersion=$assemblyVersion /p:FileVersion=$fileVersion --self-contained false
if($LastExitCode){
echo "Abnormal. build failded."
exit(1)
}
if(Test-Path -Path $dist)
{
Remove-Item $dist -Recurse
}
mkdir $dist
mkdir $dist\netstandard2.0
cp $publishDir\* $dist\netstandard2.0 -Recurse
cp LICENSE $dist
cp CHANGELOG.md $dist
cp README.md $dist
cp bucket.json $dist
$env:CATLIB_PROJECT_VERSION=$versionNormalized.trim()
$env:CATLIB_FILE_VERSION=$fileVersion.trim()
$env:CATLIB_STABILITY=$matches["stability"].substring(1).trim()
$env:CATLIB_MIN_DOTNET_CORE="3.0.0".trim()
$env:CATLIB_PUBLISH_DIR=$publishDir.trim()
echo "CATLIB_COMMIT_SHA $env:CATLIB_COMMIT_SHA"
echo "CATLIB_FILE_VERSION $env:CATLIB_FILE_VERSION"
echo "CATLIB_PROJECT_VERSION $env:CATLIB_PROJECT_VERSION"
echo "CATLIB_STABILITY $env:CATLIB_STABILITY"
echo "CATLIB_MIN_DOTNET_CORE $env:CATLIB_MIN_DOTNET_CORE"
echo "CATLIB_PUBLISH_DIR $env:CATLIB_PUBLISH_DIR"
================================================
FILE: src/CatLib.Core/CatLib/App.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using CatLib.Container;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
#pragma warning disable CA1030
namespace CatLib
{
/// <summary>
/// The <see cref="IApplication"/> static facade.
/// </summary>
[ExcludeFromCodeCoverage]
#pragma warning disable S1118
public abstract class App
#pragma warning restore S1118
{
/// <summary>
/// The <see cref="IApplication"/> instance.
/// </summary>
private static IApplication that;
/// <summary>
/// Callback when a new <see cref="IApplication"/> instance is created.
/// </summary>
public static event Action<IApplication> OnNewApplication
{
add
{
RaiseOnNewApplication += value;
if (That != null)
{
value?.Invoke(That);
}
}
remove => RaiseOnNewApplication -= value;
}
/// <summary>
/// Callback when a new <see cref="IApplication"/> instance is created.
/// </summary>
private static event Action<IApplication> RaiseOnNewApplication;
/// <summary>
/// Gets or Sets the <see cref="IApplication"/> instance.
/// </summary>
public static IApplication That
{
get
{
return that;
}
set
{
that = value;
RaiseOnNewApplication?.Invoke(that);
}
}
/// <inheritdoc cref="IApplication.IsMainThread"/>
public static bool IsMainThread => That.IsMainThread;
/// <inheritdoc cref="IApplication.DebugLevel"/>
public static DebugLevel DebugLevel
{
get => That.DebugLevel;
set => That.DebugLevel = value;
}
/// <inheritdoc cref="IApplication.Terminate"/>
public static void Terminate()
{
That.Terminate();
}
/// <inheritdoc cref="IApplication.Register"/>
public static void Register(IServiceProvider provider, bool force = false)
{
That.Register(provider, force);
}
/// <inheritdoc cref="IApplication.IsRegistered"/>
public static bool IsRegistered(IServiceProvider provider)
{
return That.IsRegistered(provider);
}
/// <inheritdoc cref="IApplication.GetRuntimeId"/>
public static long GetRuntimeId()
{
return That.GetRuntimeId();
}
/// <inheritdoc cref="IContainer.UnbindMethod(object)"/>
public static void UnbindMethod(object target)
{
That.UnbindMethod(target);
}
/// <inheritdoc cref="IContainer.Invoke(string, object[])"/>
public static object Invoke(string method, params object[] userParams)
{
return That.Invoke(method, userParams);
}
/// <inheritdoc cref="IContainer.OnFindType(Func{string, Type}, int)"/>
public static IContainer OnFindType(Func<string, Type> func, int priority = int.MaxValue)
{
return That.OnFindType(func, priority);
}
/// <inheritdoc cref="IContainer.OnRebound(string, Action{object})"/>
public static IContainer OnRebound(string service, Action<object> callback)
{
return That.OnRebound(service, callback);
}
/// <inheritdoc cref="IContainer.GetBind"/>
public static IBindData GetBind(string service)
{
return That.GetBind(service);
}
/// <inheritdoc cref="ExtendContainer.GetBind{TService}(IContainer)"/>
public static IBindData GetBind<TService>()
{
return That.GetBind<TService>();
}
/// <inheritdoc cref="IContainer.HasInstance(string)"/>
public static bool HasInstance(string service)
{
return That.HasInstance(service);
}
/// <inheritdoc cref="ExtendContainer.HasInstance{TService}(IContainer)"/>
public static bool HasInstance<TService>()
{
#if CATLIB_PERFORMANCE
return Facade<TService>.HasInstance || Handler.HasInstance<TService>();
#else
return That.HasInstance<TService>();
#endif
}
/// <inheritdoc cref="IContainer.IsResolved(string)"/>
public static bool IsResolved(string service)
{
return That.IsResolved(service);
}
/// <inheritdoc cref="ExtendContainer.IsResolved{TService}(IContainer)"/>
public static bool IsResolved<TService>()
{
return That.IsResolved<TService>();
}
/// <inheritdoc cref="IContainer.HasBind(string)"/>
public static bool HasBind(string service)
{
return That.HasBind(service);
}
/// <inheritdoc cref="ExtendContainer.HasBind{TService}(IContainer)"/>
public static bool HasBind<TService>()
{
return That.HasBind<TService>();
}
/// <inheritdoc cref="IContainer.CanMake(string)"/>
public static bool CanMake(string service)
{
return That.CanMake(service);
}
/// <inheritdoc cref="ExtendContainer.CanMake{TService}(IContainer)"/>
public static bool CanMake<TService>()
{
return That.CanMake<TService>();
}
/// <inheritdoc cref="IContainer.IsStatic(string)"/>
public static bool IsStatic(string service)
{
return That.IsStatic(service);
}
/// <inheritdoc cref="ExtendContainer.IsStatic{TService}(IContainer)"/>
public static bool IsStatic<TService>()
{
return That.IsStatic<TService>();
}
/// <inheritdoc cref="IContainer.IsAlias(string)"/>
public static bool IsAlias(string name)
{
return That.IsAlias(name);
}
/// <inheritdoc cref="ExtendContainer.IsAlias{TService}(IContainer)"/>
public static bool IsAlias<TService>()
{
return That.IsAlias<TService>();
}
/// <inheritdoc cref="IContainer.Alias(string, string)"/>
public static IContainer Alias(string alias, string service)
{
return That.Alias(alias, service);
}
/// <inheritdoc cref="ExtendContainer.Alias{TAlias, TService}(IContainer)"/>
public static IContainer Alias<TAlias, TService>()
{
return That.Alias<TAlias, TService>();
}
/// <inheritdoc cref="IContainer.Extend(string, Func{object, IContainer, object})"/>
public static void Extend(string service, Func<object, IContainer, object> closure)
{
That.Extend(service, closure);
}
/// <inheritdoc cref="ExtendContainer.Extend(IContainer, string, Func{object, object})"/>
public static void Extend(string service, Func<object, object> closure)
{
That.Extend(service, closure);
}
/// <inheritdoc cref="ExtendContainer.Extend{TConcrete}(IContainer, Func{TConcrete, object})"/>
public static void Extend<TService, TConcrete>(Func<TConcrete, object> closure)
{
That.Extend<TService, TConcrete>(closure);
}
/// <inheritdoc cref="ExtendContainer.Extend{TConcrete}(IContainer, Func{TConcrete, IContainer, object})"/>
public static void Extend<TService, TConcrete>(Func<TConcrete, IContainer, object> closure)
{
That.Extend<TService, TConcrete>(closure);
}
/// <inheritdoc cref="ExtendContainer.Extend{TService, TConcrete}(IContainer, Func{TConcrete, IContainer, object})"/>
public static void Extend<TConcrete>(Func<TConcrete, IContainer, object> closure)
{
That.Extend(closure);
}
/// <inheritdoc cref="ExtendContainer.Extend{TService, TConcrete}(IContainer, Func{TConcrete, object})"/>
public static void Extend<TConcrete>(Func<TConcrete, object> closure)
{
That.Extend(closure);
}
/// <inheritdoc cref="ExtendContainer.Bind{TService}(IContainer)"/>
public static IBindData Bind<TService>()
{
return That.Bind<TService>();
}
/// <inheritdoc cref="ExtendContainer.Bind{TService, TConcrete}(IContainer)"/>
public static IBindData Bind<TService, TConcrete>()
{
return That.Bind<TService, TConcrete>();
}
/// <inheritdoc cref="IContainer.Bind(string, Type, bool)"/>
public static IBindData Bind(string service, Type concrete, bool isStatic)
{
return That.Bind(service, concrete, isStatic);
}
/// <inheritdoc cref="IContainer.Bind(string, Func{IContainer, object[], object}, bool)"/>
public static IBindData Bind(string service, Func<IContainer, object[], object> concrete, bool isStatic)
{
return That.Bind(service, concrete, isStatic);
}
/// <inheritdoc cref="ExtendContainer.Bind(IContainer, Func{IContainer, object[], object})"/>
public static IBindData Bind<TService>(Func<IContainer, object[], object> concrete)
{
return That.Bind<TService>(concrete);
}
/// <inheritdoc cref="ExtendContainer.Bind{TService}(IContainer, Func{object[], object})"/>
public static IBindData Bind<TService>(Func<object[], object> concrete)
{
return That.Bind<TService>(concrete);
}
/// <inheritdoc cref="ExtendContainer.Bind{TService}(IContainer, Func{object})"/>
public static IBindData Bind<TService>(Func<object> concrete)
{
return That.Bind<TService>(concrete);
}
/// <inheritdoc cref="ExtendContainer.Bind(IContainer, string, Func{IContainer, object[], object})"/>
public static IBindData Bind(string service, Func<IContainer, object[], object> concrete)
{
return That.Bind(service, concrete);
}
/// <inheritdoc cref="IContainer.BindIf(string, Func{IContainer, object[], object}, bool, out IBindData)"/>
public static bool BindIf(string service, Func<IContainer, object[], object> concrete, bool isStatic, out IBindData bindData)
{
return That.BindIf(service, concrete, isStatic, out bindData);
}
/// <inheritdoc cref="IContainer.BindIf(string, Type, bool, out IBindData)"/>
public static bool BindIf(string service, Type concrete, bool isStatic, out IBindData bindData)
{
return That.BindIf(service, concrete, isStatic, out bindData);
}
/// <inheritdoc cref="ExtendContainer.BindIf{TService, TConcrete}(IContainer, out IBindData)"/>
public static bool BindIf<TService, TConcrete>(out IBindData bindData)
{
return That.BindIf<TService, TConcrete>(out bindData);
}
/// <inheritdoc cref="ExtendContainer.BindIf{TService}(IContainer, out IBindData)"/>
public static bool BindIf<TService>(out IBindData bindData)
{
return That.BindIf<TService>(out bindData);
}
/// <inheritdoc cref="ExtendContainer.BindIf{TService}(IContainer, Func{IContainer, object[], object}, out IBindData)"/>
public static bool BindIf<TService>(Func<IContainer, object[], object> concrete, out IBindData bindData)
{
return That.BindIf<TService>(concrete, out bindData);
}
/// <inheritdoc cref="ExtendContainer.BindIf{TService}(IContainer, Func{object[], object}, out IBindData)"/>
public static bool BindIf<TService>(Func<object[], object> concrete, out IBindData bindData)
{
return That.BindIf<TService>(concrete, out bindData);
}
/// <inheritdoc cref="ExtendContainer.BindIf{TService}(IContainer, Func{object}, out IBindData)"/>
public static bool BindIf<TService>(Func<object> concrete, out IBindData bindData)
{
return That.BindIf<TService>(concrete, out bindData);
}
/// <inheritdoc cref="ExtendContainer.BindIf(IContainer, string, Func{IContainer, object[], object}, out IBindData)"/>
public static bool BindIf(string service, Func<IContainer, object[], object> concrete, out IBindData bindData)
{
return That.BindIf(service, concrete, out bindData);
}
/// <inheritdoc cref="ExtendContainer.Singleton{TService, TConcrete}(IContainer)"/>
public static IBindData Singleton<TService, TConcrete>()
{
return That.Singleton<TService, TConcrete>();
}
/// <inheritdoc cref="ExtendContainer.Singleton{TService}(IContainer)"/>
public static IBindData Singleton<TService>()
{
return That.Singleton<TService>();
}
/// <inheritdoc cref="ExtendContainer.Singleton{TService}(IContainer, Func{IContainer, object[], object})"/>
public static IBindData Singleton<TService>(Func<IContainer, object[], object> concrete)
{
return That.Singleton<TService>(concrete);
}
/// <inheritdoc cref="ExtendContainer.Singleton{TService}(IContainer, Func{object[], object})"/>
public static IBindData Singleton<TService>(Func<object[], object> concrete)
{
return That.Singleton<TService>(concrete);
}
/// <inheritdoc cref="ExtendContainer.Singleton{TService}(IContainer, Func{object})"/>
public static IBindData Singleton<TService>(Func<object> concrete)
{
return That.Singleton<TService>(concrete);
}
/// <inheritdoc cref="ExtendContainer.Singleton(IContainer, string, Func{IContainer, object[], object})"/>
public static IBindData Singleton(string service, Func<IContainer, object[], object> concrete)
{
return That.Singleton(service, concrete);
}
/// <inheritdoc cref="ExtendContainer.SingletonIf{TService, TConcrete}(IContainer, out IBindData)"/>
public static bool SingletonIf<TService, TConcrete>(out IBindData bindData)
{
return That.SingletonIf<TService, TConcrete>(out bindData);
}
/// <inheritdoc cref="ExtendContainer.SingletonIf{TService}(IContainer, out IBindData)"/>
public static bool SingletonIf<TService>(out IBindData bindData)
{
return That.SingletonIf<TService>(out bindData);
}
/// <inheritdoc cref="ExtendContainer.SingletonIf{TService}(IContainer, Func{IContainer, object[], object}, out IBindData)"/>
public static bool SingletonIf<TService>(Func<IContainer, object[], object> concrete, out IBindData bindData)
{
return That.SingletonIf<TService>(concrete, out bindData);
}
/// <inheritdoc cref="ExtendContainer.SingletonIf{TService}(IContainer, Func{object[], object}, out IBindData)"/>
public static bool SingletonIf<TService>(Func<object[], object> concrete, out IBindData bindData)
{
return That.SingletonIf<TService>(concrete, out bindData);
}
/// <inheritdoc cref="ExtendContainer.SingletonIf{TService}(IContainer, Func{object}, out IBindData)"/>
public static bool SingletonIf<TService>(Func<object> concrete, out IBindData bindData)
{
return That.SingletonIf<TService>(concrete, out bindData);
}
/// <inheritdoc cref="ExtendContainer.SingletonIf(IContainer, string, Func{IContainer, object[], object}, out IBindData)"/>
public static bool SingletonIf(string service, Func<IContainer, object[], object> concrete, out IBindData bindData)
{
return That.SingletonIf(service, concrete, out bindData);
}
/// <inheritdoc cref="IContainer.BindMethod(string, object, MethodInfo)"/>
public static IMethodBind BindMethod(string method, object target, MethodInfo call)
{
return That.BindMethod(method, target, call);
}
/// <inheritdoc cref="ExtendContainer.BindMethod(IContainer, string, object, string)"/>
public static IMethodBind BindMethod(string method, object target,
string call = null)
{
return That.BindMethod(method, target, call);
}
/// <inheritdoc cref="ExtendContainer.BindMethod(IContainer, string, Func{object})"/>
public static IMethodBind BindMethod(string method, Func<object> callback)
{
return That.BindMethod(method, callback);
}
/// <inheritdoc cref="ExtendContainer.BindMethod{T1}(IContainer, string, Func{T1, object})"/>
public static IMethodBind BindMethod<T1>(string method, Func<T1, object> callback)
{
return That.BindMethod(method, callback);
}
/// <inheritdoc cref="ExtendContainer.BindMethod{T1, T2}(IContainer, string, Func{T1, T2, object})"/>
public static IMethodBind BindMethod<T1, T2>(string method, Func<T1, T2, object> callback)
{
return That.BindMethod(method, callback);
}
/// <inheritdoc cref="ExtendContainer.BindMethod{T1, T2, T3}(IContainer, string, Func{T1, T2, T3, object})"/>
public static IMethodBind BindMethod<T1, T2, T3>(string method, Func<T1, T2, T3, object> callback)
{
return That.BindMethod(method, callback);
}
/// <inheritdoc cref="ExtendContainer.BindMethod{T1, T2, T3, T4}(IContainer, string, Func{T1, T2, T3, T4, object})"/>
public static IMethodBind BindMethod<T1, T2, T3, T4>(string method, Func<T1, T2, T3, T4, object> callback)
{
return That.BindMethod(method, callback);
}
/// <inheritdoc cref="IContainer.Unbind(string)"/>
public static void Unbind(string service)
{
That.Unbind(service);
}
/// <inheritdoc cref="ExtendContainer.Unbind{TService}(IContainer)"/>
public static void Unbind<TService>()
{
That.Unbind<TService>();
}
/// <inheritdoc cref="IContainer.Tagged(string)"/>
public static object[] Tagged(string tag)
{
return That.Tagged(tag);
}
/// <inheritdoc cref="IContainer.Tag(string, string[])"/>
public static void Tag(string tag, params string[] service)
{
That.Tag(tag, service);
}
/// <inheritdoc cref="ExtendContainer.Tag{TService}(IContainer, string)"/>
public static void Tag<TService>(string tag)
{
That.Tag<TService>(tag);
}
/// <inheritdoc cref="IContainer.Instance(string, object)"/>
public static object Instance(string service, object instance)
{
return That.Instance(service, instance);
}
/// <inheritdoc cref="ExtendContainer.Instance{TService}(IContainer, object)"/>
public static void Instance<TService>(object instance)
{
That.Instance<TService>(instance);
}
/// <inheritdoc cref="IContainer.Release(object)"/>
public static bool Release(string service)
{
return That.Release(service);
}
/// <inheritdoc cref="ExtendContainer.Release{TService}(IContainer)"/>
public static bool Release<TService>()
{
return That.Release<TService>();
}
/// <inheritdoc cref="ExtendContainer.Release(IContainer, ref object[], bool)"/>
public static bool Release(ref object[] instances, bool reverse = true)
{
return That.Release(ref instances, reverse);
}
/// <inheritdoc cref="IContainer.Call(object, MethodInfo, object[])"/>
public static object Call(object instance, MethodInfo methodInfo, params object[] userParams)
{
return That.Call(instance, methodInfo, userParams);
}
/// <inheritdoc cref="ExtendContainer.Call(IContainer, object, string, object[])"/>
public static object Call(object instance, string method, params object[] userParams)
{
return That.Call(instance, method, userParams);
}
/// <inheritdoc cref="ExtendContainer.Call{T1}(IContainer, Action{T1}, object[])"/>
public static void Call<T1>(Action<T1> method, params object[] userParams)
{
That.Call(method, userParams);
}
/// <inheritdoc cref="ExtendContainer.Call{T1, T2}(IContainer, Action{T1, T2}, object[])"/>
public static void Call<T1, T2>(Action<T1, T2> method, params object[] userParams)
{
That.Call(method, userParams);
}
/// <inheritdoc cref="ExtendContainer.Call{T1, T2, T3}(IContainer, Action{T1, T2, T3}, object[])"/>
public static void Call<T1, T2, T3>(Action<T1, T2, T3> method, params object[] userParams)
{
That.Call(method, userParams);
}
/// <inheritdoc cref="ExtendContainer.Call{T1, T2, T3, T4}(IContainer, Action{T1, T2, T3, T4}, object[])"/>
public static void Call<T1, T2, T3, T4>(Action<T1, T2, T3, T4> method, params object[] userParams)
{
That.Call(method, userParams);
}
/// <inheritdoc cref="ExtendContainer.Wrap{T1}(IContainer, Action{T1}, object[])"/>
public static Action Wrap<T1>(Action<T1> method, params object[] userParams)
{
return That.Wrap(method, userParams);
}
/// <inheritdoc cref="ExtendContainer.Wrap{T1, T2}(IContainer, Action{T1, T2}, object[])"/>
public static Action Wrap<T1, T2>(Action<T1, T2> method, params object[] userParams)
{
return That.Wrap(method, userParams);
}
/// <inheritdoc cref="ExtendContainer.Wrap{T1, T2, T3}(IContainer, Action{T1, T2, T3}, object[])"/>
public static Action Wrap<T1, T2, T3>(Action<T1, T2, T3> method, params object[] userParams)
{
return That.Wrap(method, userParams);
}
/// <inheritdoc cref="ExtendContainer.Wrap{T1, T2, T3, T4}(IContainer, Action{T1, T2, T3, T4}, object[])"/>
public static Action Wrap<T1, T2, T3, T4>(Action<T1, T2, T3, T4> method, params object[] userParams)
{
return That.Wrap(method, userParams);
}
/// <inheritdoc cref="IContainer.Make(string, object[])"/>
public static object Make(string service, params object[] userParams)
{
return That.Make(service, userParams);
}
/// <inheritdoc cref="ExtendContainer.Make{TService}(IContainer, object[])"/>
public static TService Make<TService>(params object[] userParams)
{
#if CATLIB_PERFORMANCE
return Facade<TService>.Make(userParams);
#else
return That.Make<TService>(userParams);
#endif
}
/// <inheritdoc cref="ExtendContainer.Make(IContainer, Type, object[])"/>
public static object Make(Type type, params object[] userParams)
{
return That.Make(type, userParams);
}
/// <inheritdoc cref="ExtendContainer.Factory(IContainer, string, object[])"/>
public static Func<object> Factory(string service, params object[] userParams)
{
return That.Factory(service, userParams);
}
/// <inheritdoc cref="ExtendContainer.Factory{TService}(IContainer, object[])"/>
public static Func<TService> Factory<TService>(params object[] userParams)
{
return That.Factory<TService>(userParams);
}
/// <inheritdoc cref="IContainer.OnRelease(Action{IBindData, object})"/>
public static IContainer OnRelease(Action<IBindData, object> action)
{
return That.OnRelease(action);
}
/// <inheritdoc cref="ExtendContainer.OnRelease(IContainer, Action{object})"/>
public static IContainer OnRelease(Action<object> callback)
{
return That.OnRelease(callback);
}
/// <inheritdoc cref="ExtendContainer.OnRelease{T}(IContainer, Action{T})"/>
public static IContainer OnRelease<TWhere>(Action<TWhere> closure)
{
return That.OnRelease(closure);
}
/// <inheritdoc cref="ExtendContainer.OnRelease{T}(IContainer, Action{IBindData, T})"/>
public static IContainer OnRelease<TWhere>(Action<IBindData, TWhere> closure)
{
return That.OnRelease(closure);
}
/// <inheritdoc cref="IContainer.OnResolving(Action{IBindData, object})"/>
public static IContainer OnResolving(Action<IBindData, object> closure)
{
return That.OnResolving(closure);
}
/// <inheritdoc cref="ExtendContainer.OnRelease(IContainer, Action{object})"/>
public static IContainer OnResolving(Action<object> callback)
{
return That.OnResolving(callback);
}
/// <inheritdoc cref="ExtendContainer.OnResolving{T}(IContainer, Action{T})"/>
public static IContainer OnResolving<TWhere>(Action<TWhere> closure)
{
return That.OnResolving(closure);
}
/// <inheritdoc cref="ExtendContainer.OnResolving{T}(IContainer, Action{IBindData, T})"/>
public static IContainer OnResolving<TWhere>(Action<IBindData, TWhere> closure)
{
return That.OnResolving(closure);
}
/// <inheritdoc cref="IContainer.OnAfterResolving(Action{IBindData, object})"/>
public static IContainer OnAfterResolving(Action<IBindData, object> closure)
{
return That.OnAfterResolving(closure);
}
/// <inheritdoc cref="ExtendContainer.OnAfterResolving(IContainer, Action{object})"/>
public static IContainer OnAfterResolving(Action<object> closure)
{
return That.OnAfterResolving(closure);
}
/// <inheritdoc cref="ExtendContainer.OnAfterResolving{T}(IContainer, Action{T})"/>
public static IContainer OnAfterResolving<TWhere>(Action<TWhere> closure)
{
return That.OnAfterResolving(closure);
}
/// <inheritdoc cref="ExtendContainer.OnAfterResolving{T}(IContainer, Action{IBindData, T})"/>
public static IContainer OnAfterResolving<TWhere>(Action<IBindData, TWhere> closure)
{
return That.OnAfterResolving(closure);
}
/// <inheritdoc cref="ExtendContainer.Watch{TService}(IContainer, Action)"/>
public static void Watch<TService>(Action method)
{
That.Watch<TService>(method);
}
/// <inheritdoc cref="ExtendContainer.Watch{TService}(IContainer, Action{TService})"/>
public static void Watch<TService>(Action<TService> method)
{
That.Watch(method);
}
/// <inheritdoc cref="IContainer.Type2Service(Type)"/>
public static string Type2Service(Type type)
{
return That.Type2Service(type);
}
/// <inheritdoc cref="ExtendContainer.Type2Service{TService}(IContainer)"/>
public static string Type2Service<TService>()
{
return That.Type2Service<TService>();
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Application.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using CatLib.Container;
using CatLib.EventDispatcher;
using CatLib.Exception;
using CatLib.Util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
namespace CatLib
{
/// <summary>
/// The CatLib <see cref="Application"/> instance.
/// </summary>
public class Application : Container.Container, IApplication
{
private static string version;
private readonly IList<IServiceProvider> loadedProviders;
private readonly int mainThreadId;
private readonly IDictionary<Type, string> dispatchMapping;
private bool bootstrapped;
private bool inited;
private bool registering;
private long incrementId;
private DebugLevel debugLevel;
private IEventDispatcher dispatcher;
/// <summary>
/// Initializes a new instance of the <see cref="Application"/> class.
/// </summary>
/// <param name="global">True if sets the instance to <see cref="App"/> facade.</param>
public Application()
{
loadedProviders = new List<IServiceProvider>();
mainThreadId = Thread.CurrentThread.ManagedThreadId;
RegisterBaseBindings();
dispatchMapping = new Dictionary<Type, string>()
{
{ typeof(AfterBootEventArgs), ApplicationEvents.OnAfterBoot },
{ typeof(AfterInitEventArgs), ApplicationEvents.OnAfterInit },
{ typeof(AfterTerminateEventArgs), ApplicationEvents.OnAfterTerminate },
{ typeof(BeforeBootEventArgs), ApplicationEvents.OnBeforeBoot },
{ typeof(BeforeInitEventArgs), ApplicationEvents.OnBeforeInit },
{ typeof(BeforeTerminateEventArgs), ApplicationEvents.OnBeforeTerminate },
{ typeof(BootingEventArgs), ApplicationEvents.OnBooting },
{ typeof(InitProviderEventArgs), ApplicationEvents.OnInitProvider },
{ typeof(RegisterProviderEventArgs), ApplicationEvents.OnRegisterProvider },
{ typeof(StartCompletedEventArgs), ApplicationEvents.OnStartCompleted },
};
// We use closures to save the current context state
// Do not change to: OnFindType(Type.GetType) This
// causes the active assembly to be not the expected scope.
OnFindType(finder => { return Type.GetType(finder); });
DebugLevel = DebugLevel.Production;
Process = StartProcess.Construct;
}
/// <summary>
/// Gets the CatLib <see cref="Application"/> version.
/// </summary>
public static string Version => version ?? (version = FileVersionInfo
.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion);
/// <summary>
/// Gets indicates the application startup process.
/// </summary>
public StartProcess Process { get; private set; }
/// <inheritdoc />
public bool IsMainThread => mainThreadId == Thread.CurrentThread.ManagedThreadId;
/// <inheritdoc />
public DebugLevel DebugLevel
{
get => debugLevel;
set
{
debugLevel = value;
this.Instance<DebugLevel>(debugLevel);
}
}
/// <inheritdoc cref="Application(bool)"/>
/// <returns>The CatLib <see cref="Application"/> instance.</returns>
public static Application New(bool global = true)
{
var application = new Application();
if (global)
{
App.That = application;
}
return application;
}
/// <summary>
/// Sets the event dispatcher.
/// </summary>
/// <param name="dispatcher">The event dispatcher instance.</param>
public void SetDispatcher(IEventDispatcher dispatcher)
{
this.dispatcher = dispatcher;
this.Instance<IEventDispatcher>(dispatcher);
}
/// <inheritdoc />
public IEventDispatcher GetDispatcher()
{
return dispatcher;
}
/// <inheritdoc />
public virtual void Terminate()
{
Process = StartProcess.Terminate;
Raise(new BeforeTerminateEventArgs(this));
Process = StartProcess.Terminating;
Flush();
if (App.That == this)
{
App.That = null;
}
Process = StartProcess.Terminated;
Raise(new AfterTerminateEventArgs(this));
}
/// <summary>
/// Bootstrap the given array of bootstrap classes.
/// </summary>
/// <param name="bootstraps">The given bootstrap classes.</param>
public virtual void Bootstrap(params IBootstrap[] bootstraps)
{
Guard.Requires<ArgumentNullException>(bootstraps != null);
if (bootstrapped || Process != StartProcess.Construct)
{
throw new LogicException($"Cannot repeatedly trigger the {nameof(Bootstrap)}()");
}
Process = StartProcess.Bootstrap;
bootstraps = Raise(new BeforeBootEventArgs(bootstraps, this))
.GetBootstraps();
Process = StartProcess.Bootstrapping;
var existed = new HashSet<IBootstrap>();
foreach (var bootstrap in bootstraps)
{
if (bootstrap == null)
{
continue;
}
if (existed.Contains(bootstrap))
{
throw new LogicException($"The bootstrap already exists : {bootstrap}");
}
existed.Add(bootstrap);
var skipped = Raise(new BootingEventArgs(bootstrap, this))
.IsSkip;
if (!skipped)
{
bootstrap.Bootstrap();
}
}
Process = StartProcess.Bootstraped;
bootstrapped = true;
Raise(new AfterBootEventArgs(this));
}
/// <summary>
/// Init all of the registered service provider.
/// </summary>
public virtual void Init()
{
if (!bootstrapped)
{
throw new LogicException($"You must call {nameof(Bootstrap)}() first.");
}
if (inited || Process != StartProcess.Bootstraped)
{
throw new LogicException($"Cannot repeatedly trigger the {nameof(Init)}()");
}
Process = StartProcess.Init;
Raise(new BeforeInitEventArgs(this));
Process = StartProcess.Initing;
foreach (var provider in loadedProviders)
{
InitProvider(provider);
}
inited = true;
Process = StartProcess.Inited;
Raise(new AfterInitEventArgs(this));
Process = StartProcess.Running;
Raise(new StartCompletedEventArgs(this));
}
/// <inheritdoc />
public virtual void Register(IServiceProvider provider, bool force = false)
{
Guard.Requires<ArgumentNullException>(provider != null, $"Parameter \"{nameof(provider)}\" can not be null.");
if (IsRegistered(provider))
{
if (!force)
{
throw new LogicException($"Provider [{provider.GetType()}] is already register.");
}
loadedProviders.Remove(provider);
}
if (Process == StartProcess.Initing)
{
throw new LogicException($"Unable to add service provider during {nameof(StartProcess.Initing)}");
}
if (Process > StartProcess.Running)
{
throw new LogicException($"Unable to {nameof(Terminate)} in-process registration service provider");
}
if (provider is ServiceProvider baseProvider)
{
baseProvider.SetApplication(this);
}
var skipped = Raise(new RegisterProviderEventArgs(provider, this))
.IsSkip;
if (skipped)
{
return;
}
try
{
registering = true;
provider.Register();
}
finally
{
registering = false;
}
loadedProviders.Add(provider);
if (inited)
{
InitProvider(provider);
}
}
/// <inheritdoc />
public bool IsRegistered(IServiceProvider provider)
{
Guard.Requires<ArgumentNullException>(provider != null);
return loadedProviders.Contains(provider);
}
/// <inheritdoc />
public long GetRuntimeId()
{
return Interlocked.Increment(ref incrementId);
}
/// <summary>
/// Initialize the specified service provider.
/// </summary>
/// <param name="provider">The specified service provider.</param>
protected virtual void InitProvider(IServiceProvider provider)
{
Raise(new InitProviderEventArgs(provider, this));
provider.Init();
}
/// <inheritdoc />
protected override void GuardConstruct(string method)
{
if (registering)
{
throw new LogicException(
$"It is not allowed to make services or dependency injection in the {nameof(Register)} process, method:{method}");
}
base.GuardConstruct(method);
}
private void RegisterBaseBindings()
{
this.Singleton<IApplication>(() => this).Alias<Application>().Alias<IContainer>();
SetDispatcher(new EventDispatcher.EventDispatcher());
}
private T Raise<T>(T args)
where T : EventArgs
{
if (!dispatchMapping.TryGetValue(args.GetType(), out string eventName))
{
throw new AssertException($"Assertion error: Undefined event {args}");
}
if (dispatcher == null)
{
return args;
}
dispatcher.Raise(eventName, this, args);
return args;
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/DebugLevel.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// Indicates the framework debug level.
/// </summary>
public enum DebugLevel
{
/// <summary>
/// Production environment
/// </summary>
Production,
/// <summary>
/// Between the production environment and the developer environment
/// </summary>
Staging,
/// <summary>
/// Development environment
/// </summary>
Development,
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/AfterBootEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// Indicates that the bootstrap has been booted.
/// </summary>
public class AfterBootEventArgs : ApplicationEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AfterBootEventArgs"/> class.
/// </summary>
/// <param name="application">The application instance.</param>
public AfterBootEventArgs(IApplication application)
: base(application)
{
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/AfterInitEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// Indicates that all the <see cref="IServiceProvider.Init"/> has been called.
/// </summary>
public class AfterInitEventArgs : ApplicationEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AfterInitEventArgs"/> class.
/// </summary>
/// <param name="application">The application instance.</param>
public AfterInitEventArgs(IApplication application)
: base(application)
{
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/AfterTerminateEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// Indicates that the framework will terminate.
/// </summary>
public class AfterTerminateEventArgs : ApplicationEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="AfterTerminateEventArgs"/> class.
/// </summary>
/// <param name="application">The terminate application instance.</param>
public AfterTerminateEventArgs(IApplication application)
: base(application)
{
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/ApplicationEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using System;
namespace CatLib
{
/// <summary>
/// Represents an application event.
/// </summary>
public class ApplicationEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationEventArgs"/> class.
/// </summary>
/// <param name="application">The application instance.</param>
public ApplicationEventArgs(IApplication application)
{
Application = application;
}
/// <summary>
/// Gets the application instance.
/// </summary>
public IApplication Application { get; private set; }
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/ApplicationEvents.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// Contains all events dispatched by an Application.
/// </summary>
public static class ApplicationEvents
{
/// <summary>
/// Before the <see cref="Application.Bootstrap"/> call.
/// </summary>
public static readonly string OnBeforeBoot = $"{BaseEventArgs}.OnBeforeBoot";
/// <summary>
/// When the <see cref="Application.Bootstrap"/> call is in progress.
/// </summary>
public static readonly string OnBooting = $"{BaseEventArgs}.BootingEventArgs";
/// <summary>
/// After the <see cref="Application.Bootstrap"/> called.
/// </summary>
public static readonly string OnAfterBoot = $"{BaseEventArgs}.AfterBootEventArgs";
/// <summary>
/// When registering for a service provider.
/// </summary>
public static readonly string OnRegisterProvider = $"{BaseEventArgs}.RegisterProviderEventArgs";
/// <summary>
/// Before the <see cref="Application.Init"/> call.
/// </summary>
public static readonly string OnBeforeInit = $"{BaseEventArgs}.BeforeInitEventArgs";
/// <summary>
/// Before the <see cref="IServiceProvider.Init"/> call.
/// </summary>
public static readonly string OnInitProvider = $"{BaseEventArgs}.InitProviderEventArgs";
/// <summary>
/// After the <see cref="Application.Init"/> called.
/// </summary>
public static readonly string OnAfterInit = $"{BaseEventArgs}.AfterInitEventArgs";
/// <summary>
/// When the framework is started.
/// </summary>
public static readonly string OnStartCompleted = $"{BaseEventArgs}.StartCompletedEventArgs";
/// <summary>
/// Before the <see cref="Application.Terminate"/> call.
/// </summary>
public static readonly string OnBeforeTerminate = $"{BaseEventArgs}.BeforeTerminateEventArgs";
/// <summary>
/// After the <see cref="Application.Terminate"/> called.
/// </summary>
public static readonly string OnAfterTerminate = $"{BaseEventArgs}.AfterTerminateEventArgs";
private const string BaseEventArgs = "EventArgs.ApplicationEventArgs";
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/BeforeBootEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// It indicates that the bootstrap will be bootstrapped.
/// </summary>
public class BeforeBootEventArgs : ApplicationEventArgs
{
private IBootstrap[] bootstraps;
/// <summary>
/// Initializes a new instance of the <see cref="BeforeBootEventArgs"/> class.
/// </summary>
/// <param name="bootstraps">An array of the bootstrap list.</param>
/// <param name="application">The application instance.</param>
public BeforeBootEventArgs(IBootstrap[] bootstraps, IApplication application)
: base(application)
{
this.bootstraps = bootstraps;
}
/// <summary>
/// Gets an array of bootstrap will be bootstrapped.
/// </summary>
/// <returns>Returns an array of bootstraps.</returns>
public IBootstrap[] GetBootstraps()
{
return bootstraps;
}
/// <summary>
/// Sets the bootstrap will replace the old boot list.
/// </summary>
/// <param name="bootstraps">New bootstrap list.</param>
public void SetBootstraps(IBootstrap[] bootstraps)
{
this.bootstraps = bootstraps;
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/BeforeInitEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// It indicates that the <see cref="IServiceProvider.Init"/> method will be called.
/// </summary>
public class BeforeInitEventArgs : ApplicationEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="BeforeInitEventArgs"/> class.
/// </summary>
/// <param name="bootstraps">An array of the bootstrap list.</param>
/// <param name="application">The application instance.</param>
public BeforeInitEventArgs(IApplication application)
: base(application)
{
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/BeforeTerminateEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// Indicates that the framework will terminate.
/// </summary>
public class BeforeTerminateEventArgs : ApplicationEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="BeforeTerminateEventArgs"/> class.
/// </summary>
/// <param name="application">The terminate application instance.</param>
public BeforeTerminateEventArgs(IApplication application)
: base(application)
{
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/BootingEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using CatLib.EventDispatcher;
namespace CatLib
{
/// <summary>
/// Indicates a boot class that is booting.
/// </summary>
public class BootingEventArgs : ApplicationEventArgs, IStoppableEvent
{
private readonly IBootstrap bootstrap;
/// <summary>
/// Initializes a new instance of the <see cref="BootingEventArgs"/> class.
/// </summary>
/// <param name="bootstrap">The boot class that is booting.</param>
/// <param name="application">The application instance.</param>
public BootingEventArgs(IBootstrap bootstrap, IApplication application)
: base(application)
{
IsSkip = false;
this.bootstrap = bootstrap;
}
/// <summary>
/// Gets a value indicating whether the boot class is skip booting.
/// </summary>
public bool IsSkip { get; private set; }
/// <inheritdoc />
public bool IsPropagationStopped => IsSkip;
/// <summary>
/// Gets the a boot class that is booting.
/// </summary>
/// <returns>Return the boot class.</returns>
public IBootstrap GetBootstrap()
{
return bootstrap;
}
/// <summary>
/// Disable the boot class.
/// </summary>
public void Skip()
{
IsSkip = true;
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/InitProviderEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// Indicates a service provider that will inited.
/// </summary>
public class InitProviderEventArgs : ApplicationEventArgs
{
private readonly IServiceProvider provider;
/// <summary>
/// Initializes a new instance of the <see cref="InitProviderEventArgs"/> class.
/// </summary>
/// <param name="provider">The service provider class that will inited.</param>
/// <param name="application">The application instance.</param>
public InitProviderEventArgs(IServiceProvider provider, IApplication application)
: base(application)
{
this.provider = provider;
}
/// <summary>
/// Gets the a service provider class that will inited.
/// </summary>
/// <returns>Return the service provider class.</returns>
public IServiceProvider GetServiceProvider()
{
return provider;
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/RegisterProviderEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using CatLib.EventDispatcher;
namespace CatLib
{
/// <summary>
/// Indicates a service provider that will register.
/// </summary>
public class RegisterProviderEventArgs : ApplicationEventArgs, IStoppableEvent
{
private readonly IServiceProvider provider;
/// <summary>
/// Initializes a new instance of the <see cref="RegisterProviderEventArgs"/> class.
/// </summary>
/// <param name="provider">The service provider class that will register.</param>
/// <param name="application">The application instance.</param>
public RegisterProviderEventArgs(IServiceProvider provider, IApplication application)
: base(application)
{
IsSkip = false;
this.provider = provider;
}
/// <summary>
/// Gets a value indicating whether the service provider is skip register.
/// </summary>
public bool IsSkip { get; private set; }
/// <inheritdoc />
public bool IsPropagationStopped => IsSkip;
/// <summary>
/// Gets the a service provider class that will register.
/// </summary>
/// <returns>Return the service provider class.</returns>
public IServiceProvider GetServiceProvider()
{
return provider;
}
/// <summary>
/// Skip the register service provider.
/// </summary>
public void Skip()
{
IsSkip = true;
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Events/StartCompletedEventArgs.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// Indicates that the framework ready.
/// </summary>
public class StartCompletedEventArgs : ApplicationEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="StartCompletedEventArgs"/> class.
/// </summary>
/// <param name="application">The application instance.</param>
public StartCompletedEventArgs(IApplication application)
: base(application)
{
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/Facade.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
#pragma warning disable CA1000
#pragma warning disable S2743
#pragma warning disable S1118
using CatLib.Container;
namespace CatLib
{
/// <summary>
/// <see cref="Facade{TService}"/> is the abstract implemented by all facade classes.
/// </summary>
/// <typeparam name="TService">The service type.</typeparam>
/// <remarks>
/// <code>public class FileSystem : Facade>IFileSystem<{ }</code>
/// </remarks>
public abstract class Facade<TService>
{
private static readonly string Service;
private static TService that;
private static IBindData binder;
private static bool inited;
private static bool released;
/// <summary>
/// Initializes static members of the <see cref="Facade{TService}"/> class.
/// </summary>
#pragma warning disable S3963
static Facade()
#pragma warning restore S3963
{
Service = App.Type2Service(typeof(TService));
App.OnNewApplication += app =>
{
that = default;
binder = null;
inited = false;
released = false;
};
}
/// <inheritdoc cref="that"/>
public static TService That => HasInstance ? that : Resolve();
/// <summary>
/// Gets a value indicating whether the resolved instance is exists in the facade.
/// <para>If it is a non-static binding then return forever false.</para>
/// </summary>
internal static bool HasInstance => binder != null && binder.IsStatic && !released && that != null;
/// <summary>
/// Resolve the object instance.
/// </summary>
/// <param name="userParams">The user parameters.</param>
/// <returns>The resolved object.</returns>
internal static TService Make(params object[] userParams)
{
return HasInstance ? that : Resolve(userParams);
}
/// <inheritdoc cref="Make"/>
private static TService Resolve(params object[] userParams)
{
released = false;
if (!inited && (App.IsResolved(Service) || App.CanMake(Service)))
{
App.Watch<TService>(ServiceRebound);
inited = true;
}
else if (binder != null && !binder.IsStatic)
{
// If it has been initialized, the binder has been initialized.
// Then judging in advance can optimize performance without
// going through a hash lookup.
return Build(userParams);
}
var newBinder = App.GetBind(Service);
if (newBinder == null || !newBinder.IsStatic)
{
binder = newBinder;
return Build(userParams);
}
Rebind(newBinder);
return that = Build(userParams);
}
/// <summary>
/// When the resolved object is released.
/// </summary>
/// <param name="oldBinder">The old bind data with resolved object.</param>
/// <param name="instance">The ignored parameter.</param>
private static void OnRelease(IBindData oldBinder, object instance)
{
if (oldBinder != binder)
{
return;
}
that = default;
released = true;
}
/// <summary>
/// When the resolved object is rebound.
/// </summary>
/// <param name="newService">The new resolved object.</param>
private static void ServiceRebound(TService newService)
{
var newBinder = App.GetBind(Service);
Rebind(newBinder);
that = (newBinder == null || !newBinder.IsStatic) ? default : newService;
}
/// <summary>
/// Rebinding the bound data to given binder.
/// </summary>
/// <param name="newBinder">The new binder.</param>
private static void Rebind(IBindData newBinder)
{
if (newBinder != null && binder != newBinder && newBinder.IsStatic)
{
newBinder.OnRelease(OnRelease);
}
binder = newBinder;
}
/// <summary>
/// Resolve facade object from the container.
/// </summary>
/// <param name="userParams">The user parameters.</param>
/// <returns>The resolved object.</returns>
private static TService Build(params object[] userParams)
{
return (TService)App.Make(Service, userParams);
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/IApplication.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this sender code.
*
* Document: https://catlib.io/
*/
using CatLib.Container;
using CatLib.EventDispatcher;
namespace CatLib
{
/// <summary>
/// <see cref="IApplication"/> is the interface implemented by all application classes.
/// </summary>
public interface IApplication : IContainer
{
/// <summary>
/// Gets a value indicating whether true if we're on the main thread.
/// </summary>
bool IsMainThread { get; }
/// <summary>
/// Gets or sets the debug level.
/// </summary>
DebugLevel DebugLevel { get; set; }
/// <summary>
/// Gets the event dispatcher.
/// </summary>
/// <returns>Returns event dispatcher instance, null if the dispatcher not found.</returns>
IEventDispatcher GetDispatcher();
/// <summary>
/// Register a service provider with the application.
/// </summary>
/// <param name="provider">The service provider.</param>
/// <param name="force">True if the force register.</param>
void Register(IServiceProvider provider, bool force = false);
/// <summary>
/// Checks whether the given service provider is registered.
/// </summary>
/// <param name="provider">The service provider.</param>
/// <returns>True if the service provider is registered.</returns>
bool IsRegistered(IServiceProvider provider);
/// <summary>
/// Gets the unique runtime id.
/// </summary>
/// <returns>The unique runtime id.</returns>
long GetRuntimeId();
/// <summary>
/// Terminates the <see cref="IApplication"/>.
/// </summary>
void Terminate();
}
}
================================================
FILE: src/CatLib.Core/CatLib/IBootstrap.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// <see cref="IBootstrap"/> is the interface implemented by all bootstrap classes.
/// </summary>
public interface IBootstrap
{
/// <summary>
/// Bootstrap the framework.
/// </summary>
void Bootstrap();
}
}
================================================
FILE: src/CatLib.Core/CatLib/IServiceProvider.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// <see cref="IServiceProvider"/> is the interface implemented by all service provider classes.
/// </summary>
public interface IServiceProvider
{
/// <summary>
/// Initialize the application's service providers.
/// </summary>
void Init();
/// <summary>
/// Register any application services.
/// </summary>
void Register();
}
}
================================================
FILE: src/CatLib.Core/CatLib/ServiceProvider.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using System.Diagnostics.CodeAnalysis;
namespace CatLib
{
/// <summary>
/// <see cref="ServiceProvider"/> is default service provider class
/// for all concrete ServiceProvider classes.
/// </summary>
[ExcludeFromCodeCoverage]
public abstract class ServiceProvider : IServiceProvider
{
/// <summary>
/// Gets application instance.
/// </summary>
protected IApplication App { get; private set; }
/// <inheritdoc />
public virtual void Init()
{
}
/// <inheritdoc />
public virtual void Register()
{
}
internal void SetApplication(IApplication application)
{
App = application;
}
}
}
================================================
FILE: src/CatLib.Core/CatLib/StartProcess.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
namespace CatLib
{
/// <summary>
/// The framework start process type.
/// </summary>
public enum StartProcess
{
/// <summary>
/// When you create a new <see cref="Application"/>,
/// you are in the <see cref="Construct"/> phase.
/// </summary>
Construct = 0,
/// <summary>
/// Before the <see cref="Application.Bootstrap"/> call.
/// </summary>
Bootstrap = 1,
/// <summary>
/// When during <see cref="Application.Bootstrap"/> execution,
/// you are in the <see cref="Bootstrapping"/> phase.
/// </summary>
Bootstrapping = 2,
/// <summary>
/// After the <see cref="Application.Bootstrap"/> called.
/// </summary>
Bootstraped = 3,
/// <summary>
/// Before the <see cref="Application.Init"/> call.
/// </summary>
Init = 4,
/// <summary>
/// When during <see cref="Application.Init"/> execution,
/// you are in the <see cref="Initing"/> phase.
/// </summary>
Initing = 5,
/// <summary>
/// After the <see cref="Application.Init"/> called.
/// </summary>
Inited = 6,
/// <summary>
/// When the framework running.
/// </summary>
Running = 7,
/// <summary>
/// Before the <see cref="Application.Terminate"/> call.
/// </summary>
Terminate = 8,
/// <summary>
/// When during <see cref="Application.Terminate"/> execution,
/// you are in the <see cref="Terminating"/> phase.
/// </summary>
Terminating = 9,
/// <summary>
/// After the <see cref="Application.Terminate"/> called.
/// All resources are destroyed.
/// </summary>
Terminated = 10,
}
}
================================================
FILE: src/CatLib.Core/CatLib.Core.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>2.0.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>CatLib</Authors>
<Company>CatLib</Company>
<Description>CatLib lightweight dependency injection container</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/CatLib/Core</PackageProjectUrl>
<RepositoryUrl>https://github.com/CatLib/Core</RepositoryUrl>
<RepositoryType>github</RepositoryType>
<PackageTags>catlib, ioc, inject, framework</PackageTags>
</PropertyGroup>
</Project>
================================================
FILE: src/CatLib.Core/Container/BindData.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using CatLib.Exception;
using CatLib.Util;
using System;
using System.Collections.Generic;
using CatLibContainer = CatLib.Container.Container;
namespace CatLib.Container
{
/// <inheritdoc cref="IBindData"/>
public sealed class BindData : Bindable<IBindData>, IBindData
{
/// <summary>
/// The local resolving callbacks.
/// </summary>
private List<Action<IBindData, object>> resolving;
/// <summary>
/// The local after resolving callbacks.
/// </summary>
private List<Action<IBindData, object>> afterResolving;
/// <summary>
/// The local release callbacks.
/// </summary>
private List<Action<IBindData, object>> release;
/// <summary>
/// Initializes a new instance of the <see cref="BindData"/> class.
/// </summary>
/// <param name="container">The container instance.</param>
/// <param name="service">The service name.</param>
/// <param name="concrete">The service concrete.</param>
/// <param name="isStatic">Whether the service is singleton(static).</param>
public BindData(CatLibContainer container, string service, Func<IContainer, object[], object> concrete, bool isStatic)
: base(container, service)
{
Concrete = concrete;
IsStatic = isStatic;
}
/// <inheritdoc />
public Func<IContainer, object[], object> Concrete { get; }
/// <inheritdoc />
public bool IsStatic { get; }
/// <inheritdoc />
public IBindData Alias(string alias)
{
AssertDestroyed();
Guard.ParameterNotNull(alias, nameof(alias));
Container.Alias(alias, Service);
return this;
}
/// <inheritdoc />
public IBindData Tag(string tag)
{
AssertDestroyed();
Guard.ParameterNotNull(tag, nameof(tag));
Container.Tag(tag, Service);
return this;
}
/// <inheritdoc />
public IBindData OnResolving(Action<IBindData, object> closure)
{
AddClosure(closure, ref resolving);
return this;
}
/// <inheritdoc />
public IBindData OnAfterResolving(Action<IBindData, object> closure)
{
AddClosure(closure, ref afterResolving);
return this;
}
/// <inheritdoc />
public IBindData OnRelease(Action<IBindData, object> closure)
{
if (!IsStatic)
{
throw new LogicException(
$"Service [{Service}] is not Singleton(Static) Bind , Can not call {nameof(OnRelease)}().");
}
AddClosure(closure, ref release);
return this;
}
internal object TriggerResolving(object instance)
{
return CatLibContainer.Trigger(this, instance, resolving);
}
internal object TriggerAfterResolving(object instance)
{
return CatLibContainer.Trigger(this, instance, afterResolving);
}
internal object TriggerRelease(object instance)
{
return CatLibContainer.Trigger(this, instance, release);
}
/// <inheritdoc />
protected override void ReleaseBind()
{
((CatLibContainer)Container).Unbind(this);
}
private void AddClosure(Action<IBindData, object> closure, ref List<Action<IBindData, object>> collection)
{
Guard.Requires<ArgumentNullException>(closure != null);
AssertDestroyed();
if (collection == null)
{
collection = new List<Action<IBindData, object>>();
}
collection.Add(closure);
}
}
}
================================================
FILE: src/CatLib.Core/Container/BindDataExtension.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using CatLib.Util;
using System;
namespace CatLib.Container
{
/// <summary>
/// An extension function for <see cref="BindData"/>.
/// </summary>
public static class BindDataExtension
{
/// <inheritdoc cref="IBindData.Alias"/>
/// <typeparam name="TAlias">The type convert to alias name.</typeparam>
public static IBindData Alias<TAlias>(this IBindData bindData)
{
return bindData.Alias(bindData.Container.Type2Service(typeof(TAlias)));
}
/// <inheritdoc cref="IBindData.OnResolving"/>
public static IBindData OnResolving(this IBindData bindData, Action closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnResolving((_, instance) =>
{
closure();
});
}
/// <inheritdoc cref="IBindData.OnResolving"/>
public static IBindData OnResolving(this IBindData bindData, Action<object> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnResolving((_, instance) =>
{
closure(instance);
});
}
/// <inheritdoc cref="IBindData.OnResolving"/>
/// <typeparam name="T">The type of resolve instance.</typeparam>
public static IBindData OnResolving<T>(this IBindData bindData, Action<T> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnResolving((_, instance) =>
{
if (instance is T)
{
closure((T)instance);
}
});
}
/// <inheritdoc cref="OnResolving{T}(IBindData, Action{T})"/>
public static IBindData OnResolving<T>(this IBindData bindData, Action<IBindData, T> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnResolving((bind, instance) =>
{
if (instance is T)
{
closure(bind, (T)instance);
}
});
}
/// <inheritdoc cref="IBindData.OnAfterResolving"/>
public static IBindData OnAfterResolving(this IBindData bindData, Action closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnAfterResolving((_, instance) =>
{
closure();
});
}
/// <inheritdoc cref="IBindData.OnAfterResolving"/>
public static IBindData OnAfterResolving(this IBindData bindData, Action<object> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnAfterResolving((_, instance) =>
{
closure(instance);
});
}
/// <inheritdoc cref="IBindData.OnAfterResolving"/>
/// <typeparam name="T">The type of resolve instance.</typeparam>
public static IBindData OnAfterResolving<T>(this IBindData bindData, Action<T> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnAfterResolving((_, instance) =>
{
if (instance is T)
{
closure((T)instance);
}
});
}
/// <inheritdoc cref="OnAfterResolving{T}(IBindData, Action{T})"/>
public static IBindData OnAfterResolving<T>(this IBindData bindData, Action<IBindData, T> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnAfterResolving((bind, instance) =>
{
if (instance is T)
{
closure(bind, (T)instance);
}
});
}
/// <inheritdoc cref="IBindData.OnRelease"/>
public static IBindData OnRelease(this IBindData bindData, Action closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnRelease((_, __) =>
{
closure();
});
}
/// <inheritdoc cref="IBindData.OnRelease"/>
public static IBindData OnRelease(this IBindData bindData, Action<object> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnRelease((_, instance) =>
{
closure(instance);
});
}
/// <inheritdoc cref="IBindData.OnRelease"/>
/// <typeparam name="T">The type of release instance.</typeparam>
public static IBindData OnRelease<T>(this IBindData bindData, Action<T> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnRelease((_, instance) =>
{
if (instance is T)
{
closure((T)instance);
}
});
}
/// <inheritdoc cref="OnRelease{T}(IBindData, Action{T})"/>
public static IBindData OnRelease<T>(this IBindData bindData, Action<IBindData, T> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
return bindData.OnRelease((bind, instance) =>
{
if (instance is T)
{
closure(bind, (T)instance);
}
});
}
}
}
================================================
FILE: src/CatLib.Core/Container/Bindable.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using CatLib.Exception;
using CatLib.Util;
using System;
using System.Collections.Generic;
namespace CatLib.Container
{
/// <summary>
/// The bindable data indicates relational data related to the specified service.
/// </summary>
public abstract class Bindable : IBindable
{
private readonly Container container;
private Dictionary<string, string> contextual;
private Dictionary<string, Func<object>> contextualClosure;
private bool isDestroy;
/// <summary>
/// Initializes a new instance of the <see cref="Bindable"/> class.
/// </summary>
/// <param name="container">The container instance.</param>
/// <param name="service">The service name.</param>
protected Bindable(Container container, string service)
{
this.container = container;
Service = service;
isDestroy = false;
}
/// <inheritdoc />
public string Service { get; }
/// <summary>
/// Gets the container to which the service belongs.
/// </summary>
public IContainer Container => container;
/// <inheritdoc />
public void Unbind()
{
isDestroy = true;
ReleaseBind();
}
/// <summary>
/// Add the context with service.
/// </summary>
/// <param name="needs">Demand specified service.</param>
/// <param name="given">Given speified service or alias.</param>
internal void AddContextual(string needs, string given)
{
AssertDestroyed();
if (contextual == null)
{
contextual = new Dictionary<string, string>();
}
if (contextual.ContainsKey(needs)
|| (contextualClosure != null && contextualClosure.ContainsKey(needs)))
{
throw new LogicException($"Needs [{needs}] is already exist.");
}
contextual.Add(needs, given);
}
/// <inheritdoc cref="AddContextual(string, string)"/>
/// <param name="given">The closure return the given service instance.</param>
internal void AddContextual(string needs, Func<object> given)
{
AssertDestroyed();
if (contextualClosure == null)
{
contextualClosure = new Dictionary<string, Func<object>>();
}
if (contextualClosure.ContainsKey(needs)
|| (contextual != null && contextual.ContainsKey(needs)))
{
throw new LogicException($"Needs [{needs}] is already exist.");
}
contextualClosure.Add(needs, given);
}
/// <summary>
/// Get the demand context of the service.
/// </summary>
/// <param name="needs">The demand service.</param>
/// <returns>The given service or alias.</returns>
internal string GetContextual(string needs)
{
if (contextual == null)
{
return null;
}
return contextual.TryGetValue(needs, out string contextualNeeds) ? contextualNeeds : null;
}
/// <inheritdoc cref="GetContextual"/>
/// <returns>The closure return the given service instance.</returns>
internal Func<object> GetContextualClosure(string needs)
{
if (contextualClosure == null)
{
return null;
}
return contextualClosure.TryGetValue(needs, out Func<object> closure) ? closure : null;
}
/// <inheritdoc cref="Unbind"/>
protected abstract void ReleaseBind();
/// <summary>
/// Verify that the current instance i has been released.
/// </summary>
protected void AssertDestroyed()
{
if (isDestroy)
{
throw new LogicException("The current instance is destroyed.");
}
}
}
#pragma warning disable SA1402
/// <inheritdoc />
public abstract class Bindable<TReturn> : Bindable, IBindable<TReturn>
where TReturn : class, IBindable<TReturn>
{
/// <summary>
/// Indicates the given relationship in the context.
/// </summary>
private GivenData<TReturn> given;
/// <summary>
/// Initializes a new instance of the <see cref="Bindable{TReturn}"/> class.
/// </summary>
/// <param name="container">The container instance.</param>
/// <param name="service">The service name.</param>
protected Bindable(Container container, string service)
: base(container, service)
{
}
/// <inheritdoc />
public IGivenData<TReturn> Needs(string service)
{
Guard.ParameterNotNull(service, nameof(service));
AssertDestroyed();
if (given == null)
{
given = new GivenData<TReturn>((Container)Container, this);
}
given.Needs(service);
return given;
}
/// <inheritdoc />
public IGivenData<TReturn> Needs<TService>()
{
return Needs(Container.Type2Service(typeof(TService)));
}
}
}
================================================
FILE: src/CatLib.Core/Container/Container.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
using CatLib.Exception;
using CatLib.Util;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Text;
using SException = System.Exception;
namespace CatLib.Container
{
/// <summary>
/// The catlib ioc container implemented.
/// </summary>
public class Container : IContainer
{
/// <summary>
/// Characters not allowed in the service name.
/// </summary>
private static readonly char[] ServiceBanChars = { '@', ':', '$' };
/// <summary>
/// The container's bindings.
/// </summary>
private readonly Dictionary<string, BindData> bindings;
/// <summary>
/// The container's singleton(static) instances.
/// </summary>
private readonly Dictionary<string, object> instances;
/// <summary>
/// The container's singleton instances inverse index mapping.
/// </summary>
private readonly Dictionary<object, string> instancesReverse;
/// <summary>
/// The registered aliases with service.
/// </summary>
private readonly Dictionary<string, string> aliases;
/// <summary>
/// The registered aliases with service. inverse index mapping.
/// </summary>
private readonly Dictionary<string, List<string>> aliasesReverse;
/// <summary>
/// All of the registered tags.
/// </summary>
private readonly Dictionary<string, List<string>> tags;
/// <summary>
/// All of the global resolving callbacks.
/// </summary>
private readonly List<Action<IBindData, object>> resolving;
/// <summary>
/// All of the global after resolving callbacks.
/// </summary>
private readonly List<Action<IBindData, object>> afterResloving;
/// <summary>
/// All of the global release callbacks.
/// </summary>
private readonly List<Action<IBindData, object>> release;
/// <summary>
/// The extension closures for services.
/// </summary>
private readonly Dictionary<string, List<Func<object, IContainer, object>>> extenders;
/// <summary>
/// The type finder convert a string to a service type.
/// </summary>
private readonly SortSet<Func<string, Type>, int> findType;
/// <summary>
/// The cache that has been type found.
/// </summary>
private readonly Dictionary<string, Type> findTypeCache;
/// <summary>
/// An hash set of the service that have been resolved.
/// </summary>
private readonly HashSet<string> resolved;
/// <summary>
/// The singleton service build timing.
/// </summary>
private readonly SortSet<string, int> instanceTiming;
/// <summary>
/// All of the registered rebound callbacks.
/// </summary>
private readonly Dictionary<string, List<Action<object>>> rebound;
/// <summary>
/// The method ioc container.
/// </summary>
private readonly MethodContainer methodContainer;
/// <summary>
/// Represents a skipped object to skip some dependency injection.
/// </summary>
private readonly object skipped;
/// <summary>
/// Whether the container is flushing.
/// </summary>
private bool flushing;
/// <summary>
/// The unique Id is used to mark the global build order.
/// </summary>
private int instanceId;
/// <summary>
/// Initializes a new instance of the <see cref="Container"/> class.
/// </summary>
/// <param name="prime">The estimated number of services.</param>
public Container(int prime = 64)
{
prime = Math.Max(8, prime);
tags = new Dictionary<string, List<string>>((int)(prime * 0.25));
aliases = new Dictionary<string, string>(prime * 4);
aliasesReverse = new Dictionary<string, List<string>>(prime * 4);
instances = new Dictionary<string, object>(prime * 4);
instancesReverse = new Dictionary<object, string>(prime * 4);
bindings = new Dictionary<string, BindData>(prime * 4);
resolving = new List<Action<IBindData, object>>((int)(prime * 0.25));
afterResloving = new List<Action<IBindData, object>>((int)(prime * 0.25));
release = new List<Action<IBindData, object>>((int)(prime * 0.25));
extenders = new Dictionary<string, List<Func<object, IContainer, object>>>((int)(prime * 0.25));
resolved = new HashSet<string>();
findType = new SortSet<Func<string, Type>, int>();
findTypeCache = new Dictionary<string, Type>(prime * 4);
rebound = new Dictionary<string, List<Action<object>>>(prime);
instanceTiming = new SortSet<string, int>();
BuildStack = new Stack<string>(32);
UserParamsStack = new Stack<object[]>(32);
skipped = new object();
methodContainer = new MethodContainer(this);
flushing = false;
instanceId = 0;
}
/// <summary>
/// Gets the stack of concretions currently being built.
/// </summary>
protected Stack<string> BuildStack { get; }
/// <summary>
/// Gets the stack of the user params being built.
/// </summary>
protected Stack<object[]> UserParamsStack { get; }
/// <inheritdoc />
public object this[string service]
{
get => Make(service);
set
{
GetBind(service)?.Unbind();
Bind(service, (container, args) => value, false);
}
}
/// <inheritdoc />
public void Tag(string tag, params string[] services)
{
Guard.ParameterNotNull(tag, nameof(tag));
GuardFlushing();
if (!tags.TryGetValue(tag, out List<string> collection))
{
tags[tag] = collection = new List<string>();
}
foreach (var service in services ?? Array.Empty<string>())
{
if (string.IsNullOrEmpty(service))
{
continue;
}
collection.Add(service);
}
}
/// <inheritdoc />
public object[] Tagged(string tag)
{
Guard.ParameterNotNull(tag, nameof(tag));
if (!tags.TryGetValue(tag, out List<string> services))
{
throw new LogicException($"Tag \"{tag}\" is not exist.");
}
return Arr.Map(services, (service) => Make(service));
}
/// <inheritdoc />
public IBindData GetBind(string service)
{
if (string.IsNullOrEmpty(service))
{
return null;
}
service = AliasToService(service);
return bindings.TryGetValue(service, out BindData bindData)
? bindData : null;
}
/// <inheritdoc />
public bool HasBind(string service)
{
return GetBind(service) != null;
}
/// <inheritdoc />
public bool HasInstance(string service)
{
Guard.ParameterNotNull(service, nameof(service));
service = AliasToService(service);
return instances.ContainsKey(service);
}
/// <inheritdoc />
public bool IsResolved(string service)
{
Guard.ParameterNotNull(service, nameof(service));
service = AliasToService(service);
return resolved.Contains(service) || instances.ContainsKey(service);
}
/// <inheritdoc />
public bool CanMake(string service)
{
Guard.ParameterNotNull(service, nameof(service));
service = AliasToService(service);
if (HasBind(service) || HasInstance(service))
{
return true;
}
var type = SpeculatedServiceType(service);
return !IsBasicType(type) && !IsUnableType(type);
}
/// <inheritdoc />
public bool IsStatic(string service)
{
var bind = GetBind(service);
return bind != null && bind.IsStatic;
}
/// <inheritdoc />
public bool IsAlias(string name)
{
name = FormatService(name);
return aliases.ContainsKey(name);
}
/// <inheritdoc />
public IContainer Alias(string alias, string service)
{
Guard.ParameterNotNull(alias, nameof(alias));
Guard.ParameterNotNull(service, nameof(service));
if (alias == service)
{
throw new LogicException($"Alias is same as service: \"{alias}\".");
}
GuardFlushing();
alias = FormatService(alias);
service = AliasToService(service);
if (aliases.ContainsKey(alias))
{
throw new LogicException($"Alias \"{alias}\" is already exists.");
}
if (bindings.ContainsKey(alias))
{
throw new LogicException($"Alias \"{alias}\" has been used for service name.");
}
if (!bindings.ContainsKey(service) && !instances.ContainsKey(service))
{
throw new LogicException(
$"You must {nameof(Bind)}() or {nameof(Instance)}() serivce before and you be able to called {nameof(Alias)}().");
}
aliases.Add(alias, service);
if (!aliasesReverse.TryGetValue(service, out List<string> collection))
{
aliasesReverse[service] = collection = new List<string>();
}
collection.Add(alias);
return this;
}
/// <inheritdoc />
public bool BindIf(string service, Func<IContainer, object[], object> concrete, bool isStatic, out IBindData bindData)
{
var bind = GetBind(service);
if (bind == null && (HasInstance(service) || IsAlias(service)))
{
bindData = null;
return false;
}
bindData = bind ?? Bind(service, concrete, isStatic);
return bind == null;
}
/// <inheritdoc />
public bool BindIf(string service, Type concrete, bool isStatic, out IBindData bindData)
{
if (!IsUnableType(concrete))
{
service = FormatService(service);
return BindIf(service, WrapperTypeBuilder(service, concrete), isStatic, out bindData);
}
bindData = null;
return false;
}
/// <inheritdoc />
public IBindData Bind(string service, Type concrete, bool isStatic)
{
Guard.Requires<ArgumentNullException>(concrete != null, $"Parameter {nameof(concrete)} can not be null.");
if (IsUnableType(concrete))
{
throw new LogicException($"Type \"{concrete}\" can not bind. please check if there is a list of types that cannot be built.");
}
service = FormatService(service);
return Bind(service, WrapperTypeBuilder(service, concrete), isStatic);
}
/// <inheritdoc />
public IBindData Bind(string service, Func<IContainer, object[], object> concrete, bool isStatic)
{
Guard.ParameterNotNull(service, nameof(service));
Guard.ParameterNotNull(concrete, nameof(concrete));
GuardServiceName(service);
GuardFlushing();
service = FormatService(service);
if (bindings.ContainsKey(service))
{
throw new LogicException($"Bind [{service}] already exists.");
}
if (instances.ContainsKey(service))
{
throw new LogicException($"Instances [{service}] is already exists.");
}
if (aliases.ContainsKey(service))
{
throw new LogicException($"Aliase [{service}] is already exists.");
}
var bindData = new BindData(this, service, concrete, isStatic);
bindings.Add(service, bindData);
if (!IsResolved(service))
{
return bindData;
}
if (isStatic)
{
// If it is "static" then solve this service directly
// The process of staticizing the service triggers TriggerOnRebound
Make(service);
}
else
{
TriggerOnRebound(service);
}
return bindData;
}
/// <inheritdoc />
public IMethodBind BindMethod(string method, object target, MethodInfo called)
{
GuardFlushing();
GuardMethodName(method);
return methodContainer.Bind(method, target, called);
}
/// <inheritdoc />
public void UnbindMethod(object target)
{
methodContainer.Unbind(target);
}
/// <inheritdoc />
public object Invoke(string method, params object[] userParams)
{
GuardConstruct(nameof(Invoke));
return methodContainer.Invoke(method, userParams);
}
/// <inheritdoc />
public object Call(object target, MethodInfo methodInfo, params object[] userParams)
{
Guard.Requires<ArgumentNullException>(methodInfo != null);
if (!methodInfo.IsStatic)
{
Guard.Requires<ArgumentNullException>(target != null);
}
GuardConstruct(nameof(Call));
var parameter = methodInfo.GetParameters();
var bindData = GetBindFillable(target != null ? Type2Service(target.GetType()) : null);
userParams = GetDependencies(bindData, parameter, userParams) ?? Array.Empty<object>();
return methodInfo.Invoke(target, userParams);
}
/// <inheritdoc />
public object Make(string service, params object[] userParams)
{
GuardConstruct(nameof(Make));
return Resolve(service, userParams);
}
/// <inheritdoc />
public void Extend(string service, Func<object, IContainer, object> closure)
{
Guard.Requires<ArgumentNullException>(closure != null);
GuardFlushing();
service = string.IsNullOrEmpty(service) ? string.Empty : AliasToService(service);
if (!string.IsNullOrEmpty(service) && instances.TryGetValue(service, out object instance))
{
// If the instance already exists then apply the extension.
// Extensions will no longer be added to the permanent extension list.
var old = instance;
instances[service] = instance = closure(instance, this);
if (!old.Equals(instance))
{
instancesReverse.Remove(old);
instancesReverse.Add(instance, service);
}
TriggerOnRebound(service, instance);
return;
}
if (!extenders.TryGetValue(service, out List<Func<object, IContainer, object>> extender))
{
extenders[service] = extender = new List<Func<object, IContainer, object>>();
}
extender.Add(closure);
if (!string.IsNullOrEmpty(service) && IsResolved(service))
{
TriggerOnRebound(service);
}
}
/// <summary>
/// Remove all extensions for the specified service.
/// </summary>
/// <param name="service">The service name or alias.</param>
public void ClearExtenders(string service)
{
GuardFlushing();
service = AliasToService(service);
extenders.Remove(service);
if (!IsResolved(service))
{
return;
}
Release(service);
TriggerOnRebound(service);
}
/// <inheritdoc />
public object Instance(string service, object instance)
{
Guard.ParameterNotNull(service, nameof(service));
GuardFlushing();
GuardServiceName(service);
service = AliasToService(service);
var bindData = GetBind(service);
if (bindData != null)
{
if (!bindData.IsStatic)
{
throw new LogicException($"Service [{service}] is not Singleton(Static) Bind.");
}
}
else
{
bindData = MakeEmptyBindData(service);
}
instance = TriggerOnResolving((BindData)bindData, instance);
if (instance != null
&& instancesReverse.TryGetValue(instance, out string realService)
&& realService != service)
{
throw new LogicException($"The instance has been registered as a singleton in {realService}");
}
var isResolved = IsResolved(service);
Release(service);
instances.Add(service, instance);
if (instance != null)
{
instancesReverse.Add(instance, service);
}
if (!instanceTiming.Contains(service))
{
instanceTiming.Add(service, instanceId++);
}
if (isResolved)
{
TriggerOnRebound(service, instance);
}
return instance;
}
/// <inheritdoc />
public bool Release(object mixed)
{
if (mixed == null)
{
return false;
}
string service;
object instance = null;
if (!(mixed is string))
{
service = GetServiceWithInstanceObject(mixed);
}
else
{
service = AliasToService(mixed.ToString());
if (!instances.TryGetValue(service, out instance))
{
// Prevent the use of a string as a service name.
service = GetServiceWithInstanceObject(mixed);
}
}
if (instance == null &&
(string.IsNullOrEmpty(service) || !instances.TryGetValue(service, out instance)))
{
return false;
}
var bindData = GetBindFillable(service);
bindData.TriggerRelease(instance);
TriggerOnRelease(bindData, instance);
if (instance != null)
{
DisposeInstance(instance);
instancesReverse.Remove(instance);
}
instances.Remove(service);
if (!HasOnReboundCallbacks(service))
{
instanceTiming.Remove(service);
}
return true;
}
/// <inheritdoc />
public IContainer OnFindType(Func<string, Type> func, int priority = int.MaxValue)
{
Guard.Requires<ArgumentNullException>(func != null);
GuardFlushing();
findType.Add(func, priority);
return this;
}
/// <inheritdoc />
public IContainer OnRelease(Action<IBindData, object> closure)
{
AddClosure(closure, release);
return this;
}
/// <inheritdoc />
public IContainer OnResolving(Action<IBindData, object> closure)
{
AddClosure(closure, resolving);
return this;
}
/// <inheritdoc />
public IContainer OnAfterResolving(Action<IBindData, object> closure)
{
AddClosure(closure, afterResloving);
return this;
}
/// <inheritdoc />
public IContainer OnRebound(string service, Action<object> callback)
{
Guard.Requires<ArgumentNullException>(callback != null);
GuardFlushing();
service = AliasToService(service);
if (!IsResolved(service) && !CanMake(service))
{
throw new LogicException(
$"If you want use Rebound(Watch) , please {nameof(Bind)} or {nameof(Instance)} service first.");
}
if (!rebound.TryGetValue(service, out List<Action<object>> list))
{
rebound[service] = list = new List<Action<object>>();
}
list.Add(callback);
return this;
}
/// <inheritdoc />
public void Unbind(string service)
{
service = AliasToService(service);
var bind = GetBind(service);
bind?.Unbind();
}
/// <inheritdoc />
public virtual void Flush()
{
try
{
flushing = true;
foreach (var service in instanceTiming.GetIterator(false))
{
Release(service);
}
Guard.Requires<AssertException>(instances.Count <= 0);
tags.Clear();
aliases.Clear();
aliasesReverse.Clear();
instances.Clear();
bindings.Clear();
resolving.Clear();
release.Clear();
extenders.Clear();
resolved.Clear();
findType.Clear();
findTypeCache.Clear();
BuildStack.Clear();
UserParamsStack.Clear();
rebound.Clear();
methodContainer.Flush();
instanceTiming.Clear();
instanceId = 0;
}
finally
{
flushing = false;
}
}
/// <inheritdoc />
public string Type2Service(Type type)
{
return type.ToString();
}
/// <summary>
/// Trigger all callbacks in specified list.
/// </summary>
/// <param name="bindData">The bind data for <see cref="Make"/> service.</param>
/// <param name="instance">The service instance.</param>
/// <param name="list">The specified list.</param>
/// <returns>The decorated service instance.</returns>
internal static object Trigger(IBindData bindData, object instance, List<Action<IBindData, object>> list)
{
if (list == null)
{
return instance;
}
foreach (var closure in list)
{
closure(bindData, instance);
}
return instance;
}
/// <summary>
/// Unbind the service from the container.
/// </summary>
/// <param name="bindable">The bindable instance.</param>
internal void Unbind(IBindable bindable)
{
GuardFlushing();
Release(bindable.Service);
if (aliasesReverse.TryGetValue(bindable.Service, out List<string> serviceList))
{
foreach (var alias in serviceList)
{
aliases.Remove(alias);
}
aliasesReverse.Remove(bindable.Service);
}
bindings.Remove(bindable.Service);
}
/// <summary>
/// Gets an array of resolved instances for dependent parameters.
/// </summary>
/// <param name="makeServiceBindData">The bind data for <see cref="Make"/> service.</param>
/// <param name="baseParams">The dependent parameters array for <see cref="Make"/> service.</param>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>An array of resolved instances for dependent parameters.</returns>
protected internal virtual object[] GetDependencies(Bindable makeServiceBindData, ParameterInfo[] baseParams, object[] userParams)
{
if (baseParams.Length <= 0)
{
return Array.Empty<object>();
}
var results = new object[baseParams.Length];
// Gets a parameter matcher for filtering parameters
var matcher = GetParamsMatcher(ref userParams);
for (var i = 0; i < baseParams.Length; i++)
{
var baseParam = baseParams[i];
// Parameter matching is used to match the parameters.
// The parameter matchers are the first to perform because their
// matching accuracy is the most accurate.
var param = matcher?.Invoke(baseParam);
// When the container finds that the developer uses object or object[] as
// the dependency parameter type, we try to compact inject the user parameters.
param = param ?? GetCompactInjectUserParams(baseParam, ref userParams);
// Select the appropriate parameters from the user parameters and inject
// them in the relative order.
param = param ?? GetDependenciesFromUserParams(baseParam, ref userParams);
string needService = null;
if (param == null)
{
// Try to generate the required parameters through the dependency
// injection container.
needService = GetParamNeedsService(baseParam);
if (baseParam.ParameterType.IsClass
|| baseParam.ParameterType.IsInterface)
{
param = ResloveClass(makeServiceBindData, needService, baseParam);
}
else
{
param = ResolvePrimitive(makeServiceBindData, needService, baseParam);
}
}
// Perform dependency injection checking on the obtained injection instance.
if (!CanInject(baseParam.ParameterType, param))
{
var error =
$"[{makeServiceBindData.Service}] Params inject type must be [{baseParam.ParameterType}] , But instance is [{param?.GetType()}]";
if (needService == null)
{
error += " Inject params from user incoming parameters.";
}
else
{
error += $" Make service is [{needService}].";
}
throw new UnresolvableException(error);
}
results[i] = param;
}
return results;
}
/// <summary>
/// Determine if specified type is the default base type of the container.
/// </summary>
/// <param name="type">The specified type.</param>
/// <returns>True if the specified type is the default base type. otherwise false.</returns>
protected virtual bool IsBasicType(Type type)
{
return type == null || type.IsPrimitive || type == typeof(string);
}
/// <summary>
/// Determine the specified type is cannot built.
/// </summary>
/// <param name="type">The specified type.</param>
/// <returns>True if the specified type is cannot built. otherwise false.</returns>
protected virtual bool IsUnableType(Type type)
{
return type == null || type.IsAbstract || type.IsInterface || type.IsArray || type.IsEnum
|| (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>));
}
/// <summary>
/// Wrap a specified type.
/// </summary>
/// <param name="service">The service name.</param>
/// <param name="concrete">The service concrete type.</param>
/// <returns>Return a closure, call it to get the service instance.</returns>
protected virtual Func<IContainer, object[], object> WrapperTypeBuilder(string service, Type concrete)
{
return (container, userParams) => ((Container)container).CreateInstance(GetBindFillable(service), concrete,
userParams);
}
/// <summary>
/// Get dependencies from the user parameters.
/// </summary>
/// <param name="baseParam">The depend type.</param>
/// <param name="userParams">The user parameters.</param>
/// <returns>The instance that match the type of dependency.</returns>
protected virtual object GetDependenciesFromUserParams(ParameterInfo baseParam, ref object[] userParams)
{
if (userParams == null)
{
return null;
}
GuardUserParamsCount(userParams.Length);
for (var n = 0; n < userParams.Length; n++)
{
var userParam = userParams[n];
if (!ChangeType(ref userParam, baseParam.ParameterType))
{
continue;
}
Arr.RemoveAt(ref userParams, n);
return userParam;
}
return null;
}
/// <summary>
/// Convert instance to specified type.
/// </summary>
/// <param name="result">The instance.</param>
/// <param name="conversionType">The specified type.</param>
/// <returns>True if the conversion was successful, otherwise false.</returns>
protected virtual bool ChangeType(ref object result, Type conversionType)
{
try
{
if (result == null || conversionType.IsInstanceOfType(result))
{
return true;
}
if (IsBasicType(result.GetType()) && conversionType.IsDefined(typeof(VariantAttribute), false))
{
try
{
result = Make(Type2Service(conversionType), result);
return true;
}
#pragma warning disable CA1031
catch (SException)
#pragma warning restore CA1031
{
// ignored
// when throw exception then stop inject
}
}
if (result is IConvertible && typeof(IConvertible).IsAssignableFrom(conversionType))
{
result = Convert.ChangeType(result, conversionType);
return true;
}
}
#pragma warning disable CA1031
catch (SException)
#pragma warning restore CA1031
{
// ignored
// when throw exception then stop inject
}
return false;
}
/// <summary>
/// Convert <see cref="PropertyInfo"/> to the service name.
/// </summary>
/// <param name="propertyInfo">The property.</param>
/// <returns>The service name.</returns>
protected virtual string GetPropertyNeedsService(PropertyInfo propertyInfo)
{
return Type2Service(propertyInfo.PropertyType);
}
/// <summary>
/// Convert <see cref="ParameterInfo"/> to the service name.
/// </summary>
/// <param name="baseParam">The parameter.</param>
/// <returns>The service name.</returns>
protected virtual string GetParamNeedsService(ParameterInfo baseParam)
{
return Type2Service(baseParam.ParameterType);
}
/// <summary>
/// Gets build closures based on context.
/// </summary>
/// <param name="makeServiceBindData">The bind data for the <see cref="Make"/> service.</param>
/// <param name="service">The service name for dependent.</param>
/// <param name="paramName">The parameter name for dependent.</param>
/// <returns>The closure, call returned the dependency instance.</returns>
protected virtual Func<object> GetContextualClosure(Bindable makeServiceBindData, string service,
string paramName)
{
return makeServiceBindData.GetContextualClosure(service) ??
makeServiceBindData.GetContextualClosure($"{GetVariableTag()}{paramName}");
}
/// <inheritdoc cref="GetContextualClosure"/>
/// <summary>
/// Get build service based on context.
/// </summary>
/// <returns>The dependency service name.</returns>
protected virtual string GetContextualService(Bindable makeServiceBindData, string service, string paramName)
{
return makeServiceBindData.GetContextual(service) ??
makeServiceBindData.GetContextual($"{GetVariableTag()}{paramName}") ??
service;
}
/// <summary>
/// Gets the instance from closure.
/// </summary>
/// <param name="closure">The closure.</param>
/// <param name="needType">The expected type.</param>
/// <param name="ouput">The instance.</param>
/// <returns>True if the build is successful and matches the expected type, otherwise false.</returns>
protected virtual bool MakeFromContextualClosure(Func<object> closure, Type needType, out object ouput)
{
ouput = null;
if (closure == null)
{
return false;
}
ouput = closure();
return ChangeType(ref ouput, needType);
}
/// <inheritdoc cref="MakeFromContextualClosure"/>
/// <summary>
/// Gets the instance from service name.
/// </summary>
/// <param name="service">The service name.</param>
protected virtual bool MakeFromContextualService(string service, Type needType, out object output)
{
output = null;
if (!CanMake(service))
{
return false;
}
output = Make(service);
return ChangeType(ref output, needType);
}
/// <summary>
/// Resolve the specified service based on context.
/// </summary>
/// <param name="makeServiceBindData">The bind data for the <see cref="Make"/> service.</param>
/// <param name="service">The service name for dependent.</param>
/// <param name="paramName">The parameter or property name for dependent.</param>
/// <param name="paramType">The parameter or property type for dependent.</param>
/// <param name="output">The dependency instance.</param>
/// <returns>True if build the dependency instance successful. otherwise false.</returns>
protected virtual bool ResloveFromContextual(Bindable makeServiceBindData, string service, string paramName,
Type paramType, out object output)
{
if (MakeFromContextualClosure(
GetContextualClosure(makeServiceBindData, service, paramName),
paramType, out output))
{
return true;
}
return MakeFromContextualService(
GetContextualService(makeServiceBindData, service, paramName),
paramType, out output);
}
/// <summary>
/// Resolved the attribute selector's primitive type.
/// </summary>
/// <param name="makeServiceBindData">The bind data for the <see cref="Make"/> service.</param>
/// <param name="service">The name or alias of the service dependent needs to resolved.</param>
/// <param name="baseParam">The property for dependent.</param>
/// <returns>The dependency instance.</returns>
protected virtual object ResolveAttrPrimitive(Bindable makeServiceBindData, string service, PropertyInfo baseParam)
{
if (ResloveFromContextual(makeServiceBindData, service, baseParam.Name, baseParam.PropertyType,
out object instance))
{
return instance;
}
if (baseParam.PropertyType.IsGenericType && baseParam.PropertyType.GetGenericTypeDefinition() ==
typeof(Nullable<>))
{
return null;
}
var inject = (InjectAttribute)baseParam.GetCustomAttribute(typeof(InjectAttribute));
if (inject != null && !inject.Required)
{
return skipped;
}
throw MakeUnresolvableException(baseParam.Name, baseParam.DeclaringType);
}
/// <inheritdoc cref="ResolveAttrPrimitive"/>
/// <summary>
/// Resolved the attribute selector's reference type.
/// </summary>
protected virtual object ResloveAttrClass(Bindable makeServiceBindData, string service, PropertyInfo baseParam)
{
if (ResloveFromContextual(makeServiceBindData, service, baseParam.Name, baseParam.PropertyType,
out object instance))
{
return instance;
}
var inject = (InjectAttribute)baseParam.GetCustomAttribute(typeof(InjectAttribute));
if (inject != null && !inject.Required)
{
return skipped;
}
throw MakeUnresolvableException(baseParam.Name, baseParam.DeclaringType);
}
/// <summary>
/// Resolved the constructor's primitive type.
/// </summary>
/// <param name="makeServiceBindData">The bind data for the <see cref="Make"/> service.</param>
/// <param name="service">The name or alias of the service dependent needs to resolved.</param>
/// <param name="baseParam">The parameter for dependent.</param>
/// <returns>The dependency instance.</returns>
protected virtual object ResolvePrimitive(Bindable makeServiceBindData, string service, ParameterInfo baseParam)
{
if (ResloveFromContextual(makeServiceBindData, service, baseParam.Name, baseParam.ParameterType,
out object instance))
{
return instance;
}
if (baseParam.IsOptional)
{
return baseParam.DefaultValue;
}
if (baseParam.ParameterType.IsGenericType && baseParam.ParameterType.GetGenericTypeDefinition() ==
typeof(Nullable<>))
{
return null;
}
throw MakeUnresolvableException(
baseParam.Name,
baseParam.Member?.DeclaringType);
}
/// <inheritdoc cref="ResolvePrimitive"/>
/// <summary>
/// Resolved the constructor's reference type.
/// </summary>
protected virtual object ResloveClass(Bindable makeServiceBindData, string service, ParameterInfo baseParam)
{
if (ResloveFromContextual(makeServiceBindData, service, baseParam.Name, baseParam.ParameterType,
out object instance))
{
return instance;
}
if (baseParam.IsOptional)
{
return baseParam.DefaultValue;
}
// baseParam.Member maybe empty and may occur when some underlying
// development overwrites ParameterInfo class.
throw MakeUnresolvableException(
baseParam.Name,
baseParam.Member?.DeclaringType);
}
/// <summary>
/// Gets variable characters.
/// </summary>
/// <returns>The variable characters.</returns>
protected virtual char GetVariableTag()
{
return '$';
}
/// <summary>
/// Gets the debug message of the build stack.
/// </summary>
/// <returns>The debug message of the build stack.</returns>
protected virtual string GetBuildStackDebugMessage()
{
var previous = string.Join(", ", BuildStack.ToArray());
return $" While building stack [{previous}].";
}
/// <summary>
/// Build a reslove failure exception.
/// </summary>
/// <param name="makeService">The <see cref="Make"/> service name.</param>
/// <param name="makeServiceType">The <see cref="Make"/> service type.</param>
/// <param name="innerException">The inner exception.</param>
/// <returns>The resolve failure exception instance.</returns>
protected virtual UnresolvableException MakeBuildFaildException(string makeService, Type makeServiceType, SException innerException)
{
var message = makeServiceType != null
? $"Class [{makeServiceType}] build faild. Service is [{makeService}]."
: $"Service [{makeService}] is not exists.";
message += GetBuildStackDebugMessage();
message += GetInnerExceptionMessage(innerException);
return new UnresolvableException(message, innerException);
}
/// <summary>
/// Gets the inner exception debug message.
/// </summary>
/// <param name="innerException">The inner exception.</param>
/// <returns>The debug message.</returns>
protected virtual string GetInnerExceptionMessage(SException innerException)
{
if (innerException == null)
{
return string.Empty;
}
var stack = new StringBuilder();
do
{
if (stack.Length > 0)
{
stack.Append(", ");
}
stack.Append(innerException);
}
while ((innerException = innerException.InnerException) != null);
return $" InnerException message stack: [{stack}]";
}
/// <summary>
/// Build a unresolved exception.
/// </summary>
/// <param name="name">The parameter or property name for dependent.</param>
/// <param name="declaringClass">Declaring class type for parameter or property.</param>
/// <returns>The unresolved exception instance.</returns>
protected virtual UnresolvableException MakeUnresolvableException(string name, Type declaringClass)
{
return new UnresolvableException(
$"Unresolvable dependency , resolving [{name ?? "Unknow"}] in class [{declaringClass?.ToString() ?? "Unknow"}]");
}
/// <summary>
/// Build a circular dependency exception.
/// </summary>
/// <param name="service">The name of the service that throws the exception.</param>
/// <returns>The circular dependency exception.</returns>
protected virtual LogicException MakeCircularDependencyException(string service)
{
var message = $"Circular dependency detected while for [{service}].";
message += GetBuildStackDebugMessage();
return new LogicException(message);
}
/// <summary>
/// Format the service name.
/// </summary>
/// <param name="service">The service name.</param>
/// <returns>The formatted service name.</returns>
protected virtual string FormatService(string service)
{
return service.Trim();
}
/// <summary>
/// Check if the specified instance can be injected.
/// </summary>
/// <param name="type">The expected type.</param>
/// <param name="instance">The specified instance.</param>
/// <returns>True if the instance can be injected. otherwise false.</returns>
protected virtual bool CanInject(Type type, object instance)
{
return instance == null || type.IsInstanceOfType(instance);
}
/// <summary>
/// Ensure that the number of parameters passed in by the user must be less than the specified value.
/// </summary>
/// <param name="count">The specified count.</param>
protected virtual void GuardUserParamsCount(int count)
{
if (count > 255)
{
throw new LogicException($"Too many parameters , must be less or equal than 255 or override the {nameof(GuardUserParamsCount)} method.");
}
}
/// <summary>
/// Ensure that the specified instance is valid.
/// </summary>
/// <param name="instance">The specified instance.</param>
/// <param name="makeService">The <see cref="Make"/> service name.</param>
protected virtual void GuardResolveInstance(object instance, string makeService)
{
if (instance == null)
{
throw MakeBuildFaildException(makeService, SpeculatedServiceType(makeService), null);
}
}
/// <summary>
/// Speculative service type based on specified service name.
/// </summary>
/// <param name="service">The specified service name.</param>
/// <returns>The speculative service type.</returns>
protected virtual Type SpeculatedServiceType(string service)
{
if (findTypeCache.TryGetValue(service, out Type result))
{
return result;
}
foreach (var finder in findType)
{
var type = finder.Invoke(service);
if (type != null)
{
return findTypeCache[service] = type;
}
}
return findTypeCache[service] = null;
}
/// <summary>
/// Dependency injection on the property selector.
/// </summary>
/// <param name="makeServiceBindData">The bind data for <see cref="Make"/> service.</param>
/// <param name="makeServiceInstance">The instance for <see cref="Make"/> service.</param>
protected virtual void AttributeInject(Bindable makeServiceBindData, object makeServiceInstance)
{
if (makeServiceInstance == null)
{
return;
}
foreach (var property in makeServiceInstance.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
if (!property.CanWrite
|| !property.IsDefined(typeof(InjectAttribute), false))
{
continue;
}
var needService = GetPropertyNeedsService(property);
object instance;
if (property.PropertyType.IsClass
|| property.PropertyType.IsInterface)
{
instance = ResloveAttrClass(makeServiceBindData, needService, property);
}
else
{
instance = ResolveAttrPrimitive(makeServiceBindData, needService, property);
}
if (ReferenceEquals(instance, skipped))
{
continue;
}
if (!CanInject(property.PropertyType, instance))
{
throw new UnresolvableException(
$"[{makeServiceBindData.Service}]({makeServiceInstance.GetType()}) Attr inject type must be [{property.PropertyType}] , But instance is [{instance?.GetType()}] , Make service is [{needService}].");
}
property.SetValue(makeServiceInstance, instance, null);
}
}
/// <summary>
/// Check if the parameter passed in by the user can be injected compact.
/// </summary>
/// <param name="baseParam">The parameter for dependent.</param>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>True if the parameter can be injected tightly. otherwise false.</returns>
protected virtual bool CheckCompactInjectUserParams(ParameterInfo baseParam, object[] userParams)
{
if (userParams == null || userParams.Length <= 0)
{
return false;
}
return baseParam.ParameterType == typeof(object[])
|| baseParam.ParameterType == typeof(object);
}
/// <summary>
/// Gets the parameters injected through the compact.
/// </summary>
/// <param name="baseParam">The parameter for dependent.</param>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>Parameters that can be injected in a compact.</returns>
protected virtual object GetCompactInjectUserParams(ParameterInfo baseParam, ref object[] userParams)
{
if (!CheckCompactInjectUserParams(baseParam, userParams))
{
return null;
}
try
{
if (baseParam.ParameterType == typeof(object)
&& userParams != null && userParams.Length == 1)
{
return userParams[0];
}
return userParams;
}
finally
{
userParams = null;
}
}
/// <summary>
/// Gets the parameter matcher.
/// </summary>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>Returns the parameter matcher, if it is null, there is no matcher.</returns>
protected virtual Func<ParameterInfo, object> GetParamsMatcher(ref object[] userParams)
{
if (userParams == null || userParams.Length <= 0)
{
return null;
}
var tables = GetParamsTypeInUserParams(ref userParams);
return tables.Length <= 0 ? null : MakeParamsMatcher(tables);
}
/// <summary>
/// Select the appropriate constructor and get the corresponding array of parameter instances.
/// </summary>
/// <param name="makeServiceBindData">The bind data for <see cref="Make"/> service.</param>
/// <param name="makeServiceType">The type for <see cref="Make"/> service.</param>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>An array of resolved instances for dependent parameters.</returns>
protected virtual object[] GetConstructorsInjectParams(Bindable makeServiceBindData, Type makeServiceType, object[] userParams)
{
var constructors = makeServiceType.GetConstructors();
if (constructors.Length <= 0)
{
return Array.Empty<object>();
}
ExceptionDispatchInfo exceptionDispatchInfo = null;
foreach (var constructor in constructors)
{
try
{
return GetDependencies(makeServiceBindData, constructor.GetParameters(), userParams);
}
#pragma warning disable CA1031
catch (SException ex)
{
if (exceptionDispatchInfo == null)
{
exceptionDispatchInfo = ExceptionDispatchInfo.Capture(ex);
}
}
#pragma warning restore CA1031
}
exceptionDispatchInfo?.Throw();
throw new AssertException("Exception dispatch info is null.");
}
/// <summary>
/// Get the service name of the specified instance.
/// </summary>
/// <param name="instance">The specified instance.</param>
/// <returns>Returns the service name, or null if not found.</returns>
protected string GetServiceWithInstanceObject(object instance)
{
return instancesReverse.TryGetValue(instance, out string origin)
? origin
: null;
}
/// <summary>
/// Verify that the current construct is valid.
/// </summary>
/// <param name="method">Called function name.</param>
protected virtual void GuardConstruct(string method)
{
}
/// <summary>
/// Verify service name validity.
/// </summary>
/// <param name="service">The service name.</param>
protected virtual void GuardServiceName(string service)
{
foreach (var c in ServiceBanChars)
{
if (service.IndexOf(c) >= 0)
{
throw new LogicException(
$"Service name {service} contains disabled characters : {c}. please use Alias replacement");
}
}
}
/// <summary>
/// Verify function name validity.
/// </summary>
/// <param name="method">The method name.</param>
protected virtual void GuardMethodName(string method)
{
}
/// <summary>
/// Build an empty bound data.
/// </summary>
/// <param name="service">The service name.</param>
/// <returns>The bound data.</returns>
protected virtual BindData MakeEmptyBindData(string service)
{
return new BindData(this, service, null, false);
}
/// <summary>
/// Resolve the specified service(Will not perform <see cref="GuardConstruct"/> check).
/// </summary>
/// <param name="service">The service name or alias.</param>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>The service instance.</returns>
protected object Resolve(string service, params object[] userParams)
{
Guard.ParameterNotNull(service, nameof(service));
service = AliasToService(service);
if (instances.TryGetValue(service, out object instance))
{
return instance;
}
if (BuildStack.Contains(service))
{
throw MakeCircularDependencyException(service);
}
BuildStack.Push(service);
UserParamsStack.Push(userParams);
try
{
var bindData = GetBindFillable(service);
// We will start building a service instance,
// For the built service we will try to do dependency injection。
instance = Build(bindData, userParams);
// If we define an extender for the specified service, then we need
// to execute the expander in turn,And allow the extender to modify
// or overwrite the original service。
instance = Extend(service, instance);
instance = bindData.IsStatic
? Instance(bindData.Service, instance)
: TriggerOnResolving(bindData, instance);
resolved.Add(bindData.Service);
return instance;
}
finally
{
UserParamsStack.Pop();
BuildStack.Pop();
}
}
/// <summary>
/// Build the specified service.
/// </summary>
/// <param name="makeServiceBindData">The bind data for the <see cref="Make"/> service.</param>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>The service instance.</returns>
protected virtual object Build(BindData makeServiceBindData, object[] userParams)
{
var instance = makeServiceBindData.Concrete != null
? makeServiceBindData.Concrete(this, userParams)
: CreateInstance(makeServiceBindData, SpeculatedServiceType(makeServiceBindData.Service),
userParams);
return Inject(makeServiceBindData, instance);
}
/// <summary>
/// Create the specified service instance.
/// </summary>
/// <param name="makeServiceBindData">The bind data for the <see cref="Make"/> service.</param>
/// <param name="makeServiceType">The type for the <see cref="Make"/> service.</param>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>The service instance.</returns>
protected virtual object CreateInstance(Bindable makeServiceBindData, Type makeServiceType, object[] userParams)
{
if (IsUnableType(makeServiceType))
{
return null;
}
userParams = GetConstructorsInjectParams(makeServiceBindData, makeServiceType, userParams);
try
{
return CreateInstance(makeServiceType, userParams);
}
#pragma warning disable CA1031
catch (SException ex)
#pragma warning restore CA1031
{
throw MakeBuildFaildException(makeServiceBindData.Service, makeServiceType, ex);
}
}
/// <inheritdoc cref="CreateInstance(Bindable, Type, object[])"/>
protected virtual object CreateInstance(Type makeServiceType, object[] userParams)
{
// If the parameter does not exist then you can get better
// performance without writing parameters when reflecting.
if (userParams == null || userParams.Length <= 0)
{
return Activator.CreateInstance(makeServiceType);
}
return Activator.CreateInstance(makeServiceType, userParams);
}
/// <summary>
/// Get the service binding data, fill the data if the data is null.
/// </summary>
/// <param name="service">The service name.</param>
/// <returns>The bind data for the service.</returns>
protected BindData GetBindFillable(string service)
{
return service != null && bindings.TryGetValue(service, out BindData bindData)
? bindData
: MakeEmptyBindData(service);
}
/// <summary>
/// Guaranteed not to be flushing.
/// </summary>
private void GuardFlushing()
{
if (flushing)
{
throw new LogicException("Container is flushing can not do it");
}
}
/// <summary>
/// Convert an alias to a service name.
/// </summary>
/// <param name="name">The service name or alias.</param>
/// <returns>The service name.</returns>
private string AliasToService(string name)
{
name = FormatService(name);
return aliases.TryGetValue(name, out string alias) ? alias : name;
}
/// <summary>
/// Trigger all of the resolving callbacks.
/// </summary>
/// <param name="bindData">The bind data for <see cref="Make"/> service.</param>
/// <param name="instance">The service instance.</param>
/// <returns>The decorated service instance.</returns>
private object TriggerOnResolving(BindData bindData, object instance)
{
instance = bindData.TriggerResolving(instance);
instance = Trigger(bindData, instance, resolving);
return TriggerOnAfterResolving(bindData, instance);
}
/// <inheritdoc cref="TriggerOnResolving"/>
/// <summary>
/// Trigger all of the after resolving callbacks.
/// </summary>
private object TriggerOnAfterResolving(BindData bindData, object instance)
{
instance = bindData.TriggerAfterResolving(instance);
return Trigger(bindData, instance, afterResloving);
}
/// <inheritdoc cref="TriggerOnResolving"/>
/// <summary>
/// Trigger all of the release callbacks.
/// </summary>
private void TriggerOnRelease(IBindData bindData, object instance)
{
Trigger(bindData, instance, release);
}
/// <summary>
/// Trigger the rebound callbacks for specified service instance.
/// </summary>
/// <param name="service">The specified service name.</param>
/// <param name="instance">
/// The specified service instance.
/// Build from the container by service name if a null value is passed in.
/// </param>
private void TriggerOnRebound(string service, object instance = null)
{
var callbacks = GetOnReboundCallbacks(service);
if (callbacks == null || callbacks.Count <= 0)
{
return;
}
var bind = GetBind(service);
instance = instance ?? Make(service);
for (var index = 0; index < callbacks.Count; index++)
{
callbacks[index](instance);
// If it is a not singleton(static) binding then each callback is given a separate instance.
if (index + 1 < callbacks.Count && (bind == null || !bind.IsStatic))
{
instance = Make(service);
}
}
}
/// <summary>
/// Release the specified instance via <see cref="IDisposable"/>.
/// </summary>
/// <param name="instance">The specified instance.</param>
private void DisposeInstance(object instance)
{
if (instance is IDisposable disposable)
{
disposable.Dispose();
}
}
/// <summary>
/// Gets the specified service all of the rebound callbacks.
/// </summary>
/// <param name="service">The service name.</param>
/// <returns>The rebound callbacks list.</returns>
private IList<Action<object>> GetOnReboundCallbacks(string service)
{
return !rebound.TryGetValue(service, out List<Action<object>> result) ? null : result;
}
/// <summary>
/// Check if there is a callback for the rebound service.
/// </summary>
/// <param name="service">The service name.</param>
/// <returns>True if the rebound callback exists. otherwise false.</returns>
private bool HasOnReboundCallbacks(string service)
{
var result = GetOnReboundCallbacks(service);
return result != null && result.Count > 0;
}
/// <summary>
/// Trigger all of the extend callbacks.
/// </summary>
/// <param name="service">The service name.</param>
/// <param name="instance">The service instance.</param>
/// <returns>The decorated instance.</returns>
private object Extend(string service, object instance)
{
if (extenders.TryGetValue(service, out List<Func<object, IContainer, object>> list))
{
foreach (var extender in list)
{
instance = extender(instance, this);
}
}
if (!extenders.TryGetValue(string.Empty, out list))
{
return instance;
}
foreach (var extender in list)
{
instance = extender(instance, this);
}
return instance;
}
/// <summary>
/// Dependency injection for specified instance.
/// </summary>
/// <param name="bindable">The bindable for the instance.</param>
/// <param name="instance">The instance.</param>
/// <returns>An instance of injection has been completed.</returns>
private object Inject(Bindable bindable, object instance)
{
GuardResolveInstance(instance, bindable.Service);
AttributeInject(bindable, instance);
return instance;
}
/// <summary>
/// Get the variable of type <see cref="IParams"/> from <paramref name="userParams"/>.
/// </summary>
/// <param name="userParams">An array for the user parameter.</param>
/// <returns>An array of <see cref="IParams"/> parameters.</returns>
private IParams[] GetParamsTypeInUserParams(ref object[] userParams)
{
// Filter is used here without using Remove because
// the IParams is also one of the types that you might want to inject.
var elements = Arr.Filter(userParams, value => value is IParams);
var results = new IParams[elements.Length];
for (var i = 0; i < elements.Length; i++)
{
results[i] = (IParams)elements[i];
}
return results;
}
/// <summary>
/// Generate a default parameter <see cref="IParams" /> matcher.
/// </summary>
/// <param name="tables">An array of <see cref="IParams"/> parameters.</param>
/// <returns>The default parameter matcher.</returns>
private Func<ParameterInfo, object> MakeParamsMatcher(IParams[] tables)
{
// The default matcher policy will match the parameter name
// with the parameter name of the parameter table.
// The first valid valid parameter value will be returned
// as the return value
return parameterInfo =>
{
foreach (var table in tables)
{
if (!table.TryGetValue(parameterInfo.Name, out object result))
{
continue;
}
if (ChangeType(ref result, parameterInfo.ParameterType))
{
return result;
}
}
return null;
};
}
/// <summary>
/// Register a new callback in specified list.
/// </summary>
/// <param name="closure">The callback.</param>
/// <param name="list">The specified list.</param>
private void AddClosure(Action<IBindData, object> closure, List<Action<IBindData, object>> list)
{
Guard.Requires<ArgumentNullException>(closure != null);
GuardFlushing();
list.Add(closure);
}
}
}
================================================
FILE: src/CatLib.Core/Container/ContainerExtension.cs
================================================
/*
* This file is part of the CatLib package.
*
* (c) CatLib <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: https://catlib.io/
*/
#pragma warning disable SA1618
using CatLib.Exception;
using CatLib.Util;
using System;
namespace CatLib.Container
{
/// <summary>
/// An extension function for <see cref="Container"/>.
/// </summary>
public static class ContainerExtension
{
/// <summary>
/// Gets the binding data of the given service.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>Return null If there is no binding data.</returns>
public static IBindData GetBind<TService>(this IContainer container)
{
return container.GetBind(container.Type2Service(typeof(TService)));
}
/// <summary>
/// Whether the given service has been bound.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>True if the service has been bound.</returns>
public static bool HasBind<TService>(this IContainer container)
{
return container.HasBind(container.Type2Service(typeof(TService)));
}
/// <summary>
/// Whether the existing instance is exists in the container.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>True if the instance existed.</returns>
public static bool HasInstance<TService>(this IContainer container)
{
return container.HasInstance(container.Type2Service(typeof(TService)));
}
/// <summary>
/// Whether the service has been resolved.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>True if the service has been resolved.</returns>
public static bool IsResolved<TService>(this IContainer container)
{
return container.IsResolved(container.Type2Service(typeof(TService)));
}
/// <summary>
/// Whether the given service can be made.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>True if the given service can be made.</returns>
public static bool CanMake<TService>(this IContainer container)
{
return container.CanMake(container.Type2Service(typeof(TService)));
}
/// <summary>
/// Whether the given service is singleton bind. false if the service not exists.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>True if the service is singleton bind.</returns>
public static bool IsStatic<TService>(this IContainer container)
{
return container.IsStatic(container.Type2Service(typeof(TService)));
}
/// <summary>
/// Whether the given name is an alias.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>True if the given name is an alias.</returns>
public static bool IsAlias<TService>(this IContainer container)
{
return container.IsAlias(container.Type2Service(typeof(TService)));
}
/// <summary>
/// Alias a service to a different name.
/// </summary>
/// <typeparam name="TAlias">The alias name.</typeparam>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The container instance.</param>
/// <returns>Returns the container instance.</returns>
public static IContainer Alias<TAlias, TService>(this IContainer container)
{
return container.Alias(container.Type2Service(typeof(TAlias)), container.Type2Service(typeof(TService)));
}
/// <summary>
/// Register a binding with the container.
/// </summary>
/// <typeparam name="TService">The service name (also indicates specific implementation).</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>The service binding data.</returns>
public static IBindData Bind<TService>(this IContainer container)
{
return container.Bind(container.Type2Service(typeof(TService)), typeof(TService), false);
}
/// <summary>
/// Register a binding with the container.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <typeparam name="TConcrete">The service concrete.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <returns>The service binding data.</returns>
public static IBindData Bind<TService, TConcrete>(this IContainer container)
{
return container.Bind(container.Type2Service(typeof(TService)), typeof(TConcrete), false);
}
/// <summary>
/// Register a binding with the container.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="concrete">The service concrete.</param>
/// <returns>The service binding data.</returns>
public static IBindData Bind<TService>(this IContainer container, Func<IContainer, object[], object> concrete)
{
Guard.Requires<ArgumentNullException>(concrete != null);
return container.Bind(container.Type2Service(typeof(TService)), concrete, false);
}
/// <summary>
/// Register a binding with the container.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="concrete">The service concrete.</param>
/// <returns>The service binding data.</returns>
public static IBindData Bind<TService>(this IContainer container, Func<object[], object> concrete)
{
Guard.Requires<ArgumentNullException>(concrete != null);
return container.Bind(container.Type2Service(typeof(TService)), (c, p) => concrete.Invoke(p), false);
}
/// <summary>
/// Register a binding with the container.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="concrete">The service concrete.</param>
/// <returns>The service binding data.</returns>
public static IBindData Bind<TService>(this IContainer container, Func<object> concrete)
{
Guard.Requires<ArgumentNullException>(concrete != null);
return container.Bind(container.Type2Service(typeof(TService)), (c, p) => concrete.Invoke(), false);
}
/// <summary>
/// Register a binding with the container.
/// </summary>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="service">The service name.</param>
/// <param name="concrete">The service concrete.</param>
/// <returns>The service binding data.</returns>
public static IBindData Bind(this IContainer container, string service,
Func<IContainer, object[], object> concrete)
{
Guard.Requires<ArgumentNullException>(concrete != null);
return container.Bind(service, concrete, false);
}
/// <summary>
/// Register a binding with the container if the service not exists.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <typeparam name="TConcrete">The service concrete.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="bindData">The binding data.</param>
/// <returns>True if register a binding with the container.</returns>
public static bool BindIf<TService, TConcrete>(this IContainer container, out IBindData bindData)
{
return container.BindIf(container.Type2Service(typeof(TService)), typeof(TConcrete), false, out bindData);
}
/// <summary>
/// Register a binding with the container if the service not exists.
/// </summary>
/// <typeparam name="TService">The service name (also indicates specific implementation).</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="bindData">The binding data.</param>
/// <returns>True if register a binding with the container.</returns>
public static bool BindIf<TService>(this IContainer container, out IBindData bindData)
{
return container.BindIf(container.Type2Service(typeof(TService)), typeof(TService), false, out bindData);
}
/// <summary>
/// Register a binding with the container if the service not exists.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="concrete">The service concrete.</param>
/// <param name="bindData">The binding data.</param>
/// <returns>True if register a binding with the container.</returns>
public static bool BindIf<TService>(this IContainer container, Func<IContainer, object[], object> concrete, out IBindData bindData)
{
Guard.Requires<ArgumentNullException>(concrete != null);
return container.BindIf(container.Type2Service(typeof(TService)), concrete, false, out bindData);
}
/// <summary>
/// Register a binding with the container if the service not exists.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="concrete">The service concrete.</param>
/// <param name="bindData">The binding data.</param>
/// <returns>True if register a binding with the container.</returns>
public static bool BindIf<TService>(this IContainer container, Func<object[], object> concrete, out IBindData bindData)
{
Guard.Requires<ArgumentNullException>(concrete != null);
return container.BindIf(container.Type2Service(typeof(TService)), (c, @params) => concrete(@params), false,
out bindData);
}
/// <summary>
/// Register a binding with the container if the service not exists.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="concrete">The service concrete.</param>
/// <param name="bindData">The binding data.</param>
/// <returns>True if register a binding with the container.</returns>
public static bool BindIf<TService>(this IContainer container, Func<object> concrete, out IBindData bindData)
{
Guard.Requires<ArgumentNullException>(concrete != null);
return container.BindIf(container.Type2Service(typeof(TService)), (c, p) => concrete.Invoke(), false,
out bindData);
}
/// <summary>
/// Register a binding with the container if the service not exists.
/// </summary>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="service">The service name.</param>
/// <param name="concrete">The service concrete.</param>
/// <param name="bindData">The binding data.</param>
/// <returns>True if register a binding with the container.</returns>
public static bool BindIf(this IContainer container, string service,
Func<IContainer, object[], object> concrete, out IBindData bindData)
{
return container.BindIf(service, concrete, false, out bindData);
}
/// <summary>
/// Register a singleton binding with the container.
/// </summary>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <param name="service">The service name.</param>
/// <param name="concrete">The service concrete.</param>
/// <returns>The service binding data.</returns>
public static IBindData Singleton(this IContainer container, string service,
Func<IContainer, object[], object> concrete)
{
return container.Bind(service, concrete, true);
}
/// <summary>
/// Register a singleton binding with the container.
/// </summary>
/// <typeparam name="TService">The service name.</typeparam>
/// <typeparam name="TConcrete">The service concrete.</typeparam>
/// <param name="container">The <see cref="IContainer"/> instance.</param>
/// <
gitextract_rz18cs7b/
├── .dist/
│ ├── CHANGELOG.md
│ ├── LICENSE
│ ├── README.md
│ ├── bucket.json
│ └── netstandard2.0/
│ ├── CatLib.Core.deps.json
│ └── CatLib.Core.pdb
├── .gitattributes
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── ---bug-report.md
│ ├── ---documentation-issue.md
│ ├── ---feature-request.md
│ └── ---support-question.md
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CatLib.Core.sln
├── LICENSE
├── README.md
├── bucket.json
├── build.ps1
└── src/
├── CatLib.Core/
│ ├── CatLib/
│ │ ├── App.cs
│ │ ├── Application.cs
│ │ ├── DebugLevel.cs
│ │ ├── Events/
│ │ │ ├── AfterBootEventArgs.cs
│ │ │ ├── AfterInitEventArgs.cs
│ │ │ ├── AfterTerminateEventArgs.cs
│ │ │ ├── ApplicationEventArgs.cs
│ │ │ ├── ApplicationEvents.cs
│ │ │ ├── BeforeBootEventArgs.cs
│ │ │ ├── BeforeInitEventArgs.cs
│ │ │ ├── BeforeTerminateEventArgs.cs
│ │ │ ├── BootingEventArgs.cs
│ │ │ ├── InitProviderEventArgs.cs
│ │ │ ├── RegisterProviderEventArgs.cs
│ │ │ └── StartCompletedEventArgs.cs
│ │ ├── Facade.cs
│ │ ├── IApplication.cs
│ │ ├── IBootstrap.cs
│ │ ├── IServiceProvider.cs
│ │ ├── ServiceProvider.cs
│ │ └── StartProcess.cs
│ ├── CatLib.Core.csproj
│ ├── Container/
│ │ ├── BindData.cs
│ │ ├── BindDataExtension.cs
│ │ ├── Bindable.cs
│ │ ├── Container.cs
│ │ ├── ContainerExtension.cs
│ │ ├── GivenData.cs
│ │ ├── IBindData.cs
│ │ ├── IBindable.cs
│ │ ├── IContainer.cs
│ │ ├── IGivenData.cs
│ │ ├── IMethodBind.cs
│ │ ├── IParams.cs
│ │ ├── InjectAttribute.cs
│ │ ├── MethodBind.cs
│ │ ├── MethodContainer.cs
│ │ ├── ParamsCollection.cs
│ │ ├── UnresolvableException.cs
│ │ └── VariantAttribute.cs
│ ├── EventDispatcher/
│ │ ├── EventDispatcher.cs
│ │ ├── IEventDispatcher.cs
│ │ └── IStoppableEvent.cs
│ ├── Exception/
│ │ ├── AssertException.cs
│ │ ├── LogicException.cs
│ │ └── RuntimeException.cs
│ ├── IO/
│ │ ├── CombineStream.cs
│ │ ├── RingBufferStream.cs
│ │ ├── SegmentStream.cs
│ │ ├── StreamExtension.cs
│ │ └── WrapperStream.cs
│ ├── Properties/
│ │ └── AssemblyInfo.cs
│ └── Util/
│ ├── Arr.cs
│ ├── Guard.cs
│ ├── InternalHelper.cs
│ ├── SortSet.cs
│ └── Str.cs
├── CatLib.Core.Tests/
│ ├── CatLib/
│ │ ├── TestsApplication.cs
│ │ └── TestsFacade.cs
│ ├── CatLib.Core.Tests.csproj
│ ├── Container/
│ │ ├── TestsBindData.cs
│ │ ├── TestsContainer.cs
│ │ └── TestsExtensionContainer.cs
│ ├── EventDispatcher/
│ │ └── TestsEventDispatcher.cs
│ ├── Fixture/
│ │ ├── AbstractClass.cs
│ │ ├── Bar.cs
│ │ ├── Baz.cs
│ │ ├── CircularDependency.cs
│ │ ├── Foo.cs
│ │ ├── FooBar.cs
│ │ ├── Fubar.cs
│ │ ├── FubarChild.cs
│ │ ├── IFoo.cs
│ │ ├── Position.cs
│ │ ├── Quux.cs
│ │ ├── QuuxFoo.cs
│ │ ├── TestEventArgs.cs
│ │ ├── Variant.cs
│ │ └── VariantModel.cs
│ ├── Framework/
│ │ ├── ExpectedExceptionAndMessageAttribute.cs
│ │ ├── TestException.cs
│ │ └── TestMethodIterativeAttribute.cs
│ ├── IO/
│ │ ├── TestsCombineStream.cs
│ │ ├── TestsRingBuffer.cs
│ │ ├── TestsSegmentStream.cs
│ │ └── TestsStreamExtension.cs
│ └── Util/
│ ├── TestsArr.cs
│ ├── TestsGuard.cs
│ ├── TestsSortSet.cs
│ └── TestsStr.cs
├── Directory.Build.props
├── analysis.ruleset
├── analysis.test.ruleset
├── settings.runsettings
└── stylecop.json
SYMBOL INDEX (1037 symbols across 87 files)
FILE: src/CatLib.Core.Tests/CatLib/TestsApplication.cs
class TestsApplication (line 23) | [TestClass]
method Initialize (line 29) | [TestInitialize]
method TestGetFileVersion (line 36) | [TestMethod]
method TestBootstrapRepeat (line 43) | [TestMethod]
method TestInitRepeat (line 52) | [TestMethod]
method TestInitNoBootstrap (line 61) | [TestMethod]
method TestBootstrapSkip (line 68) | [TestMethod]
method TestRegisterSkip (line 89) | [TestMethod]
method TestRegisterRepeat (line 111) | [TestMethod]
method TestInitingRegister (line 120) | [TestMethod]
method TestTerminateRegister (line 137) | [TestMethod]
method TestTerminateSequenceOfEvents (line 153) | [TestMethod]
method TestGetProcess (line 171) | [TestMethod]
method TestDebugLevel (line 177) | [TestMethod]
method TestGetRuntimeId (line 187) | [TestMethod]
method TestIsMainThread (line 193) | [TestMethod]
method TestInitAfterRegister (line 203) | [TestMethod]
method TestRegistingMake (line 218) | [TestMethod]
method TestBoostrapRepeat (line 231) | [TestMethod]
method TestBoostrapOrder (line 239) | [TestMethod]
FILE: src/CatLib.Core.Tests/CatLib/TestsFacade.cs
class TestsFacade (line 18) | [TestClass]
method Initialize (line 23) | [TestInitialize]
method TestFacade (line 30) | [TestMethod]
method TestAlwaysWatchNewer (line 39) | [TestMethod]
method TestAlwaysWatchWithInstance (line 52) | [TestMethod]
method TestFacadeMakeFaild (line 63) | [TestMethod]
method TestFacadeRelease (line 74) | [TestMethod]
method TestNotStaticBindFacade (line 86) | [TestMethod]
method TestSingletonChangeToBind (line 95) | [TestMethod]
method TestBindChangeToSingleton (line 110) | [TestMethod]
method TestInstance (line 125) | [TestMethod]
FILE: src/CatLib.Core.Tests/Container/TestsBindData.cs
class TestsBindData (line 21) | [TestClass]
method Init (line 27) | [TestInitialize]
method CheckNeedsIllegal (line 34) | [TestMethod]
method TestGetContextual (line 41) | [TestMethod]
method TestGetContextualClosure (line 51) | [TestMethod]
method TestNeedsDuplicate (line 59) | [TestMethod]
method TestAlias (line 67) | [TestMethod]
method TestAliasIllegal (line 77) | [TestMethod]
method TestTag (line 84) | [TestMethod]
method TestOnRelease (line 91) | [TestMethod]
method TestOnReleaseIllegal (line 112) | [TestMethod]
method TestOnResolvingIllegal (line 119) | [TestMethod]
method TestUnbind (line 126) | [TestMethod]
method TestUnbindAfterChanged (line 135) | [TestMethod]
FILE: src/CatLib.Core.Tests/Container/TestsContainer.cs
class TestsContainer (line 24) | [TestClass]
method Initialize (line 29) | [TestInitialize]
method TestTag (line 40) | [TestMethod]
method TestTagIllegal (line 58) | [TestMethod]
method TestTagNotExists (line 66) | [TestMethod]
method TestUnbind (line 75) | [TestMethod]
method TestUnbindWithAlias (line 84) | [TestMethod]
method TestUnableType (line 93) | [TestMethod]
method TestBindIf (line 103) | [TestMethod]
method TestbBindIfWithType (line 114) | [TestMethod]
method TestBindStatic (line 125) | [TestMethod]
method TestBindNonStatic (line 138) | [TestMethod]
method TestGetBind (line 148) | [TestMethod]
method TestBindIllegal (line 166) | [TestMethod]
method TestHasBind (line 199) | [TestMethod]
method TestIsStatic (line 209) | [TestMethod]
method TestAlias (line 224) | [TestMethod]
method TestAliasIllegal (line 237) | [TestMethod]
method TestCircularDependencyInject (line 264) | [TestMethod]
method TestIsAlias (line 272) | [TestMethod]
method TestCall (line 282) | [TestMethod]
method TestCallCircularDependencyInject (line 298) | [TestMethod]
method TestCallGivenIncorrectParament (line 309) | [TestMethod]
method TestMakearameterOverflow (line 324) | [TestMethod]
method TestTightInject (line 334) | [TestMethod]
method TestContextInjectionWithProperty (line 348) | [TestMethod]
method TestContextInjection (line 360) | [TestMethod]
method TestContextInjectionErrorType (line 377) | [TestMethod]
method TestMake (line 387) | [TestMethod]
method TestMakeWithParams (line 396) | [TestMethod]
method TestMakeEmptyService (line 405) | [TestMethod]
method TestMakeWithAlias (line 412) | [TestMethod]
method TestMakeAttributeInjectFaild (line 425) | [TestMethod]
method TestMakeAttributeInjectFaildWithPrimitiveAttr (line 437) | [TestMethod]
method TestMakeWithDefaultValuePrimitive (line 447) | [TestMethod]
method TestMakeWithDefaultValue (line 456) | [TestMethod]
method TestMakeInjectWithStruct (line 466) | [TestMethod]
method TestMakeInjectWithGeneric (line 483) | [TestMethod]
method TestMakeAbstractClass (line 514) | [TestMethod]
method TestMakeInjectWithInheritance (line 524) | [TestMethod]
method TestMakeMissConstructor (line 544) | [TestMethod]
method TestMakeConstructorThrowException (line 552) | [TestMethod]
method TestMakeWithIParams (line 560) | [TestMethod]
method TestMakeWithMultIParamsOrder (line 580) | [TestMethod]
method TestMakeWithIParamsGivenErrorType (line 606) | [TestMethod]
method TestMakeNullable (line 620) | [TestMethod]
method TestCanMake (line 631) | [TestMethod]
method TestInstance (line 641) | [TestMethod]
method TestInstanceIllegalChars (line 655) | [TestMethod]
method TestInstanceNotAllowedSameObject (line 665) | [TestMethod]
method TestInstanceAllowedDifferenceObject (line 674) | [TestMethod]
method TestInstanceIllegal (line 681) | [TestMethod]
method TestReleaseAutoCallDispose (line 691) | [TestMethod]
method TestOnRelease (line 702) | [TestMethod]
method TestFlush (line 728) | [TestMethod]
method TestFlushInstanceService (line 753) | [TestMethod]
method TestFlushOrder (line 767) | [TestMethod]
method TestVariant (line 794) | [TestMethod]
method TestVariantThrowException (line 806) | [TestMethod]
method TestVariantForceGivenNull (line 814) | [TestMethod]
method TestReboundNotExistsService (line 825) | [TestMethod]
method TestRebound (line 834) | [TestMethod]
method TestReboundWithInstance (line 857) | [TestMethod]
method TestUnbindNotExistsService (line 871) | [TestMethod]
method TestHasInstance (line 877) | [TestMethod]
method TestIsResolved (line 886) | [TestMethod]
method TestExtend (line 901) | [TestMethod]
method TestExtendMult (line 910) | [TestMethod]
method TestExtendSingle (line 920) | [TestMethod]
method TestExtendAndRebound (line 936) | [TestMethod]
method TestExtendGivenMismatchedType (line 956) | [TestMethod]
method TestClearExtend (line 968) | [TestMethod]
method TestIndexer (line 993) | [TestMethod]
method TestIndexerOverride (line 1000) | [TestMethod]
method TestOnAfterResolving (line 1010) | [TestMethod]
method TestOnAfterResolvingLocal (line 1035) | [TestMethod]
method TestNullRelease (line 1058) | [TestMethod]
method CreateContainer (line 1064) | protected virtual IContainer CreateContainer()
FILE: src/CatLib.Core.Tests/Container/TestsExtensionContainer.cs
class TestsExtensionContainer (line 21) | [TestClass]
method Initialize (line 26) | [TestInitialize]
method TestMake (line 36) | [TestMethod]
method TestInstance (line 46) | [TestMethod]
method TestRelease (line 55) | [TestMethod]
method TestAlias (line 62) | [TestMethod]
method TestReleaseWithObject (line 69) | [TestMethod]
method TestBindIf (line 101) | [TestMethod]
method TestSingletonIf (line 109) | [TestMethod]
method TestGetBind (line 117) | [TestMethod]
method TestCanMake (line 123) | [TestMethod]
method TestIsStatic (line 130) | [TestMethod]
method TestIsAlias (line 137) | [TestMethod]
method TestWrap (line 145) | [TestMethod]
method TestCall (line 190) | [TestMethod]
method TestOnResolving (line 231) | [TestMethod]
method TestOnAfterResolving (line 258) | [TestMethod]
method TestOnRelease (line 285) | [TestMethod]
method TestCallIllegal (line 317) | [TestMethod]
method TestFactory (line 327) | [TestMethod]
method TestHasBind (line 342) | [TestMethod]
method TestWatch (line 348) | [TestMethod]
method TestWatchInstanceOverride (line 366) | [TestMethod]
method TestReleaseWithTag (line 392) | [TestMethod]
method TestExtend (line 404) | [TestMethod]
method TestBindMethod (line 415) | [TestMethod]
method TestUnbindMethodWithMethodName (line 432) | [TestMethod]
method TestBindMethodExists (line 448) | [TestMethod]
method TestBindMethodStatic (line 456) | [TestMethod]
method TestUnbindWithObject (line 463) | [TestMethod]
method TestContainerMethodContextual (line 491) | [TestMethod]
FILE: src/CatLib.Core.Tests/EventDispatcher/TestsEventDispatcher.cs
class TestsEventDispatcher (line 20) | [TestClass]
method Initialize (line 25) | [TestInitialize]
method TestRaise (line 31) | [TestMethod]
method TestAddListener (line 41) | [TestMethod]
method TestHasListener (line 58) | [TestMethod]
method TestRepateAddSameListeners (line 72) | [TestMethod]
method TestRemoveListeners (line 81) | [TestMethod]
method TestRemoveAllListeners (line 106) | [TestMethod]
method TestRemoveNotExistsListener (line 129) | [TestMethod]
method TestStoppableEvent (line 137) | [TestMethod]
FILE: src/CatLib.Core.Tests/Fixture/AbstractClass.cs
class AbstractClass (line 14) | public abstract class AbstractClass
FILE: src/CatLib.Core.Tests/Fixture/Bar.cs
class Bar (line 17) | public sealed class Bar : IDisposable
method Bar (line 19) | public Bar(int? num = null)
method ToString (line 31) | public override string ToString()
method Dispose (line 36) | public void Dispose()
FILE: src/CatLib.Core.Tests/Fixture/Baz.cs
class Baz (line 17) | public sealed class Baz
method Baz (line 19) | public Baz(Foo foo, int boo = 100)
FILE: src/CatLib.Core.Tests/Fixture/CircularDependency.cs
class CircularDependency (line 16) | public class CircularDependency
method CircularDependency (line 18) | public CircularDependency(CircularDependency dependency)
method Foo (line 26) | public virtual object Foo(CircularDependency dependency)
FILE: src/CatLib.Core.Tests/Fixture/Foo.cs
class Foo (line 16) | public class Foo : IFoo
method Echo (line 18) | public static string Echo(string input)
method EchoInt (line 23) | public int EchoInt(int input)
method EchoFloat (line 28) | public float EchoFloat(float input)
method ToString (line 33) | public override string ToString()
FILE: src/CatLib.Core.Tests/Fixture/FooBar.cs
class FooBar (line 18) | public class FooBar
method FooBar (line 20) | public FooBar(Foo foo, Bar bar)
method New (line 33) | public static FooBar New()
method GetName (line 38) | public string GetName(Foo foo, Bar bar)
method ToString (line 43) | public override string ToString()
FILE: src/CatLib.Core.Tests/Fixture/Fubar.cs
class Fubar (line 19) | public class Fubar
method Fubar (line 21) | public Fubar(Bar bar = null, IList<string> heros = null)
FILE: src/CatLib.Core.Tests/Fixture/FubarChild.cs
class FubarChild (line 17) | public class FubarChild : Fubar
method FubarChild (line 19) | public FubarChild(Bar bar = null, IList<string> heros = null)
FILE: src/CatLib.Core.Tests/Fixture/IFoo.cs
type IFoo (line 15) | public interface IFoo
FILE: src/CatLib.Core.Tests/Fixture/Position.cs
type Position (line 16) | public struct Position
FILE: src/CatLib.Core.Tests/Fixture/Quux.cs
class Quux (line 14) | public class Quux
method Quux (line 16) | protected Quux()
FILE: src/CatLib.Core.Tests/Fixture/QuuxFoo.cs
class QuuxFoo (line 14) | public class QuuxFoo : Quux
method QuuxFoo (line 16) | public QuuxFoo()
FILE: src/CatLib.Core.Tests/Fixture/TestEventArgs.cs
class TestEventArgs (line 17) | public class TestEventArgs : EventArgs, IStoppableEvent
method StopPropagation (line 21) | public void StopPropagation()
FILE: src/CatLib.Core.Tests/Fixture/Variant.cs
class Variant (line 14) | public class Variant
method Variant (line 16) | public Variant(VariantModel model)
FILE: src/CatLib.Core.Tests/Fixture/VariantModel.cs
class VariantModel (line 16) | [Variant]
method VariantModel (line 19) | public VariantModel(int id)
FILE: src/CatLib.Core.Tests/Framework/ExpectedExceptionAndMessageAttribute.cs
class ExpectedExceptionAndMessageAttribute (line 21) | public class ExpectedExceptionAndMessageAttribute : ExpectedExceptionBas...
method ExpectedExceptionAndMessageAttribute (line 27) | public ExpectedExceptionAndMessageAttribute(Type expectedExceptionType)
method ExpectedExceptionAndMessageAttribute (line 33) | public ExpectedExceptionAndMessageAttribute(Type expectedExceptionType...
method Verify (line 40) | protected override void Verify(SException exception)
FILE: src/CatLib.Core.Tests/Framework/TestException.cs
class TestException (line 17) | public class TestException : SException
method TestException (line 19) | public TestException()
method TestException (line 23) | public TestException(string message)
method TestException (line 28) | public TestException(string message, SException innerException)
method TestException (line 33) | protected TestException(SerializationInfo serializationInfo, Streaming...
FILE: src/CatLib.Core.Tests/Framework/TestMethodIterativeAttribute.cs
class TestMethodIterativeAttribute (line 18) | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
method TestMethodIterativeAttribute (line 23) | public TestMethodIterativeAttribute(int stabilityThreshold = 1)
method Execute (line 28) | public override TestResult[] Execute(ITestMethod testMethod)
FILE: src/CatLib.Core.Tests/IO/TestsCombineStream.cs
class TestsCombineStream (line 22) | [TestClass]
method Initialize (line 29) | [TestInitialize]
method TestCombineStream (line 37) | [TestMethod]
method TestRead (line 44) | [TestMethod]
method TestCombineSeek (line 57) | [TestMethod]
method TestSetPosition (line 89) | [TestMethod]
method TestCanStatus (line 100) | [TestMethod]
method TestSeekOutOfRange (line 110) | [TestMethod]
method TestCannotSeekStream (line 118) | [TestMethod]
method TestCannotSeekStreamSetPosition (line 125) | [TestMethod]
method TestDispose (line 133) | [TestMethod]
method TestWrite (line 146) | [TestMethod]
method TestSetLength (line 154) | [TestMethod]
method TestFlush (line 162) | [TestMethod]
class CannotSeekStream (line 170) | private sealed class CannotSeekStream : WrapperStream
FILE: src/CatLib.Core.Tests/IO/TestsRingBuffer.cs
class TestsRingBuffer (line 19) | [TestClass]
method TestReadWrite (line 22) | [TestMethod]
method TestCanRead (line 49) | [TestMethod]
method TestCanWrite (line 66) | [TestMethod]
method TestPeek (line 86) | [TestMethod]
method TestFullBuffer (line 128) | [TestMethod]
method TestReadEmptyBuffer (line 136) | [TestMethod]
method TestOutOffset (line 148) | [TestMethod]
method TestGetBuffer (line 165) | [TestMethod]
method TestBufferReuse (line 179) | [TestMethod]
method TestCapacity (line 195) | [TestMethod]
method TestClear (line 203) | [TestMethod]
method Read (line 224) | private static byte[] Read(RingBufferStream stream)
method Peek (line 231) | private static byte[] Peek(RingBufferStream stream)
FILE: src/CatLib.Core.Tests/IO/TestsSegmentStream.cs
class TestsSegmentStream (line 20) | [TestClass]
method Initialize (line 26) | [TestInitialize]
method TestRead (line 33) | [TestMethod]
method TestReadMiddle (line 40) | [TestMethod]
method TestReadEnd (line 48) | [TestMethod]
method TestSeekEnd (line 56) | [TestMethod]
method TestSeekCurrent (line 64) | [TestMethod]
method TestSeekBegin (line 73) | [TestMethod]
method TestGetLength (line 83) | [TestMethod]
method TestGetPosition (line 90) | [TestMethod]
method TestReadBuffer (line 102) | [TestMethod]
method TestReadBufferEnd (line 111) | [TestMethod]
method TestReadBufferMin (line 121) | [TestMethod]
method TestSetLength (line 130) | [TestMethod]
method TestWrite (line 138) | [TestMethod]
method TestSeekEndToRead (line 147) | [TestMethod]
method TestSeekSmallThenStart (line 155) | [TestMethod]
method TestGivenCanNotSeek (line 163) | [TestMethod]
class CanNotSeekStream (line 170) | private class CanNotSeekStream : WrapperStream
FILE: src/CatLib.Core.Tests/IO/TestsStreamExtension.cs
class TestsStreamExtension (line 19) | [TestClass]
method TestAppendTo (line 22) | [TestMethod]
method TestStreamToText (line 32) | [TestMethod]
method TestStreamToTextLarage (line 39) | [TestMethod]
method TestDoubleWidthText (line 56) | [TestMethod]
method TestStreamToTextEmpty (line 74) | [TestMethod]
method TestStreamClosed (line 81) | [TestMethod]
FILE: src/CatLib.Core.Tests/Util/TestsArr.cs
class TestsArr (line 21) | [TestClass]
method Initialize (line 30) | [TestInitialize]
method TestMerge (line 40) | [TestMethod]
method TestMergeAllEmpty (line 48) | [TestMethod]
method TestMergeNull (line 55) | [TestMethod]
method TestMergeEmpty (line 63) | [TestMethod]
method TestRandom (line 71) | [TestMethod]
method TestSplice (line 93) | [TestMethod]
method TestBaseNegativeSplice (line 106) | [TestMethod]
method TestSimpleArgsSplice (line 119) | [TestMethod]
method TestSimpleNegativeStart (line 132) | [TestMethod]
method TestZeroStart (line 145) | [TestMethod]
method TestOverflowNegativeStart (line 159) | [TestMethod]
method TestOverflowStart (line 173) | [TestMethod]
method TestOverflowStartRepl (line 186) | [TestMethod]
method TestChunk (line 195) | [TestMethod]
method TestChunkInsufficientQuantity (line 205) | [TestMethod]
method TestChunkBound (line 214) | [TestMethod]
method TestFill (line 222) | [TestMethod]
method TestFillZeroStart (line 234) | [TestMethod]
method TestFillWithSource (line 245) | [TestMethod]
method TestFillBoundWithSource (line 263) | [TestMethod]
method TestFillOutOfRangeWithSource (line 274) | [TestMethod]
method TestFillZeroWithSource (line 285) | [TestMethod]
method TestFillThrowException (line 296) | [TestMethod]
method TestFilter (line 310) | [TestMethod]
method TestFilterExpected (line 318) | [TestMethod]
method TestFilterIEnumerable (line 326) | [TestMethod]
method TestMap (line 336) | [TestMethod]
method TestMapIEnumerable (line 354) | [TestMethod]
method TestPop (line 373) | [TestMethod]
method TestPush (line 386) | [TestMethod]
method TestReduce (line 399) | [TestMethod]
method TestSlice (line 407) | [TestMethod]
method TestShift (line 419) | [TestMethod]
method TestUnShift (line 432) | [TestMethod]
method TestReverse (line 445) | [TestMethod]
method TestReverseWithStartLength (line 463) | [TestMethod]
method TestIndexOf (line 481) | [TestMethod]
method TestIndexOfNull (line 489) | [TestMethod]
method TestIndexNotFind (line 495) | [TestMethod]
method TestIndexOfAny (line 503) | [TestMethod]
method TestIndexAnyNotFind (line 511) | [TestMethod]
method TestIndexOfAnyNull (line 519) | [TestMethod]
method TestDifference (line 529) | [TestMethod]
method TestDifferenceEmptyMatch (line 541) | [TestMethod]
method TestRemoveAt (line 553) | [TestMethod]
method TestRemoveAtWithDefault (line 566) | [TestMethod]
method TestRemoveAtNegativeNumber (line 572) | [TestMethod]
method TestCut (line 594) | [TestMethod]
method TestRemove (line 625) | [TestMethod]
method TestTest (line 657) | [TestMethod]
method TestTestOutMatch (line 663) | [TestMethod]
method TestSetReplace (line 670) | [TestMethod]
method TestSetPush (line 682) | [TestMethod]
FILE: src/CatLib.Core.Tests/Util/TestsGuard.cs
class TestsGuard (line 21) | [TestClass]
method TestRequires (line 24) | [TestMethod]
method TestExtend (line 41) | [TestMethod]
method TestRequireNotBaseException (line 63) | [TestMethod]
FILE: src/CatLib.Core.Tests/Util/TestsSortSet.cs
class TestsSortSet (line 20) | [TestClass]
method Init (line 25) | [TestInitialize]
method TestRandValue (line 31) | [TestMethod]
method TestGetElementByRank (line 49) | [TestMethodIterative(100)]
method TestCustomComparer (line 67) | [TestMethod]
method TestAddObject (line 93) | [TestMethod]
method TestGetElementRangeByRank (line 109) | [TestMethod]
method TestGetElementRangeWithOutOfRange (line 125) | [TestMethod]
method TestGetElementRangeByScore (line 131) | [TestMethod]
method TestGetElementRangeByScoreOutOfRange (line 147) | [TestMethod]
method TestRemoveRangeByScore (line 153) | [TestMethodIterative(100)]
method TestGetElementByRevRank (line 179) | [TestMethodIterative(100)]
method TestReversEnumerator (line 192) | [TestMethod]
method TestScoreRangeCountBound (line 208) | [TestMethod]
method TestGetRangeCountWithOutOfRange (line 223) | [TestMethod]
method TestScoreRangeCount (line 229) | [TestMethod]
method TestAdd (line 250) | [TestMethod]
method TestRemove (line 276) | [TestMethod]
method TestGetElementByRankAndIndexer (line 298) | [TestMethod]
method TestGetRevRank (line 316) | [TestMethod]
method TestGetRank (line 327) | [TestMethodIterative(100)]
method TestSequentialAdd (line 352) | [TestMethod]
method TestEmptyListForeach (line 367) | [TestMethod]
method TestOverrideElement (line 381) | [TestMethod]
method TestContains (line 389) | [TestMethod]
method TestGetScore (line 398) | [TestMethod]
method TestGetElementByRankOverflow (line 405) | [TestMethod]
method TestGetElementByRankEmpty (line 413) | [TestMethod]
method TestGetRankOverflow (line 420) | [TestMethod]
method TestGetRevRankOverflow (line 427) | [TestMethod]
method TestMaxLevelLimit (line 436) | [TestMethod]
method TestClear (line 446) | [TestMethod]
method TestFirstLast (line 468) | [TestMethod]
method TestPop (line 500) | [TestMethod]
method TestShift (line 516) | [TestMethod]
method TestFirstBound (line 532) | [TestMethod]
method TestLastBound (line 539) | [TestMethod]
method TestToArray (line 546) | [TestMethod]
method TestSameScore (line 567) | [TestMethod]
method TestRemoveNotExistsElement (line 586) | [TestMethod]
method TestPopEmpty (line 592) | [TestMethod]
method TestShiftEmpty (line 599) | [TestMethod]
method TestIterationsDeleted (line 606) | [TestMethod]
method TestGetScoreNotFound (line 640) | [TestMethod]
class PriorityComparer (line 647) | private class PriorityComparer : IComparer<int>
method Compare (line 649) | public int Compare(int x, int y)
FILE: src/CatLib.Core.Tests/Util/TestsStr.cs
class TestsStr (line 20) | [TestClass]
method TestAsteriskWildcard (line 23) | [TestMethod]
method TestIs (line 30) | [TestMethod]
method TestSplit (line 41) | [TestMethod]
method TestSplitEmpty (line 58) | [TestMethod]
method TestRepeat (line 65) | [TestMethod]
method TestShuffle (line 73) | [TestMethod]
method TestShuffleEmpty (line 87) | [TestMethod]
method TestSubstringCount (line 93) | [TestMethod]
method TestSubstringStartLargeThanLength (line 118) | [TestMethod]
method TestReverse (line 124) | [TestMethod]
method TestPad (line 130) | [TestMethod]
method TestStrPadEmpty (line 152) | [TestMethod]
method TestAfter (line 165) | [TestMethod]
method TestContains (line 175) | [TestMethod]
method TestReplace (line 182) | [TestMethod]
method TestReplaceFirst (line 192) | [TestMethod]
method TestReplaceLast (line 202) | [TestMethod]
method TestRandom (line 212) | [TestMethod]
method TestSpace (line 228) | [TestMethod]
method TestTruncate (line 234) | [TestMethod]
method TestMethod (line 280) | [TestMethod]
method TestIsArray (line 295) | [TestMethod]
method TestLevenshtein (line 320) | [TestMethod]
method TestLevenshteinLargeThan255 (line 328) | [TestMethod]
method TestLevenshteinNull (line 341) | [TestMethod]
method TestJoinList (line 347) | [TestMethod]
method TestJoinListChar (line 361) | [TestMethod]
FILE: src/CatLib.Core/CatLib/App.cs
class App (line 24) | [ExcludeFromCodeCoverage]
method Terminate (line 83) | public static void Terminate()
method Register (line 89) | public static void Register(IServiceProvider provider, bool force = fa...
method IsRegistered (line 95) | public static bool IsRegistered(IServiceProvider provider)
method GetRuntimeId (line 101) | public static long GetRuntimeId()
method UnbindMethod (line 107) | public static void UnbindMethod(object target)
method Invoke (line 113) | public static object Invoke(string method, params object[] userParams)
method OnFindType (line 119) | public static IContainer OnFindType(Func<string, Type> func, int prior...
method OnRebound (line 125) | public static IContainer OnRebound(string service, Action<object> call...
method GetBind (line 131) | public static IBindData GetBind(string service)
method GetBind (line 137) | public static IBindData GetBind<TService>()
method HasInstance (line 143) | public static bool HasInstance(string service)
method HasInstance (line 149) | public static bool HasInstance<TService>()
method IsResolved (line 159) | public static bool IsResolved(string service)
method IsResolved (line 165) | public static bool IsResolved<TService>()
method HasBind (line 171) | public static bool HasBind(string service)
method HasBind (line 177) | public static bool HasBind<TService>()
method CanMake (line 183) | public static bool CanMake(string service)
method CanMake (line 189) | public static bool CanMake<TService>()
method IsStatic (line 195) | public static bool IsStatic(string service)
method IsStatic (line 201) | public static bool IsStatic<TService>()
method IsAlias (line 207) | public static bool IsAlias(string name)
method IsAlias (line 213) | public static bool IsAlias<TService>()
method Alias (line 219) | public static IContainer Alias(string alias, string service)
method Alias (line 225) | public static IContainer Alias<TAlias, TService>()
method Extend (line 231) | public static void Extend(string service, Func<object, IContainer, obj...
method Extend (line 237) | public static void Extend(string service, Func<object, object> closure)
method Extend (line 243) | public static void Extend<TService, TConcrete>(Func<TConcrete, object>...
method Extend (line 249) | public static void Extend<TService, TConcrete>(Func<TConcrete, IContai...
method Extend (line 255) | public static void Extend<TConcrete>(Func<TConcrete, IContainer, objec...
method Extend (line 261) | public static void Extend<TConcrete>(Func<TConcrete, object> closure)
method Bind (line 267) | public static IBindData Bind<TService>()
method Bind (line 273) | public static IBindData Bind<TService, TConcrete>()
method Bind (line 279) | public static IBindData Bind(string service, Type concrete, bool isSta...
method Bind (line 285) | public static IBindData Bind(string service, Func<IContainer, object[]...
method Bind (line 291) | public static IBindData Bind<TService>(Func<IContainer, object[], obje...
method Bind (line 297) | public static IBindData Bind<TService>(Func<object[], object> concrete)
method Bind (line 303) | public static IBindData Bind<TService>(Func<object> concrete)
method Bind (line 309) | public static IBindData Bind(string service, Func<IContainer, object[]...
method BindIf (line 315) | public static bool BindIf(string service, Func<IContainer, object[], o...
method BindIf (line 321) | public static bool BindIf(string service, Type concrete, bool isStatic...
method BindIf (line 327) | public static bool BindIf<TService, TConcrete>(out IBindData bindData)
method BindIf (line 333) | public static bool BindIf<TService>(out IBindData bindData)
method BindIf (line 339) | public static bool BindIf<TService>(Func<IContainer, object[], object>...
method BindIf (line 345) | public static bool BindIf<TService>(Func<object[], object> concrete, o...
method BindIf (line 351) | public static bool BindIf<TService>(Func<object> concrete, out IBindDa...
method BindIf (line 357) | public static bool BindIf(string service, Func<IContainer, object[], o...
method Singleton (line 363) | public static IBindData Singleton<TService, TConcrete>()
method Singleton (line 369) | public static IBindData Singleton<TService>()
method Singleton (line 375) | public static IBindData Singleton<TService>(Func<IContainer, object[],...
method Singleton (line 381) | public static IBindData Singleton<TService>(Func<object[], object> con...
method Singleton (line 387) | public static IBindData Singleton<TService>(Func<object> concrete)
method Singleton (line 393) | public static IBindData Singleton(string service, Func<IContainer, obj...
method SingletonIf (line 399) | public static bool SingletonIf<TService, TConcrete>(out IBindData bind...
method SingletonIf (line 405) | public static bool SingletonIf<TService>(out IBindData bindData)
method SingletonIf (line 411) | public static bool SingletonIf<TService>(Func<IContainer, object[], ob...
method SingletonIf (line 417) | public static bool SingletonIf<TService>(Func<object[], object> concre...
method SingletonIf (line 423) | public static bool SingletonIf<TService>(Func<object> concrete, out IB...
method SingletonIf (line 429) | public static bool SingletonIf(string service, Func<IContainer, object...
method BindMethod (line 435) | public static IMethodBind BindMethod(string method, object target, Met...
method BindMethod (line 441) | public static IMethodBind BindMethod(string method, object target,
method BindMethod (line 448) | public static IMethodBind BindMethod(string method, Func<object> callb...
method BindMethod (line 454) | public static IMethodBind BindMethod<T1>(string method, Func<T1, objec...
method BindMethod (line 460) | public static IMethodBind BindMethod<T1, T2>(string method, Func<T1, T...
method BindMethod (line 466) | public static IMethodBind BindMethod<T1, T2, T3>(string method, Func<T...
method BindMethod (line 472) | public static IMethodBind BindMethod<T1, T2, T3, T4>(string method, Fu...
method Unbind (line 478) | public static void Unbind(string service)
method Unbind (line 484) | public static void Unbind<TService>()
method Tagged (line 490) | public static object[] Tagged(string tag)
method Tag (line 496) | public static void Tag(string tag, params string[] service)
method Tag (line 502) | public static void Tag<TService>(string tag)
method Instance (line 508) | public static object Instance(string service, object instance)
method Instance (line 514) | public static void Instance<TService>(object instance)
method Release (line 520) | public static bool Release(string service)
method Release (line 526) | public static bool Release<TService>()
method Release (line 532) | public static bool Release(ref object[] instances, bool reverse = true)
method Call (line 538) | public static object Call(object instance, MethodInfo methodInfo, para...
method Call (line 544) | public static object Call(object instance, string method, params objec...
method Call (line 550) | public static void Call<T1>(Action<T1> method, params object[] userPar...
method Call (line 556) | public static void Call<T1, T2>(Action<T1, T2> method, params object[]...
method Call (line 562) | public static void Call<T1, T2, T3>(Action<T1, T2, T3> method, params ...
method Call (line 568) | public static void Call<T1, T2, T3, T4>(Action<T1, T2, T3, T4> method,...
method Wrap (line 574) | public static Action Wrap<T1>(Action<T1> method, params object[] userP...
method Wrap (line 580) | public static Action Wrap<T1, T2>(Action<T1, T2> method, params object...
method Wrap (line 586) | public static Action Wrap<T1, T2, T3>(Action<T1, T2, T3> method, param...
method Wrap (line 592) | public static Action Wrap<T1, T2, T3, T4>(Action<T1, T2, T3, T4> metho...
method Make (line 598) | public static object Make(string service, params object[] userParams)
method Make (line 604) | public static TService Make<TService>(params object[] userParams)
method Make (line 614) | public static object Make(Type type, params object[] userParams)
method Factory (line 620) | public static Func<object> Factory(string service, params object[] use...
method Factory (line 626) | public static Func<TService> Factory<TService>(params object[] userPar...
method OnRelease (line 632) | public static IContainer OnRelease(Action<IBindData, object> action)
method OnRelease (line 638) | public static IContainer OnRelease(Action<object> callback)
method OnRelease (line 644) | public static IContainer OnRelease<TWhere>(Action<TWhere> closure)
method OnRelease (line 650) | public static IContainer OnRelease<TWhere>(Action<IBindData, TWhere> c...
method OnResolving (line 656) | public static IContainer OnResolving(Action<IBindData, object> closure)
method OnResolving (line 662) | public static IContainer OnResolving(Action<object> callback)
method OnResolving (line 668) | public static IContainer OnResolving<TWhere>(Action<TWhere> closure)
method OnResolving (line 674) | public static IContainer OnResolving<TWhere>(Action<IBindData, TWhere>...
method OnAfterResolving (line 680) | public static IContainer OnAfterResolving(Action<IBindData, object> cl...
method OnAfterResolving (line 686) | public static IContainer OnAfterResolving(Action<object> closure)
method OnAfterResolving (line 692) | public static IContainer OnAfterResolving<TWhere>(Action<TWhere> closure)
method OnAfterResolving (line 698) | public static IContainer OnAfterResolving<TWhere>(Action<IBindData, TW...
method Watch (line 704) | public static void Watch<TService>(Action method)
method Watch (line 710) | public static void Watch<TService>(Action<TService> method)
method Type2Service (line 716) | public static string Type2Service(Type type)
method Type2Service (line 722) | public static string Type2Service<TService>()
FILE: src/CatLib.Core/CatLib/Application.cs
class Application (line 27) | public class Application : Container.Container, IApplication
method Application (line 44) | public Application()
method New (line 101) | public static Application New(bool global = true)
method SetDispatcher (line 116) | public void SetDispatcher(IEventDispatcher dispatcher)
method GetDispatcher (line 123) | public IEventDispatcher GetDispatcher()
method Terminate (line 129) | public virtual void Terminate()
method Bootstrap (line 148) | public virtual void Bootstrap(params IBootstrap[] bootstraps)
method Init (line 194) | public virtual void Init()
method Register (line 224) | public virtual void Register(IServiceProvider provider, bool force = f...
method IsRegistered (line 279) | public bool IsRegistered(IServiceProvider provider)
method GetRuntimeId (line 286) | public long GetRuntimeId()
method InitProvider (line 295) | protected virtual void InitProvider(IServiceProvider provider)
method GuardConstruct (line 302) | protected override void GuardConstruct(string method)
method RegisterBaseBindings (line 313) | private void RegisterBaseBindings()
method Raise (line 319) | private T Raise<T>(T args)
FILE: src/CatLib.Core/CatLib/DebugLevel.cs
type DebugLevel (line 17) | public enum DebugLevel
FILE: src/CatLib.Core/CatLib/Events/AfterBootEventArgs.cs
class AfterBootEventArgs (line 17) | public class AfterBootEventArgs : ApplicationEventArgs
method AfterBootEventArgs (line 23) | public AfterBootEventArgs(IApplication application)
FILE: src/CatLib.Core/CatLib/Events/AfterInitEventArgs.cs
class AfterInitEventArgs (line 17) | public class AfterInitEventArgs : ApplicationEventArgs
method AfterInitEventArgs (line 23) | public AfterInitEventArgs(IApplication application)
FILE: src/CatLib.Core/CatLib/Events/AfterTerminateEventArgs.cs
class AfterTerminateEventArgs (line 17) | public class AfterTerminateEventArgs : ApplicationEventArgs
method AfterTerminateEventArgs (line 23) | public AfterTerminateEventArgs(IApplication application)
FILE: src/CatLib.Core/CatLib/Events/ApplicationEventArgs.cs
class ApplicationEventArgs (line 19) | public class ApplicationEventArgs : EventArgs
method ApplicationEventArgs (line 25) | public ApplicationEventArgs(IApplication application)
FILE: src/CatLib.Core/CatLib/Events/ApplicationEvents.cs
class ApplicationEvents (line 17) | public static class ApplicationEvents
FILE: src/CatLib.Core/CatLib/Events/BeforeBootEventArgs.cs
class BeforeBootEventArgs (line 17) | public class BeforeBootEventArgs : ApplicationEventArgs
method BeforeBootEventArgs (line 26) | public BeforeBootEventArgs(IBootstrap[] bootstraps, IApplication appli...
method GetBootstraps (line 36) | public IBootstrap[] GetBootstraps()
method SetBootstraps (line 45) | public void SetBootstraps(IBootstrap[] bootstraps)
FILE: src/CatLib.Core/CatLib/Events/BeforeInitEventArgs.cs
class BeforeInitEventArgs (line 17) | public class BeforeInitEventArgs : ApplicationEventArgs
method BeforeInitEventArgs (line 24) | public BeforeInitEventArgs(IApplication application)
FILE: src/CatLib.Core/CatLib/Events/BeforeTerminateEventArgs.cs
class BeforeTerminateEventArgs (line 17) | public class BeforeTerminateEventArgs : ApplicationEventArgs
method BeforeTerminateEventArgs (line 23) | public BeforeTerminateEventArgs(IApplication application)
FILE: src/CatLib.Core/CatLib/Events/BootingEventArgs.cs
class BootingEventArgs (line 19) | public class BootingEventArgs : ApplicationEventArgs, IStoppableEvent
method BootingEventArgs (line 28) | public BootingEventArgs(IBootstrap bootstrap, IApplication application)
method GetBootstrap (line 47) | public IBootstrap GetBootstrap()
method Skip (line 55) | public void Skip()
FILE: src/CatLib.Core/CatLib/Events/InitProviderEventArgs.cs
class InitProviderEventArgs (line 17) | public class InitProviderEventArgs : ApplicationEventArgs
method InitProviderEventArgs (line 26) | public InitProviderEventArgs(IServiceProvider provider, IApplication a...
method GetServiceProvider (line 36) | public IServiceProvider GetServiceProvider()
FILE: src/CatLib.Core/CatLib/Events/RegisterProviderEventArgs.cs
class RegisterProviderEventArgs (line 19) | public class RegisterProviderEventArgs : ApplicationEventArgs, IStoppabl...
method RegisterProviderEventArgs (line 28) | public RegisterProviderEventArgs(IServiceProvider provider, IApplicati...
method GetServiceProvider (line 47) | public IServiceProvider GetServiceProvider()
method Skip (line 55) | public void Skip()
FILE: src/CatLib.Core/CatLib/Events/StartCompletedEventArgs.cs
class StartCompletedEventArgs (line 17) | public class StartCompletedEventArgs : ApplicationEventArgs
method StartCompletedEventArgs (line 23) | public StartCompletedEventArgs(IApplication application)
FILE: src/CatLib.Core/CatLib/Facade.cs
class Facade (line 27) | public abstract class Facade<TService>
method Facade (line 39) | static Facade()
method Make (line 66) | internal static TService Make(params object[] userParams)
method Resolve (line 72) | private static TService Resolve(params object[] userParams)
method OnRelease (line 105) | private static void OnRelease(IBindData oldBinder, object instance)
method ServiceRebound (line 120) | private static void ServiceRebound(TService newService)
method Rebind (line 131) | private static void Rebind(IBindData newBinder)
method Build (line 146) | private static TService Build(params object[] userParams)
FILE: src/CatLib.Core/CatLib/IApplication.cs
type IApplication (line 20) | public interface IApplication : IContainer
method GetDispatcher (line 36) | IEventDispatcher GetDispatcher();
method Register (line 43) | void Register(IServiceProvider provider, bool force = false);
method IsRegistered (line 50) | bool IsRegistered(IServiceProvider provider);
method GetRuntimeId (line 56) | long GetRuntimeId();
method Terminate (line 61) | void Terminate();
FILE: src/CatLib.Core/CatLib/IBootstrap.cs
type IBootstrap (line 17) | public interface IBootstrap
method Bootstrap (line 22) | void Bootstrap();
FILE: src/CatLib.Core/CatLib/IServiceProvider.cs
type IServiceProvider (line 17) | public interface IServiceProvider
method Init (line 22) | void Init();
method Register (line 27) | void Register();
FILE: src/CatLib.Core/CatLib/ServiceProvider.cs
class ServiceProvider (line 20) | [ExcludeFromCodeCoverage]
method Init (line 29) | public virtual void Init()
method Register (line 34) | public virtual void Register()
method SetApplication (line 38) | internal void SetApplication(IApplication application)
FILE: src/CatLib.Core/CatLib/StartProcess.cs
type StartProcess (line 17) | public enum StartProcess
FILE: src/CatLib.Core/Container/BindData.cs
class BindData (line 21) | public sealed class BindData : Bindable<IBindData>, IBindData
method BindData (line 45) | public BindData(CatLibContainer container, string service, Func<IConta...
method Alias (line 59) | public IBindData Alias(string alias)
method Tag (line 69) | public IBindData Tag(string tag)
method OnResolving (line 79) | public IBindData OnResolving(Action<IBindData, object> closure)
method OnAfterResolving (line 86) | public IBindData OnAfterResolving(Action<IBindData, object> closure)
method OnRelease (line 93) | public IBindData OnRelease(Action<IBindData, object> closure)
method TriggerResolving (line 105) | internal object TriggerResolving(object instance)
method TriggerAfterResolving (line 110) | internal object TriggerAfterResolving(object instance)
method TriggerRelease (line 115) | internal object TriggerRelease(object instance)
method ReleaseBind (line 121) | protected override void ReleaseBind()
method AddClosure (line 126) | private void AddClosure(Action<IBindData, object> closure, ref List<Ac...
FILE: src/CatLib.Core/Container/BindDataExtension.cs
class BindDataExtension (line 20) | public static class BindDataExtension
method Alias (line 24) | public static IBindData Alias<TAlias>(this IBindData bindData)
method OnResolving (line 30) | public static IBindData OnResolving(this IBindData bindData, Action cl...
method OnResolving (line 40) | public static IBindData OnResolving(this IBindData bindData, Action<ob...
method OnResolving (line 51) | public static IBindData OnResolving<T>(this IBindData bindData, Action...
method OnResolving (line 64) | public static IBindData OnResolving<T>(this IBindData bindData, Action...
method OnAfterResolving (line 77) | public static IBindData OnAfterResolving(this IBindData bindData, Acti...
method OnAfterResolving (line 87) | public static IBindData OnAfterResolving(this IBindData bindData, Acti...
method OnAfterResolving (line 98) | public static IBindData OnAfterResolving<T>(this IBindData bindData, A...
method OnAfterResolving (line 111) | public static IBindData OnAfterResolving<T>(this IBindData bindData, A...
method OnRelease (line 124) | public static IBindData OnRelease(this IBindData bindData, Action clos...
method OnRelease (line 134) | public static IBindData OnRelease(this IBindData bindData, Action<obje...
method OnRelease (line 145) | public static IBindData OnRelease<T>(this IBindData bindData, Action<T...
method OnRelease (line 158) | public static IBindData OnRelease<T>(this IBindData bindData, Action<I...
FILE: src/CatLib.Core/Container/Bindable.cs
class Bindable (line 22) | public abstract class Bindable : IBindable
method Bindable (line 34) | protected Bindable(Container container, string service)
method Unbind (line 50) | public void Unbind()
method AddContextual (line 61) | internal void AddContextual(string needs, string given)
method AddContextual (line 80) | internal void AddContextual(string needs, Func<object> given)
method GetContextual (line 102) | internal string GetContextual(string needs)
method GetContextualClosure (line 114) | internal Func<object> GetContextualClosure(string needs)
method ReleaseBind (line 125) | protected abstract void ReleaseBind();
method AssertDestroyed (line 130) | protected void AssertDestroyed()
method Bindable (line 155) | protected Bindable(Container container, string service)
method Needs (line 161) | public IGivenData<TReturn> Needs(string service)
method Needs (line 176) | public IGivenData<TReturn> Needs<TService>()
class Bindable (line 142) | public abstract class Bindable<TReturn> : Bindable, IBindable<TReturn>
method Bindable (line 34) | protected Bindable(Container container, string service)
method Unbind (line 50) | public void Unbind()
method AddContextual (line 61) | internal void AddContextual(string needs, string given)
method AddContextual (line 80) | internal void AddContextual(string needs, Func<object> given)
method GetContextual (line 102) | internal string GetContextual(string needs)
method GetContextualClosure (line 114) | internal Func<object> GetContextualClosure(string needs)
method ReleaseBind (line 125) | protected abstract void ReleaseBind();
method AssertDestroyed (line 130) | protected void AssertDestroyed()
method Bindable (line 155) | protected Bindable(Container container, string service)
method Needs (line 161) | public IGivenData<TReturn> Needs(string service)
method Needs (line 176) | public IGivenData<TReturn> Needs<TService>()
FILE: src/CatLib.Core/Container/Container.cs
class Container (line 26) | public class Container : IContainer
method Container (line 132) | public Container(int prime = 64)
method Tag (line 180) | public void Tag(string tag, params string[] services)
method Tagged (line 202) | public object[] Tagged(string tag)
method GetBind (line 215) | public IBindData GetBind(string service)
method HasBind (line 228) | public bool HasBind(string service)
method HasInstance (line 234) | public bool HasInstance(string service)
method IsResolved (line 243) | public bool IsResolved(string service)
method CanMake (line 252) | public bool CanMake(string service)
method IsStatic (line 267) | public bool IsStatic(string service)
method IsAlias (line 274) | public bool IsAlias(string name)
method Alias (line 281) | public IContainer Alias(string alias, string service)
method BindIf (line 325) | public bool BindIf(string service, Func<IContainer, object[], object> ...
method BindIf (line 339) | public bool BindIf(string service, Type concrete, bool isStatic, out I...
method Bind (line 352) | public IBindData Bind(string service, Type concrete, bool isStatic)
method Bind (line 366) | public IBindData Bind(string service, Func<IContainer, object[], objec...
method BindMethod (line 412) | public IMethodBind BindMethod(string method, object target, MethodInfo...
method UnbindMethod (line 420) | public void UnbindMethod(object target)
method Invoke (line 426) | public object Invoke(string method, params object[] userParams)
method Call (line 433) | public object Call(object target, MethodInfo methodInfo, params object...
method Make (line 450) | public object Make(string service, params object[] userParams)
method Extend (line 457) | public void Extend(string service, Func<object, IContainer, object> cl...
method ClearExtenders (line 498) | public void ClearExtenders(string service)
method Instance (line 514) | public object Instance(string service, object instance)
method Release (line 568) | public bool Release(object mixed)
method OnFindType (line 618) | public IContainer OnFindType(Func<string, Type> func, int priority = i...
method OnRelease (line 627) | public IContainer OnRelease(Action<IBindData, object> closure)
method OnResolving (line 634) | public IContainer OnResolving(Action<IBindData, object> closure)
method OnAfterResolving (line 641) | public IContainer OnAfterResolving(Action<IBindData, object> closure)
method OnRebound (line 648) | public IContainer OnRebound(string service, Action<object> callback)
method Unbind (line 670) | public void Unbind(string service)
method Flush (line 678) | public virtual void Flush()
method Type2Service (line 715) | public string Type2Service(Type type)
method Trigger (line 727) | internal static object Trigger(IBindData bindData, object instance, Li...
method Unbind (line 746) | internal void Unbind(IBindable bindable)
method GetDependencies (line 770) | protected internal virtual object[] GetDependencies(Bindable makeServi...
method IsBasicType (line 846) | protected virtual bool IsBasicType(Type type)
method IsUnableType (line 856) | protected virtual bool IsUnableType(Type type)
method WrapperTypeBuilder (line 868) | protected virtual Func<IContainer, object[], object> WrapperTypeBuilde...
method GetDependenciesFromUserParams (line 880) | protected virtual object GetDependenciesFromUserParams(ParameterInfo b...
method ChangeType (line 911) | protected virtual bool ChangeType(ref object result, Type conversionType)
method GetPropertyNeedsService (line 958) | protected virtual string GetPropertyNeedsService(PropertyInfo property...
method GetParamNeedsService (line 968) | protected virtual string GetParamNeedsService(ParameterInfo baseParam)
method GetContextualClosure (line 980) | protected virtual Func<object> GetContextualClosure(Bindable makeServi...
method GetContextualService (line 992) | protected virtual string GetContextualService(Bindable makeServiceBind...
method MakeFromContextualClosure (line 1006) | protected virtual bool MakeFromContextualClosure(Func<object> closure,...
method MakeFromContextualService (line 1023) | protected virtual bool MakeFromContextualService(string service, Type ...
method ResloveFromContextual (line 1044) | protected virtual bool ResloveFromContextual(Bindable makeServiceBindD...
method ResolveAttrPrimitive (line 1066) | protected virtual object ResolveAttrPrimitive(Bindable makeServiceBind...
method ResloveAttrClass (line 1093) | protected virtual object ResloveAttrClass(Bindable makeServiceBindData...
method ResolvePrimitive (line 1117) | protected virtual object ResolvePrimitive(Bindable makeServiceBindData...
method ResloveClass (line 1145) | protected virtual object ResloveClass(Bindable makeServiceBindData, st...
method GetVariableTag (line 1169) | protected virtual char GetVariableTag()
method GetBuildStackDebugMessage (line 1178) | protected virtual string GetBuildStackDebugMessage()
method MakeBuildFaildException (line 1191) | protected virtual UnresolvableException MakeBuildFaildException(string...
method GetInnerExceptionMessage (line 1207) | protected virtual string GetInnerExceptionMessage(SException innerExce...
method MakeUnresolvableException (line 1234) | protected virtual UnresolvableException MakeUnresolvableException(stri...
method MakeCircularDependencyException (line 1245) | protected virtual LogicException MakeCircularDependencyException(strin...
method FormatService (line 1257) | protected virtual string FormatService(string service)
method CanInject (line 1268) | protected virtual bool CanInject(Type type, object instance)
method GuardUserParamsCount (line 1277) | protected virtual void GuardUserParamsCount(int count)
method GuardResolveInstance (line 1290) | protected virtual void GuardResolveInstance(object instance, string ma...
method SpeculatedServiceType (line 1303) | protected virtual Type SpeculatedServiceType(string service)
method AttributeInject (line 1327) | protected virtual void AttributeInject(Bindable makeServiceBindData, o...
method CheckCompactInjectUserParams (line 1376) | protected virtual bool CheckCompactInjectUserParams(ParameterInfo base...
method GetCompactInjectUserParams (line 1393) | protected virtual object GetCompactInjectUserParams(ParameterInfo base...
method GetParamsMatcher (line 1421) | protected virtual Func<ParameterInfo, object> GetParamsMatcher(ref obj...
method GetConstructorsInjectParams (line 1439) | protected virtual object[] GetConstructorsInjectParams(Bindable makeSe...
method GetServiceWithInstanceObject (line 1474) | protected string GetServiceWithInstanceObject(object instance)
method GuardConstruct (line 1485) | protected virtual void GuardConstruct(string method)
method GuardServiceName (line 1493) | protected virtual void GuardServiceName(string service)
method GuardMethodName (line 1509) | protected virtual void GuardMethodName(string method)
method MakeEmptyBindData (line 1518) | protected virtual BindData MakeEmptyBindData(string service)
method Resolve (line 1529) | protected object Resolve(string service, params object[] userParams)
method Build (line 1579) | protected virtual object Build(BindData makeServiceBindData, object[] ...
method CreateInstance (line 1596) | protected virtual object CreateInstance(Bindable makeServiceBindData, ...
method CreateInstance (line 1618) | protected virtual object CreateInstance(Type makeServiceType, object[]...
method GetBindFillable (line 1635) | protected BindData GetBindFillable(string service)
method GuardFlushing (line 1645) | private void GuardFlushing()
method AliasToService (line 1658) | private string AliasToService(string name)
method TriggerOnResolving (line 1670) | private object TriggerOnResolving(BindData bindData, object instance)
method TriggerOnAfterResolving (line 1681) | private object TriggerOnAfterResolving(BindData bindData, object insta...
method TriggerOnRelease (line 1691) | private void TriggerOnRelease(IBindData bindData, object instance)
method TriggerOnRebound (line 1704) | private void TriggerOnRebound(string service, object instance = null)
method DisposeInstance (line 1731) | private void DisposeInstance(object instance)
method GetOnReboundCallbacks (line 1744) | private IList<Action<object>> GetOnReboundCallbacks(string service)
method HasOnReboundCallbacks (line 1754) | private bool HasOnReboundCallbacks(string service)
method Extend (line 1766) | private object Extend(string service, object instance)
method Inject (line 1795) | private object Inject(Bindable bindable, object instance)
method GetParamsTypeInUserParams (line 1809) | private IParams[] GetParamsTypeInUserParams(ref object[] userParams)
method MakeParamsMatcher (line 1828) | private Func<ParameterInfo, object> MakeParamsMatcher(IParams[] tables)
method AddClosure (line 1859) | private void AddClosure(Action<IBindData, object> closure, List<Action...
FILE: src/CatLib.Core/Container/ContainerExtension.cs
class ContainerExtension (line 23) | public static class ContainerExtension
method GetBind (line 31) | public static IBindData GetBind<TService>(this IContainer container)
method HasBind (line 42) | public static bool HasBind<TService>(this IContainer container)
method HasInstance (line 53) | public static bool HasInstance<TService>(this IContainer container)
method IsResolved (line 64) | public static bool IsResolved<TService>(this IContainer container)
method CanMake (line 75) | public static bool CanMake<TService>(this IContainer container)
method IsStatic (line 86) | public static bool IsStatic<TService>(this IContainer container)
method IsAlias (line 97) | public static bool IsAlias<TService>(this IContainer container)
method Alias (line 109) | public static IContainer Alias<TAlias, TService>(this IContainer conta...
method Bind (line 120) | public static IBindData Bind<TService>(this IContainer container)
method Bind (line 132) | public static IBindData Bind<TService, TConcrete>(this IContainer cont...
method Bind (line 144) | public static IBindData Bind<TService>(this IContainer container, Func...
method Bind (line 157) | public static IBindData Bind<TService>(this IContainer container, Func...
method Bind (line 170) | public static IBindData Bind<TService>(this IContainer container, Func...
method Bind (line 183) | public static IBindData Bind(this IContainer container, string service,
method BindIf (line 198) | public static bool BindIf<TService, TConcrete>(this IContainer contain...
method BindIf (line 210) | public static bool BindIf<TService>(this IContainer container, out IBi...
method BindIf (line 223) | public static bool BindIf<TService>(this IContainer container, Func<IC...
method BindIf (line 237) | public static bool BindIf<TService>(this IContainer container, Func<ob...
method BindIf (line 252) | public static bool BindIf<TService>(this IContainer container, Func<ob...
method BindIf (line 267) | public static bool BindIf(this IContainer container, string service,
method Singleton (line 280) | public static IBindData Singleton(this IContainer container, string se...
method Singleton (line 293) | public static IBindData Singleton<TService, TConcrete>(this IContainer...
method Singleton (line 304) | public static IBindData Singleton<TService>(this IContainer container)
method Singleton (line 316) | public static IBindData Singleton<TService>(
method Singleton (line 331) | public static IBindData Singleton<TService>(this IContainer container,...
method Singleton (line 344) | public static IBindData Singleton<TService>(
method SingletonIf (line 360) | public static bool SingletonIf<TService, TConcrete>(this IContainer co...
method SingletonIf (line 372) | public static bool SingletonIf<TService>(this IContainer container, ou...
method SingletonIf (line 385) | public static bool SingletonIf<TService>(this IContainer container, Fu...
method SingletonIf (line 398) | public static bool SingletonIf<TService>(this IContainer container, Fu...
method SingletonIf (line 413) | public static bool SingletonIf<TService>(this IContainer container, Fu...
method SingletonIf (line 428) | public static bool SingletonIf(this IContainer container, string service,
method BindMethod (line 442) | public static IMethodBind BindMethod(this IContainer container, string...
method BindMethod (line 457) | public static IMethodBind BindMethod(this IContainer container, string...
method BindMethod (line 471) | public static IMethodBind BindMethod<T1>(this IContainer container, st...
method BindMethod (line 485) | public static IMethodBind BindMethod<T1, T2>(this IContainer container...
method BindMethod (line 499) | public static IMethodBind BindMethod<T1, T2, T3>(this IContainer conta...
method BindMethod (line 513) | public static IMethodBind BindMethod<T1, T2, T3, T4>(this IContainer c...
method Unbind (line 525) | public static void Unbind<TService>(this IContainer container)
method Tag (line 536) | public static void Tag<TService>(this IContainer container, string tag)
method Instance (line 548) | public static object Instance<TService>(this IContainer container, obj...
method Release (line 559) | public static bool Release<TService>(this IContainer container)
method Release (line 571) | public static bool Release(this IContainer container, ref object[] ins...
method Call (line 614) | public static void Call<T1>(this IContainer container, Action<T1> meth...
method Call (line 626) | public static void Call<T1, T2>(this IContainer container, Action<T1, ...
method Call (line 638) | public static void Call<T1, T2, T3>(this IContainer container, Action<...
method Call (line 650) | public static void Call<T1, T2, T3, T4>(this IContainer container, Act...
method Call (line 664) | public static object Call(this IContainer container, object target, st...
method Wrap (line 686) | public static Action Wrap<T1>(this IContainer container, Action<T1> me...
method Wrap (line 704) | public static Action Wrap<T1, T2>(this IContainer container, Action<T1...
method Wrap (line 722) | public static Action Wrap<T1, T2, T3>(this IContainer container, Actio...
method Wrap (line 740) | public static Action Wrap<T1, T2, T3, T4>(this IContainer container, A...
method Make (line 758) | public static TService Make<TService>(this IContainer container, param...
method Make (line 770) | public static object Make(this IContainer container, Type type, params...
method Extend (line 784) | public static void Extend(this IContainer container, string service, F...
method Extend (line 795) | public static void Extend<TService, TConcrete>(this IContainer contain...
method Extend (line 806) | public static void Extend<TService, TConcrete>(this IContainer contain...
method Extend (line 820) | public static void Extend<TConcrete>(this IContainer container, Func<T...
method Extend (line 840) | public static void Extend<TConcrete>(this IContainer container, Func<T...
method OnRelease (line 859) | public static IContainer OnRelease(this IContainer container, Action<o...
method OnRelease (line 871) | public static IContainer OnRelease<T>(this IContainer container, Actio...
method OnRelease (line 889) | public static IContainer OnRelease<T>(this IContainer container, Actio...
method OnResolving (line 907) | public static IContainer OnResolving(this IContainer container, Action...
method OnResolving (line 924) | public static IContainer OnResolving<T>(this IContainer container, Act...
method OnResolving (line 944) | public static IContainer OnResolving<T>(this IContainer container, Act...
method OnAfterResolving (line 962) | public static IContainer OnAfterResolving(this IContainer container, A...
method OnAfterResolving (line 979) | public static IContainer OnAfterResolving<T>(this IContainer container...
method OnAfterResolving (line 999) | public static IContainer OnAfterResolving<T>(this IContainer container...
method Watch (line 1017) | public static void Watch<TService>(this IContainer container, Action m...
method Watch (line 1029) | public static void Watch<TService>(this IContainer container, Action<T...
method Type2Service (line 1041) | public static string Type2Service<TService>(this IContainer container)
method Factory (line 1053) | public static Func<TService> Factory<TService>(this IContainer contain...
method Factory (line 1065) | public static Func<object> Factory(this IContainer container, string s...
FILE: src/CatLib.Core/Container/GivenData.cs
class GivenData (line 18) | internal sealed class GivenData<TReturn> : IGivenData<TReturn>
method GivenData (line 30) | internal GivenData(Container container, Bindable<TReturn> bindable)
method Given (line 37) | public TReturn Given(string service)
method Given (line 46) | public TReturn Given<TService>()
method Given (line 52) | public TReturn Given(Func<object> closure)
method Needs (line 60) | internal IGivenData<TReturn> Needs(string needs)
FILE: src/CatLib.Core/Container/IBindData.cs
type IBindData (line 19) | public interface IBindData : IBindable<IBindData>
method Alias (line 37) | IBindData Alias(string alias);
method Tag (line 45) | IBindData Tag(string tag);
method OnResolving (line 52) | IBindData OnResolving(Action<IBindData, object> closure);
method OnAfterResolving (line 59) | IBindData OnAfterResolving(Action<IBindData, object> closure);
method OnRelease (line 66) | IBindData OnRelease(Action<IBindData, object> closure);
FILE: src/CatLib.Core/Container/IBindable.cs
type IBindable (line 19) | public interface IBindable
method Unbind (line 38) | void Unbind();
method Needs (line 50) | IGivenData<TReturn> Needs(string service);
method Needs (line 54) | IGivenData<TReturn> Needs<TService>();
type IBindable (line 42) | public interface IBindable<TReturn> : IBindable
method Unbind (line 38) | void Unbind();
method Needs (line 50) | IGivenData<TReturn> Needs(string service);
method Needs (line 54) | IGivenData<TReturn> Needs<TService>();
FILE: src/CatLib.Core/Container/IContainer.cs
type IContainer (line 22) | public interface IContainer
method GetBind (line 36) | IBindData GetBind(string service);
method HasBind (line 43) | bool HasBind(string service);
method HasInstance (line 50) | bool HasInstance(string service);
method IsResolved (line 57) | bool IsResolved(string service);
method CanMake (line 64) | bool CanMake(string service);
method IsStatic (line 71) | bool IsStatic(string service);
method IsAlias (line 78) | bool IsAlias(string name);
method Bind (line 87) | IBindData Bind(string service, Type concrete, bool isStatic);
method Bind (line 96) | IBindData Bind(string service, Func<IContainer, object[], object> conc...
method BindIf (line 106) | bool BindIf(string service, Func<IContainer, object[], object> concret...
method BindIf (line 116) | bool BindIf(string service, Type concrete, bool isStatic, out IBindDat...
method BindMethod (line 125) | IMethodBind BindMethod(string method, object target, MethodInfo called);
method UnbindMethod (line 136) | void UnbindMethod(object target);
method Unbind (line 142) | void Unbind(string service);
method Tag (line 149) | void Tag(string tag, params string[] services);
method Tagged (line 156) | object[] Tagged(string tag);
method Instance (line 164) | object Instance(string service, object instance);
method Release (line 171) | bool Release(object mixed);
method Flush (line 176) | void Flush();
method Invoke (line 184) | object Invoke(string method, params object[] userParams);
method Call (line 193) | object Call(object target, MethodInfo methodInfo, params object[] user...
method Make (line 201) | object Make(string service, params object[] userParams);
method Alias (line 209) | IContainer Alias(string alias, string service);
method Extend (line 217) | void Extend(string service, Func<object, IContainer, object> closure);
method OnResolving (line 224) | IContainer OnResolving(Action<IBindData, object> closure);
method OnAfterResolving (line 231) | IContainer OnAfterResolving(Action<IBindData, object> closure);
method OnRelease (line 238) | IContainer OnRelease(Action<IBindData, object> closure);
method OnFindType (line 246) | IContainer OnFindType(Func<string, Type> func, int priority = int.MaxV...
method OnRebound (line 254) | IContainer OnRebound(string service, Action<object> callback);
method Type2Service (line 261) | string Type2Service(Type type);
FILE: src/CatLib.Core/Container/IGivenData.cs
type IGivenData (line 20) | public interface IGivenData<TReturn>
method Given (line 28) | TReturn Given(string service);
method Given (line 31) | TReturn Given<TService>();
method Given (line 35) | TReturn Given(Func<object> closure);
FILE: src/CatLib.Core/Container/IMethodBind.cs
type IMethodBind (line 17) | public interface IMethodBind : IBindable<IMethodBind>
FILE: src/CatLib.Core/Container/IParams.cs
type IParams (line 17) | public interface IParams
method TryGetValue (line 25) | bool TryGetValue(string key, out object value);
FILE: src/CatLib.Core/Container/InjectAttribute.cs
class InjectAttribute (line 19) | [AttributeUsage(AttributeTargets.Property)]
FILE: src/CatLib.Core/Container/MethodBind.cs
class MethodBind (line 19) | internal sealed class MethodBind : Bindable<IMethodBind>, IMethodBind
method MethodBind (line 31) | public MethodBind(MethodContainer methodContainer, Container container...
method ReleaseBind (line 58) | protected override void ReleaseBind()
FILE: src/CatLib.Core/Container/MethodContainer.cs
class MethodContainer (line 23) | internal sealed class MethodContainer
method MethodContainer (line 33) | internal MethodContainer(Container container)
method Bind (line 47) | public IMethodBind Bind(string method, object target, MethodInfo metho...
method Invoke (line 85) | public object Invoke(string method, params object[] userParams)
method Unbind (line 108) | public void Unbind(object target)
method Flush (line 135) | public void Flush()
method Unbind (line 145) | internal void Unbind(MethodBind methodBind)
method MakeMethodNotFoundException (line 170) | private static LogicException MakeMethodNotFoundException(string method)
method UnbindWithObject (line 178) | private void UnbindWithObject(object target)
FILE: src/CatLib.Core/Container/ParamsCollection.cs
class ParamsCollection (line 20) | [ExcludeFromCodeCoverage]
method ParamsCollection (line 28) | public ParamsCollection()
method ParamsCollection (line 37) | public ParamsCollection(IDictionary<string, object> mapping)
method GetEnumerator (line 57) | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnume...
method GetEnumerator (line 66) | IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<str...
method Add (line 76) | public void Add(string key, object value)
method Remove (line 86) | public bool Remove(string key)
method TryGetValue (line 97) | public bool TryGetValue(string key, out object value)
FILE: src/CatLib.Core/Container/UnresolvableException.cs
class UnresolvableException (line 21) | [ExcludeFromCodeCoverage]
method UnresolvableException (line 27) | public UnresolvableException()
method UnresolvableException (line 35) | public UnresolvableException(string message)
method UnresolvableException (line 45) | public UnresolvableException(string message, SException innerException)
FILE: src/CatLib.Core/Container/VariantAttribute.cs
class VariantAttribute (line 19) | [AttributeUsage(AttributeTargets.Class)]
FILE: src/CatLib.Core/EventDispatcher/EventDispatcher.cs
class EventDispatcher (line 21) | public class EventDispatcher : IEventDispatcher
method EventDispatcher (line 28) | public EventDispatcher()
method AddListener (line 34) | public virtual bool AddListener(string eventName, EventHandler handler)
method Raise (line 55) | public virtual void Raise(string eventName, object sender, EventArgs e...
method GetListeners (line 78) | public virtual EventHandler[] GetListeners(string eventName)
method HasListener (line 89) | public virtual bool HasListener(string eventName)
method RemoveListener (line 95) | public virtual bool RemoveListener(string eventName, EventHandler hand...
FILE: src/CatLib.Core/EventDispatcher/IEventDispatcher.cs
type IEventDispatcher (line 19) | public interface IEventDispatcher
method AddListener (line 27) | bool AddListener(string eventName, EventHandler handler);
method RemoveListener (line 35) | bool RemoveListener(string eventName, EventHandler handler = null);
method GetListeners (line 43) | EventHandler[] GetListeners(string eventName);
method HasListener (line 51) | bool HasListener(string eventName);
method Raise (line 60) | void Raise(string eventName, object sender, EventArgs e = null);
FILE: src/CatLib.Core/EventDispatcher/IStoppableEvent.cs
type IStoppableEvent (line 17) | public interface IStoppableEvent
FILE: src/CatLib.Core/Exception/AssertException.cs
class AssertException (line 21) | [ExcludeFromCodeCoverage]
method AssertException (line 27) | public AssertException()
method AssertException (line 35) | public AssertException(string message)
method AssertException (line 45) | public AssertException(string message, SException innerException)
method AssertException (line 55) | protected AssertException(SerializationInfo serializationInfo, Streami...
FILE: src/CatLib.Core/Exception/LogicException.cs
class LogicException (line 22) | [ExcludeFromCodeCoverage]
method LogicException (line 28) | public LogicException()
method LogicException (line 36) | public LogicException(string message)
method LogicException (line 46) | public LogicException(string message, SException innerException)
method LogicException (line 56) | protected LogicException(SerializationInfo serializationInfo, Streamin...
FILE: src/CatLib.Core/Exception/RuntimeException.cs
class RuntimeException (line 20) | public class RuntimeException : SException
method RuntimeException (line 25) | public RuntimeException()
method RuntimeException (line 33) | public RuntimeException(string message)
method RuntimeException (line 43) | public RuntimeException(string message, SException innerException)
method RuntimeException (line 53) | protected RuntimeException(SerializationInfo serializationInfo, Stream...
FILE: src/CatLib.Core/IO/CombineStream.cs
class CombineStream (line 22) | public class CombineStream : Stream
method CombineStream (line 55) | public CombineStream(Stream left, Stream right, bool closed = false)
method CombineStream (line 65) | public CombineStream(Stream[] source, bool closed = false)
method Seek (line 140) | public override long Seek(long offset, SeekOrigin origin)
method Read (line 181) | public override int Read(byte[] buffer, int offset, int count)
method Write (line 214) | public override void Write(byte[] buffer, int offset, int count)
method SetLength (line 220) | public override void SetLength(long value)
method Flush (line 226) | public override void Flush()
method CalculatedIndex (line 237) | protected int CalculatedIndex(long globalPosition, ref long localPosit...
method Dispose (line 256) | protected override void Dispose(bool disposing)
FILE: src/CatLib.Core/IO/RingBufferStream.cs
class RingBufferStream (line 22) | public class RingBufferStream : Stream
method RingBufferStream (line 36) | public RingBufferStream(int capacity = 8192, bool exposable = true)
method GetBuffer (line 81) | public byte[] GetBuffer()
method Read (line 92) | public override int Read(byte[] buffer, int offset, int count)
method Write (line 100) | public override void Write(byte[] buffer, int offset, int count)
method Peek (line 154) | public int Peek(byte[] buffer, int offset, int count)
method Clear (line 198) | public void Clear()
method Flush (line 206) | public override void Flush()
method Seek (line 212) | public override long Seek(long offset, SeekOrigin origin)
method SetLength (line 218) | public override void SetLength(long value)
method Dispose (line 224) | protected override void Dispose(bool disposing)
method GetCanReadSize (line 238) | private long GetCanReadSize()
method GetCanWriteSize (line 246) | private long GetCanWriteSize()
method ToPrime (line 256) | private int ToPrime(int min)
FILE: src/CatLib.Core/IO/SegmentStream.cs
class SegmentStream (line 22) | public class SegmentStream : WrapperStream
method SegmentStream (line 39) | public SegmentStream(Stream stream, long partSize = 0)
method Seek (line 88) | public override long Seek(long offset, SeekOrigin origin)
method Read (line 120) | public override int Read(byte[] buffer, int offset, int count)
method SetLength (line 127) | public override void SetLength(long value)
method Write (line 133) | public override void Write(byte[] buffer, int offset, int count)
FILE: src/CatLib.Core/IO/StreamExtension.cs
class StreamExtension (line 23) | public static class StreamExtension
method AppendTo (line 47) | public static long AppendTo(this Stream source, Stream destination)
method AppendTo (line 59) | public static long AppendTo(this Stream source, Stream destination, by...
method ToText (line 82) | public static string ToText(this Stream source, Encoding encoding = nu...
method ToStream (line 149) | public static Stream ToStream(this string str, Encoding encoding = null)
FILE: src/CatLib.Core/IO/WrapperStream.cs
class WrapperStream (line 22) | [ExcludeFromCodeCoverage]
method WrapperStream (line 28) | public WrapperStream()
method WrapperStream (line 37) | public WrapperStream(Stream stream)
method Seek (line 68) | public override long Seek(long offset, SeekOrigin origin)
method Flush (line 74) | public override void Flush()
method Write (line 80) | public override void Write(byte[] buffer, int offset, int count)
method SetLength (line 86) | public override void SetLength(long value)
method Read (line 92) | public override int Read(byte[] buffer, int offset, int count)
FILE: src/CatLib.Core/Util/Arr.cs
class Arr (line 22) | public static class Arr
method Merge (line 31) | public static T[] Merge<T>(params T[][] sources)
method Rand (line 78) | public static T[] Rand<T>(T[] sources, int number = 1)
method Shuffle (line 95) | public static T[] Shuffle<T>(T[] sources, int? seed = null)
method Splice (line 142) | public static T[] Splice<T>(ref T[] sources, int start, int? length = ...
method Cut (line 195) | public static void Cut<T>(ref T[] source, int position)
method Chunk (line 233) | public static T[][] Chunk<T>(T[] sources, int size)
method Fill (line 278) | public static T[] Fill<T>(int start, int length, T value, T[] sources ...
method Remove (line 314) | public static T[] Remove<T>(ref T[] sources, Predicate<T> predicate, b...
method Filter (line 351) | public static T[] Filter<T>(IEnumerable<T> sources, Predicate<T> predi...
method Map (line 381) | public static TReturn[] Map<T, TReturn>(IEnumerable<T> source, Func<T,...
method Pop (line 406) | public static T Pop<T>(ref T[] sources)
method Push (line 423) | public static int Push<T>(ref T[] sources, params T[] elements)
method Reduce (line 447) | public static string Reduce<T>(IEnumerable<T> sources, Func<object, T,...
method Slice (line 482) | public static T[] Slice<T>(T[] sources, int start, int? length = null)
method Shift (line 502) | public static T Shift<T>(ref T[] sources)
method Unshift (line 522) | public static int Unshift<T>(ref T[] sources, params T[] elements)
method Reverse (line 556) | public static T[] Reverse<T>(T[] sources, int start = 0, int? length =...
method IndexOf (line 586) | public static int IndexOf<T>(T[] source, params T[] match)
method IndexOfAny (line 632) | public static int IndexOfAny<T>(T[] source, params T[] match)
method Difference (line 661) | public static T[] Difference<T>(T[] sources, params T[] matches)
method RemoveAt (line 691) | public static T RemoveAt<T>(ref T[] sources, int index, T defaultValue...
method Test (line 710) | public static bool Test<T>(IEnumerable<T> sources, Predicate<T> predic...
method Test (line 724) | public static bool Test<T>(IEnumerable<T> sources, Predicate<T> predic...
method Set (line 754) | public static void Set<T>(ref T[] sources, Predicate<T> predicate, T v...
FILE: src/CatLib.Core/Util/Guard.cs
class Guard (line 22) | public sealed class Guard
method Requires (line 61) | [System.Diagnostics.DebuggerNonUserCode]
method Requires (line 76) | [System.Diagnostics.DebuggerNonUserCode]
method ParameterNotNull (line 94) | [System.Diagnostics.DebuggerNonUserCode]
method Extend (line 118) | [System.Diagnostics.DebuggerNonUserCode]
method Extend (line 129) | [System.Diagnostics.DebuggerNonUserCode]
method CreateExceptionInstance (line 136) | private static SException CreateExceptionInstance(Type exceptionType, ...
method VerfiyExceptionFactory (line 170) | private static void VerfiyExceptionFactory()
method SetField (line 178) | private static void SetField(object obj, string field, object value)
FILE: src/CatLib.Core/Util/InternalHelper.cs
class InternalHelper (line 19) | internal static class InternalHelper
method MakeRandom (line 21) | internal static Random MakeRandom(int? seed = null)
method MakeSeed (line 26) | internal static int MakeSeed()
method NormalizationPosition (line 31) | internal static void NormalizationPosition(int sourceLength, ref int s...
FILE: src/CatLib.Core/Util/SortSet.cs
class SortSet (line 28) | [DebuggerDisplay("Count = {" + nameof(Count) + "}")]
method SortSet (line 48) | public SortSet(double probable = 0.25, int maxLevel = 32)
method SortSet (line 70) | public SortSet(IComparer<TScore> comparer, double probable = 0.25, int...
method Clear (line 92) | public void Clear()
method GetIterator (line 111) | public IEnumerable<TElement> GetIterator(bool forward = true)
method GetEnumerator (line 117) | IEnumerator<TElement> IEnumerable<TElement>.GetEnumerator()
method GetEnumerator (line 123) | IEnumerator IEnumerable.GetEnumerator()
method ToArray (line 132) | public TElement[] ToArray()
method First (line 150) | public TElement First()
method Last (line 164) | public TElement Last()
method Shift (line 178) | public TElement Shift()
method Pop (line 192) | public TElement Pop()
method Add (line 207) | public void Add(TElement element, TScore score)
method Contains (line 229) | public bool Contains(TElement element)
method GetScore (line 242) | public TScore GetScore(TElement element)
method GetRangeCount (line 262) | public int GetRangeCount(TScore start, TScore end)
method Remove (line 326) | public bool Remove(TElement element)
method RemoveRangeByRank (line 341) | public int RemoveRangeByRank(int startRank, int stopRank)
method RemoveRangeByScore (line 385) | public int RemoveRangeByScore(TScore startScore, TScore stopScore)
method GetRank (line 431) | public int GetRank(TElement element)
method GetRevRank (line 444) | public int GetRevRank(TElement element)
method GetElementRangeByRank (line 459) | public TElement[] GetElementRangeByRank(int startRank, int stopRank)
method GetElementRangeByScore (line 498) | public TElement[] GetElementRangeByScore(TScore startScore, TScore sto...
method GetElementByRank (line 538) | public TElement GetElementByRank(int rank)
method GetElementByRevRank (line 572) | public TElement GetElementByRevRank(int rank)
method AddElement (line 582) | private void AddElement(TElement element, TScore score)
method Remove (line 662) | private bool Remove(SkipNode node, out TElement element)
method Remove (line 687) | private bool Remove(TElement element, TScore score)
method GetRank (line 729) | private int GetRank(TElement element, TScore score)
method IsFindNext (line 762) | private bool IsFindNext(SkipNode node, TElement element, TScore score,...
method DeleteNode (line 796) | private void DeleteNode(SkipNode cursor, SkipNode[] update)
method GetRandomLevel (line 833) | private int GetRandomLevel()
method Compare (line 850) | private int Compare(TScore left, TScore right)
type Iterator (line 859) | public struct Iterator : IEnumerator<TElement>, IEnumerable<TElement>
method Iterator (line 882) | internal Iterator(SortSet<TElement, TScore> collection, bool forward)
method Dispose (line 908) | public void Dispose()
method GetEnumerator (line 914) | public IEnumerator<TElement> GetEnumerator()
method GetEnumerator (line 920) | IEnumerator IEnumerable.GetEnumerator()
method MoveNext (line 926) | public bool MoveNext()
method Reset (line 957) | void IEnumerator.Reset()
class SkipNode (line 966) | private class SkipNode
type SkipNodeLevel (line 993) | internal struct SkipNodeLevel
FILE: src/CatLib.Core/Util/Str.cs
class Str (line 21) | public static class Str
type PadType (line 31) | public enum PadType
method Method (line 54) | public static string Method(string pattern)
method Is (line 103) | public static bool Is(string pattern, string value)
method Is (line 116) | public static bool Is<T>(string[] patterns, T value)
method AsteriskWildcard (line 139) | public static string AsteriskWildcard(string pattern)
method Split (line 152) | public static string[] Split(string str, int length = 1)
method Repeat (line 175) | public static string Repeat(string str, int num)
method Shuffle (line 199) | public static string Shuffle(string str, int? seed = null)
method SubstringCount (line 240) | public static int SubstringCount(string str, string substr, int start ...
method Reverse (line 271) | public static string Reverse(string str)
method Pad (line 291) | public static string Pad(int length, string str = null, string padStr ...
method After (line 335) | public static string After(string str, string search)
method Contains (line 359) | public static bool Contains(string str, params string[] needles)
method Replace (line 381) | public static string Replace(string[] matches, string replace, string ...
method ReplaceFirst (line 412) | public static string ReplaceFirst(string match, string replace, string...
method ReplaceLast (line 432) | public static string ReplaceLast(string match, string replace, string ...
method Random (line 450) | public static string Random(int length = 16, int? seed = null)
method Truncate (line 479) | public static string Truncate(string str, int length, object separator...
method Levenshtein (line 536) | public static int Levenshtein(string a, string b)
method JoinList (line 607) | public static string[] JoinList(string[] sources, string separator = n...
method JoinList (line 628) | public static string[] JoinList(string[] source, char separator)
Condensed preview — 114 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (588K chars).
[
{
"path": ".dist/CHANGELOG.md",
"chars": 3152,
"preview": "# Release Notes\n\n## [v2.0.0-alpha.1 (2019-12-04)](https://github.com/CatLib/Core/releases/tag/v2.0.0) \n\n#### Added\n\n- `I"
},
{
"path": ".dist/LICENSE",
"chars": 1063,
"preview": "MIT License\n\nCopyright (c) 2017 CatLib\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof "
},
{
"path": ".dist/README.md",
"chars": 2282,
"preview": "<p align=\"center\"><img width=\"173\" height=\"57\" src=\"https://catlib.io/imgs/logo-txt.png\"></p>\n\n<p align=\"center\">\n<a hr"
},
{
"path": ".dist/bucket.json",
"chars": 461,
"preview": "{\n\t\"name\": \"catlib/core\",\n\t\"version\": \"2.0.0\",\n\t\"description\": \"catlib framework is the lightweight dependency injection"
},
{
"path": ".dist/netstandard2.0/CatLib.Core.deps.json",
"chars": 9807,
"preview": "{\n \"runtimeTarget\": {\n \"name\": \".NETStandard,Version=v2.0/\",\n \"signature\": \"\"\n },\n \"compilationOptions\": {},\n "
},
{
"path": ".gitattributes",
"chars": 344,
"preview": "src/ export-ignore\n*.sln export-ignore\n.gitignore export-ignore\n.gitattributes export"
},
{
"path": ".github/ISSUE_TEMPLATE/---bug-report.md",
"chars": 651,
"preview": "---\nname: \"\\U0001F41B Bug Report\"\nabout: Report a general framework issue. Please ensure your CatLib version is still\n "
},
{
"path": ".github/ISSUE_TEMPLATE/---documentation-issue.md",
"chars": 425,
"preview": "---\nname: \"\\U0001F4DA Documentation Issue\"\nabout: For documentation issues, open a pull request at https://github.com/ca"
},
{
"path": ".github/ISSUE_TEMPLATE/---feature-request.md",
"chars": 284,
"preview": "---\nname: \"\\U0001F4A1 Feature Request\"\nabout: Suggest an idea for this project\ntitle: \"[Feature] Suggested as the issues"
},
{
"path": ".github/ISSUE_TEMPLATE/---support-question.md",
"chars": 519,
"preview": "---\nname: \"\\U0001F680 Support Question\"\nabout: This repository is only for for questions about using CatLib and its comp"
},
{
"path": ".gitignore",
"chars": 117,
"preview": ".vs/\nsrc/*/bin/\nsrc/*/obj/\nTestResults/\ncoverage.json\ncoverage.opencover.xml\n.DS_Store\n.idea/\n*.sln.DotSettings.user\n"
},
{
"path": ".travis.yml",
"chars": 552,
"preview": "language: csharp\nmono: none\ndotnet: 3.0.100\n\nstages:\n - compile\n - test\n\njobs:\n include:\n - stage: compile\n s"
},
{
"path": "CHANGELOG.md",
"chars": 3152,
"preview": "# Release Notes\n\n## [v2.0.0-alpha.1 (2019-12-04)](https://github.com/CatLib/Core/releases/tag/v2.0.0) \n\n#### Added\n\n- `I"
},
{
"path": "CatLib.Core.sln",
"chars": 1619,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.2880"
},
{
"path": "LICENSE",
"chars": 1063,
"preview": "MIT License\n\nCopyright (c) 2017 CatLib\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof "
},
{
"path": "README.md",
"chars": 2282,
"preview": "<p align=\"center\"><img width=\"173\" height=\"57\" src=\"https://catlib.io/imgs/logo-txt.png\"></p>\n\n<p align=\"center\">\n<a hr"
},
{
"path": "bucket.json",
"chars": 461,
"preview": "{\n\t\"name\": \"catlib/core\",\n\t\"version\": \"2.0.0\",\n\t\"description\": \"catlib framework is the lightweight dependency injection"
},
{
"path": "build.ps1",
"chars": 2856,
"preview": "param(\n[string]$version=\"master-dev\"\n)\n\n$dist = \".dist\"\n$root = (Get-Item -Path \".\\\").FullName\n$publishDir = $root + \"\\s"
},
{
"path": "src/CatLib.Core/CatLib/App.cs",
"chars": 27681,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Application.cs",
"chars": 10890,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/DebugLevel.cs",
"chars": 740,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/AfterBootEventArgs.cs",
"chars": 753,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/AfterInitEventArgs.cs",
"chars": 783,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/AfterTerminateEventArgs.cs",
"chars": 777,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/ApplicationEventArgs.cs",
"chars": 908,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/ApplicationEvents.cs",
"chars": 2541,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/BeforeBootEventArgs.cs",
"chars": 1510,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/BeforeInitEventArgs.cs",
"chars": 868,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/BeforeTerminateEventArgs.cs",
"chars": 780,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/BootingEventArgs.cs",
"chars": 1652,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/InitProviderEventArgs.cs",
"chars": 1247,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/RegisterProviderEventArgs.cs",
"chars": 1767,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Events/StartCompletedEventArgs.cs",
"chars": 758,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/Facade.cs",
"chars": 4901,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/IApplication.cs",
"chars": 1952,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/IBootstrap.cs",
"chars": 553,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/IServiceProvider.cs",
"chars": 708,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/ServiceProvider.cs",
"chars": 1004,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib/StartProcess.cs",
"chars": 2121,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/CatLib.Core.csproj",
"chars": 674,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>netstandard2.0</TargetFramework>\n <Version"
},
{
"path": "src/CatLib.Core/Container/BindData.cs",
"chars": 4112,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/BindDataExtension.cs",
"chars": 5847,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/Bindable.cs",
"chars": 5595,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/Container.cs",
"chars": 67395,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/ContainerExtension.cs",
"chars": 50597,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/GivenData.cs",
"chars": 1892,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and lic"
},
{
"path": "src/CatLib.Core/Container/IBindData.cs",
"chars": 2184,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/IBindable.cs",
"chars": 1649,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/IContainer.cs",
"chars": 11163,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/IGivenData.cs",
"chars": 1096,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/IMethodBind.cs",
"chars": 426,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/IParams.cs",
"chars": 740,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/InjectAttribute.cs",
"chars": 650,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/MethodBind.cs",
"chars": 2028,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/MethodContainer.cs",
"chars": 6146,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/ParamsCollection.cs",
"chars": 3127,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/UnresolvableException.cs",
"chars": 1481,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Container/VariantAttribute.cs",
"chars": 583,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/EventDispatcher/EventDispatcher.cs",
"chars": 3254,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/EventDispatcher/IEventDispatcher.cs",
"chars": 2570,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/EventDispatcher/IStoppableEvent.cs",
"chars": 681,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Exception/AssertException.cs",
"chars": 2072,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Exception/LogicException.cs",
"chars": 2180,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Exception/RuntimeException.cs",
"chars": 2011,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/IO/CombineStream.cs",
"chars": 8160,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/IO/RingBufferStream.cs",
"chars": 8159,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/IO/SegmentStream.cs",
"chars": 4020,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/IO/StreamExtension.cs",
"chars": 4923,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/IO/WrapperStream.cs",
"chars": 2498,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Properties/AssemblyInfo.cs",
"chars": 347,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Util/Arr.cs",
"chars": 30438,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Util/Guard.cs",
"chars": 7265,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Util/InternalHelper.cs",
"chars": 1263,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Util/SortSet.cs",
"chars": 33116,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core/Util/Str.cs",
"chars": 21930,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/CatLib/TestsApplication.cs",
"chars": 7722,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/CatLib/TestsFacade.cs",
"chars": 3522,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/CatLib.Core.Tests.csproj",
"chars": 301,
"preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n <PropertyGroup>\n <TargetFramework>netcoreapp3.0</TargetFramework>\n <IsPackab"
},
{
"path": "src/CatLib.Core.Tests/Container/TestsBindData.cs",
"chars": 3792,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Container/TestsContainer.cs",
"chars": 33385,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Container/TestsExtensionContainer.cs",
"chars": 14676,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/EventDispatcher/TestsEventDispatcher.cs",
"chars": 5022,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/AbstractClass.cs",
"chars": 342,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/Bar.cs",
"chars": 819,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/Baz.cs",
"chars": 821,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/CircularDependency.cs",
"chars": 737,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/Foo.cs",
"chars": 721,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/FooBar.cs",
"chars": 1041,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/Fubar.cs",
"chars": 819,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/FubarChild.cs",
"chars": 591,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/IFoo.cs",
"chars": 418,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/Position.cs",
"chars": 432,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/Quux.cs",
"chars": 436,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/QuuxFoo.cs",
"chars": 433,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/TestEventArgs.cs",
"chars": 570,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/Variant.cs",
"chars": 474,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Fixture/VariantModel.cs",
"chars": 842,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Framework/ExpectedExceptionAndMessageAttribute.cs",
"chars": 2583,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Framework/TestException.cs",
"chars": 875,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Framework/TestMethodIterativeAttribute.cs",
"chars": 1136,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/IO/TestsCombineStream.cs",
"chars": 5119,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/IO/TestsRingBuffer.cs",
"chars": 7314,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/IO/TestsSegmentStream.cs",
"chars": 5017,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/IO/TestsStreamExtension.cs",
"chars": 2614,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Util/TestsArr.cs",
"chars": 17338,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Util/TestsGuard.cs",
"chars": 2165,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Util/TestsSortSet.cs",
"chars": 17262,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/CatLib.Core.Tests/Util/TestsStr.cs",
"chars": 12065,
"preview": "/*\n * This file is part of the CatLib package.\n *\n * (c) CatLib <support@catlib.io>\n *\n * For the full copyright and li"
},
{
"path": "src/Directory.Build.props",
"chars": 1930,
"preview": "<Project>\n <PropertyGroup>\n\t<IsTestProject>$(MSBuildProjectName.Contains('Tests'))</IsTestProject>\n\t<TreatWarningsAsErr"
},
{
"path": "src/analysis.ruleset",
"chars": 2880,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RuleSet Name=\"CatLib Code Analysis Ruleset\" Description=\"The catlib code analys"
},
{
"path": "src/analysis.test.ruleset",
"chars": 905,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RuleSet Name=\"CatLib Code Analysis Ruleset\" Description=\"The catlib code analys"
},
{
"path": "src/settings.runsettings",
"chars": 1274,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?> \n<RunSettings>\n\t<RunConfiguration> \n\t\t<ResultsDirectory>%temp%\\TestResults</R"
},
{
"path": "src/stylecop.json",
"chars": 410,
"preview": "{\n \"settings\":{\n \"orderingRules\":{\n \"usingDirectivesPlacement\" : \"outsideNamespace\"\n },\n\t\"documentationRul"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the CatLib/Core GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 114 files (544.0 KB), approximately 121.4k tokens, and a symbol index with 1037 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.