Further refine entity samples, add .http files and launch task#218
Further refine entity samples, add .http files and launch task#218jviau merged 5 commits intomicrosoft:feature/entitiesfrom
Conversation
| /// Optional property to override. When 'true', this will allow dispatching of operations to the <see cref="State"> | ||
| /// object if there is no matching method on the entity. Default is 'false'. | ||
| /// Stated differently: if this is <c>true</c> and there is no matching method for a given operation on the entity | ||
| /// type, then the operation will attempt to find a matching method on <typeparamref name="TState"/> instead. |
There was a problem hiding this comment.
I'm surprised to see this as a feature since I don't recall it ever being discussed. What are the use-cases? I'm also interested to understand the lifetime implications, etc.
There was a problem hiding this comment.
This was to help migration so customers don't have to derive from ITaskEntity if they do not want to.
What lifetime implications are you concerned about?
There was a problem hiding this comment.
I'm wondering what happens if the state object is null, etc. I don't recall any such feature existing for the in-proc model. But maybe I'm misunderstanding what is being referred to by TState? Is that not the entity state?
There was a problem hiding this comment.
In proc model does not have a concept of ITaskEntity base class. This is here to align closer with how inproc behaves: you can dispatch entity operations to some POCO. We have designed it so that POCO dispatching is done through the TState here.
If state is null we will use Activator.CreateInstance.
There was a problem hiding this comment.
Trying to summarize the discussions and design a bit:
For in-proc we had two models:
- class-based. Entity state must be defined by a class, and operations are dispatched to methods.
- function-based. Very low level but totally customizable, with entity state being an arbitrary type.
For isolated we have three (but only the first two are expected to be widely used):
- class-based. Pretty much the same as for in-proc.
- TaskEntity<TState>. Similar to class-based but with one layer of indirection, which allows advanced scenarios (arbitrary TState types, dependency injection, customizable code for constructing the state) without having to give up the convenience of the class-based approach.
- ITaskEntity. Very similar to function-based. Very general but verbose. Not recommended unless you are building some kind of framework on top of entities.
counterandlifetimeexamples.httpfiles to show quick ways to call these examples.launch.jsonandtasks.jsonfor running this sample in vscode