Jacko
Explore posts from serversQuestion about Dependency Injection:
I’m currently using autofac for dependency injection in a project because I’m attempting to do a plugin architecture and it has some features for loading interfaces from dlls. I came across the Microsoft dependency injection library and learned that it can load from autofac containers with the extension. What’s the benefit of this over using autofac alone ?
66 replies
✅ Can custom attributes use interfaces somehow ?
I have an interface named IConfiguration and I'm wondering is it possible to write a custom attribute so I can do [StaticConfiguration("Key"]var settings: Settings so that the StaticConfiguration attribute will get the config for that key from IConfiguration and parse it into the type Settings?
13 replies
How to configure services in my cli application:
So I have code like above where I'm creating a container using autofac and then registering some services with methods like
The issue is I want the logger to get its configuration details from the IConfiguraton supplied by WithSystemConfiguration() and I'm not sure whether to use a build callback like
or create a wrapper class like MyCustomLogger that uses ILogger and IConfiguration in it's constructor
15 replies
Get information about DI container:
So I’ve read that it’s a bad idea to pass a DI container into a class and use .get() because it’s a service locator pattern which isn’t recommended. I’m trying to make a cli with a plugin system and as part of that I want to have a debug command that returns all the registered plugins from the di container. Is there a best practice way to do this using Autofac ? I want to have a class like ContainerService which has some methods to get registered services, find their file locations etc.
5 replies
Restrict loaded assemblies:
I’m writing a console app with a plugin system, for security I want to try restrict it to assemblies that don’t use certain namespaces like system IO with the intention being they have to request stuff like input and config values through interfaces. Is this possible and how do I check what namespaces an assembly uses ?
11 replies
Properties vs constructor:
I’m currently creating a new project and have a class called Repository that gathers info about the system the code is running on and makes some api requests. If the class has several internal values like system status which is fetched from an api, should I run the code to fetch the status in the constructor or can I have a property getter so I can write repo.system_status to get the latest value without needing to call a function ?
8 replies
Is there a recommended way to start a nuxt project ?
So I just finished learning the basics of Vue and want to start a new website using nuxt. I’m confused though that when I use vue create it seems very opinionated and does a lot of the hard work like prettier and eslint configuration and creating a full directory structure for a demonstration. Is there a similar way to start nuxt, as the default method seems very barebones ?
2 replies