-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Register DisplayDrivers with ContentOptions #4361
Conversation
...hardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement.Abstractions/ContentOptions.cs
Outdated
Show resolved
Hide resolved
...Core/OrchardCore.ContentManagement.Display/ContentDisplay/ContentPartDisplayDriverFactory.cs
Outdated
Show resolved
Hide resolved
...hardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
...hardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
… against the same ContentPart
…y and another sins
@jtkech Thanks for taking a look last night. I had some time this morning so I refactored, based on your suggestions, and some other things that I wanted to try.
I guess this PR is all about performance, so if @sebastienros feels like benchmarking it, that would be the only way to see if what I've done is even remotely useful? |
if nothing else its much more intuitive :) |
@sebastienros Any feedback on this idea? |
@jtkech I went through this again to add some logging, and am happy with how it looks, if you had any thoughts they'd be appreciated |
src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentDisplayOptions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentDisplayOptions.cs
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement/Handlers/ContentPartHandlerCoordinator.cs
Outdated
Show resolved
Hide resolved
...rdCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentItemDisplayCoordinator.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement.Abstractions/ContentOptions.cs
Outdated
Show resolved
Hide resolved
@deanmarcussen okay no problem, i will look at it asap, but so many things ;) |
# Conflicts: # src/OrchardCore.Modules/OrchardCore.Liquid/Startup.cs # src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentItemDisplayCoordinator.cs # src/OrchardCore/OrchardCore.ContentManagement/Handlers/ContentPartHandlerCoordinator.cs
{ | ||
InvokeExtensions.HandleException(ex, Logger, displayDriver.GetType().Name, "BuildDisplayAsync"); | ||
try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastienros on your recent pr #4887 you've reduced the allocation pattern for using the invoke extensions.
Just noting that the current BuildDisplayAsync
method doesn't use the
await partDisplayDrivers.InvokeAsync(async (driver, part, typePartDefinition, context) =>
technique at all, it is only the BuildEditorAsync
that used it previously.
So if there is an opportunity to reduce allocations on BuildDisplayAsync
(regardless of whether this PR goes through), perhaps we should use them?
# Conflicts: # src/OrchardCore/OrchardCore.ContentManagement.Display/ServiceCollectionExtensions.cs
ok @sebastienros I reimplemented this with explicit registrations for display modes and editors. By default registration is Other options include registering as
I have left them as mutable Note parts only have custom editors , not display modes. Edited |
# Conflicts: # src/OrchardCore.Modules/OrchardCore.ContentLocalization/Startup.cs
# Conflicts: # src/OrchardCore.Modules/OrchardCore.Liquid/Startup.cs
Updated this after our conversation Seb Here are some examples of how registration could be done for fields
Handlers I moved to
So let me know if you agree with the design and like the naming conventions (easy to change) |
# Conflicts: # src/OrchardCore.Modules/OrchardCore.Lists/Startup.cs
# Conflicts: # src/OrchardCore.Modules/OrchardCore.Lists/Startup.cs
Far too late to be wanting to get this in now, but further to our conversation @sebastienros here's some ideas for registering DisplayDriver Types in the new ContentOptions, with a factory to resolve them from DI as required, rather than resolving all of them at once and iterating.
Just ideas for the future, but if you like the concept, then this would work for Handlers, as well.
Did think about using a dictionary of Func<> but the factory seemed better
Also will probably need to be changed to a Lookup to support multiple driver registrations against the same part, eg CommonPart Drivers