Comments (7)
That's interesting. Am I right the proposal implies:
- Adding ~
IMethodBasedFactory
- an interface you can extend - Adding ~
IServiceCollection.AddMethodBasedFactory<TFactory>() where TFactory: IMethodBasedFactory
, which resolves to a proxy acting as you've described. I.e. it automatically wires up any method call on it to an implementation, which create the actual object relying onActivatorUtilities.CreateFactory
& method call arguments.
And ultimately, it allows to replace untyped ~ services.Activate(...)
calls with typed ~ myFactory.CreateSomething(...)
, + also boost the performance of such calls due to activator/factory caching?
from stl.fusion.
I'd also add proxy support for that, btw - i.e. auto-replacement of a type with Stl.Interception
proxy, if it's available for that type (coz most likely that's the expected outcome in such cases).
from stl.fusion.
@AliveDevil I like the idea - it feels handy, + moreover, if the "default" construction helper won't fit some specific case, you can always add extension methods to the interface for custom construction.
from stl.fusion.
If you have some time, please send this PR - I'll definitely accept it, though might make some changes afterwards :)
And I'll be happy to do this anyway at some point (not sure when yet) - I like the proposal.
P.S. Great you dug pretty far into that - this part is almost undocumented.
from stl.fusion.
I like IMethodBasedFactory
- sounds good.
Adding MethodBasedActivatorUtilitiesInterceptor
for this as the interception proxy (using the ActivatorUtilities factory).
Does Stl have any support of dynamic proxies (not generated through Stl.Generation
)? Otherwise making IMethodBasedFactoryDefaultProxy
could be a challenge (or I'm missing something here).
P.S. Great you dug pretty far into that
If there's no documentation, I'm really stubborn and dig into everything until I have a solution.
Not the best habit in terms of time-efficiency, but for some personal project it works out fine.
from stl.fusion.
[…] boost the performance of such calls due to activator/factory caching?
I'd not want to vouch for that, though it makes it way more type-safe and improves discoverability - the factory caching does make it faster, as there is just the initial discovery phase of the constructor, then the factory delegate performs a regular constructor call.
The ObjectFactory itself is using params object[]
internally, so whether that makes any difference I'm not sure about - as all value types are boxed again.
I mean, there is the option of porting back ActivatorUtilities1 to not rely on object[] args
, but that may overshoot the goal by miles.
Footnotes
from stl.fusion.
You are free to edit the PR, it’s „allow edit for maintainers“ enabled.
from stl.fusion.
Related Issues (20)
- Replace LogLevel / XxxLogLevel with IsLoggingEnabled everywhere
- Possible renames HOT 2
- Add System.Text.Json serializer support HOT 1
- Add MessagePack serializer support HOT 4
- Sign the assemblies that could be signed
- async alternate HOT 3
- [StateHasChangedAsync] System.NullReferenceException: 'Object reference not set to an instance of an object.' HOT 8
- infinite query loop HOT 7
- blazor wasm only (no server side blazor) can't get auth schemes HOT 3
- Exception when using together with Moq 4.18.1 HOT 9
- Don't mask HTTP errors in replica services HOT 1
- Improve test coverage
- A DateTime value was incorrectly passed to the server in Korean. HOT 2
- Commands are executed twice? HOT 3
- Could not load type 'Stl.Fusion.Bridge.IChannelProvider' from assembly 'Stl.Fusion
- Live sample at https://fusion-samples.servicetitan.com/ is broken in wasm mode HOT 2
- Assistance Needed: List Method Not Retrieving Values and Not Subscribing to Updates HOT 5
- Stl.Interception gets trimmed away HOT 10
- Add Stl.Async-way of awaiting WaitHandle HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stl.fusion.