Comments (3)
Please forgive me. Dependency injection has come around since I've had any major dotnet projects, so I'm not very familiar with the concept. May ask why this isn't acceptable?
public class CustomerRepository
{
// public MutationContext<Customer> customerMutationContext { get; set; } // line 3
// public CustomerRepository(MutationContext<Customer> customerMutationContext) // line 5
// {
// this.customerMutationContext = customerMutationContext;
// }
public void SaveCustomer(Customer cust)
{
(new MutationContext(cust)).Mutate();
}
}
Since line 3 and 5 explicitly define a MutationContext of Customer, why not have the constructor implicitly form that context from the parameter?
from dado.componentmodel.mutations.
Because "new is glue" and it should be the job of the IoC container to new up the dependencies of a class. Since MutationContext takes an instance of the customer, its not possible for the IoC container to provide it.
In my example, I could mock MutationContext and provide one that did anything I wanted in order to test my project. In your example new MutationContext
is forever baked into the code even though its an outside dependency.
Ideally id inject IMutationContext
and not MutationContext
.
from dado.componentmodel.mutations.
Okay. I see what you're going after. You're welcome to submit a pull request.
from dado.componentmodel.mutations.
Related Issues (16)
- ToDefaultValueAttribute does not accept null
- Add EnforceMaxLength attribute for strings and collections HOT 1
- Add EnforceRange attribute for numeric range values
- Change namespace to disassociate with Microsoft packages
- Refactor code according to source commits
- Remove unnecessary GetTypeInfo() calls according to source commits
- Improved readability according to source commits HOT 1
- Refactor and update to .Net Standard 2.0 HOT 1
- Remove unnecessary GetTypeInfo() calls
- Compare Min/MaxLength Annotation Attribute changes with Min/MaxLength Mutation Attributes
- Add support for fluent api
- Add CustomMutationAttribute HOT 1
- What calls mutate? HOT 1
- Add ToSentenceCaseAttribute HOT 2
- Add ToTitleCaseAttribute
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 dado.componentmodel.mutations.