Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Alternative implementation of the ditto chain context #207

Merged
merged 2 commits into from
May 30, 2017

Conversation

mattbrailsford
Copy link
Collaborator

Alternative fix for issue #201

Chain contexts are used to persist the processor context cache across a chain of processors. The curent implementation tries to be clever by maintaining a cache behind the scenes, but this seems to be causing problems. This implementation makes passing of the chain context through the chain more explicit. All processors now have a property of ChainContext and if .As is called inside a processor and you want it to take part in the chain context then you now have to pass the current chain context in

content.As<Type>(chainContext:ChainContext);

This seems to fix the issues the other implementation had, but forces the passing of the context to be explicit and thus possible for someone to forget. That said, it's sounding like this may be the most logical solution.

Discuss!

…e chain context being passed down on any inner .As calls
@jamiepollock
Copy link

@mattbrailsford glad it fixes the issue. I'm all for it being being more explicit as to what's going on.

Sorry if I'm being thick here, just trying to make things clear in my head. So, when I'm using multiple processors be it either when decorating a property or in a multi-processor I'd use the ChainContext rather than the Context?

@Nicholas-Westby
Copy link

@mattbrailsford Sounds like a good solution. I'll give it a test once it's available via MyGet.

To echo what @jamiepollock said, would I also need to use the chainContext parameter rather than processorContext? That is, on the very first call to As() (before the nested calls to As())?

Assuming, of course, that I have a particular context I want to provide.

@jamiepollock
Copy link

jamiepollock commented Feb 2, 2017 via email

@mattbrailsford
Copy link
Collaborator Author

@jamiepollock @Nicholas-Westby the ChainContext is really just an internal thing. It keeps a cache of processor contexts. You shouldn't need to interact with it yourself. Your processor will still be passed the relevant processor context via it's Context property, so you should continue to use that. The ChainContext just allows us to pass "Chain related contextual information" down the entire chain.

@Nicholas-Westby
Copy link

@mattbrailsford I built this pull request and updated my local and it seemed to work perfectly without any code changes. ✅ 👍

Nicholas-Westby added a commit to rhythmagency/rhythm.umbraco.ditto that referenced this pull request Feb 2, 2017
Nicholas-Westby added a commit to rhythmagency/rhythm.umbraco.ditto.archetype that referenced this pull request Feb 2, 2017
@leekelleher
Copy link
Collaborator

@mattbrailsford Are you happy for this to be merged in? or are there still questions around this?

@mattbrailsford
Copy link
Collaborator Author

mattbrailsford commented May 30, 2017 via email

# Conflicts:
#	src/Our.Umbraco.Ditto/Extensions/PublishedContentExtensions.cs
@leekelleher leekelleher merged commit 81dd341 into develop May 30, 2017
@leekelleher leekelleher deleted the ditto-chain-context branch May 30, 2017 23:01
@leekelleher leekelleher added this to the 0.11.0 milestone May 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants