SkywardApps / popcorn

Popcorn is a .Net Middleware for your RESTful API that allows your consumers to request exactly as much or as little as they need, with no effort from you.
https://skywardapps.github.io/popcorn/
MIT License
59 stars 19 forks source link

Missing Factories tutorial #17

Closed alexbarbato closed 7 years ago

alexbarbato commented 7 years ago

Detailed Description

In PopcornConfiguration.cs we define the ability to assign a factory, both with and without a context provided. We want to document how to use these functions so as to make them accessible to users.

Possible Implementation

chrsi commented 7 years ago

Hey, I'd like to grab this one and started to work though the example project. As far as i understood this Factory functionality, it provides a way to specify default values for mapped entities. Are there any other interesting use cases?

alexbarbato commented 7 years ago

Hey thanks for offering to help! I'm going to mark this as claimed and it's all yours.

I think you're pretty right that one way you can use the AssignFactory function is to apply default values to generated objects from the Factory. I think the potentially cooler use case, we don't have a text example of yet, is when you apply a context to the factory because you can be a bit more dynamic with the resulting object as the context doesn't necessarily have to be hard coded to a single value.

@undiwahn, please let me know if this sounds completely out in left field too please!

Let me know if that helps/doesn't and I can get you a more concrete example should the need be. Thanks again :)

chrsi commented 7 years ago

I tried to find a fitting example in my last commit fdcbd35. Could someone please have a look if thats a good example? Its about employment types that, if not explicitly requested, responds with a generic "Employed" information. If it's included in the request, you'll get the detailed Information (eg. FullTime/PartTime)

alexbarbato commented 7 years ago

Saw your PR, thanks a ton! Let's give it a couple of days for everyone to have a chance to review (myself included), but it looks like an awesome go from the little I've looked at so far

chrsi commented 7 years ago

Thanks for the Feedback, I'm glad that i could help :)

undiwahn commented 7 years ago

Pull request accepted and merged!