-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependency injection in serializer #627
Comments
Hi, you could add a third argument ( I didn't test it, but I'm confident this will work. |
Ah ok I see. I'll try it this evening and if it works I post the solution.
Thank you very much !
Le 20 juin 2017 10:24, "Théo DELRIEU" <notifications@github.com> a écrit :
… Hi, you could add a third argument (DataService&) to your method, which
would be defaulted to the object you want to use.
I didn't test it, but I'm confident this will work.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#627 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AJyIsMKajPZKbDLGfWPlJGnqZ43Fg0_hks5sF4GhgaJpZM4N_KDX>
.
|
Your solution did'nt solve my problem since Ok after some digging, I found a solution. My solution consist in injecting my DataService after the parse. Example : CommonDataStore dataStore("a/file"); // Create the dependency
TaskBuilder taskBuilder = raw_json_data; // Parse the json in a builder (adl_serializer is called with TaskBuilder)
taskBuilder.injectDataStore(dataStore); // Inject the dependency to the builder
Task task = taskBuilder.build(); // The builder use the data from data store to build the Task object |
I close it because it works well for me. Thank you again. |
Hello,
I'm currently using your library with great pleasure but I was wondering if I could inject a service as a dependency to the adl_serializer and how to do that.
I saw that a lot of things are done at compile time so maybe that I'll have to use it as a static service ?
This option would work but if you have a better one, I'm listening :)
To illustrate, here is an example with both solutions.
Thank you :)
Célian Garcia
Edit : NB : I'll use "at" instead of "[]" as mentionned in your doc ;)
The text was updated successfully, but these errors were encountered: