-
Notifications
You must be signed in to change notification settings - Fork 32
Refactor core execution and improve plugin assembly handling #332
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ba9d7bb
Split Core's main execution method into smaller chunks for readability
mkholt 4d94e68
Move request pipeline execution into its own class and out of core
mkholt 41e0f71
Fix: Do not re-scan assemblies to avoid multiple versions of the same…
mkholt 63612b0
Fix count in comment
mkholt 1c9ebc0
Move ICoreOperations to Internal namespace
Copilot 7b1cdf8
Inject core into the constructors of the managers instead of passing …
mkholt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| using Microsoft.Xrm.Sdk; | ||
| using System; | ||
|
|
||
| namespace DG.Tools.XrmMockup.Internal | ||
| { | ||
| /// <summary> | ||
| /// Carries all intermediate state for a single request execution through the pipeline stages. | ||
| /// Populated progressively: BuildContext → PreValidation → PreOperation → Operation → PostOperation. | ||
| /// </summary> | ||
| internal class ExecutionPipelineContext | ||
| { | ||
| // Immutable inputs — set once during BuildPipelineContext | ||
| public OrganizationRequest Request { get; set; } | ||
| public EntityReference UserRef { get; set; } | ||
| public PluginContext ParentPluginContext { get; set; } | ||
| public MockupServiceSettings Settings { get; set; } | ||
|
|
||
| // Derived during BuildPipelineContext | ||
| public PluginContext PluginContext { get; set; } | ||
| public string RequestMessage { get; set; } | ||
| public Tuple<object, string, Guid> EntityInfo { get; set; } | ||
| public EntityReference PrimaryRef { get; set; } | ||
| public EntityCollection EntityCollection { get; set; } | ||
| public bool ShouldTrigger { get; set; } | ||
|
|
||
| // Images — populated at specific stage boundaries | ||
| public Entity PreImage { get; set; } // fetched before PreValidation | ||
| public Entity SyncPostImage { get; set; } // fetched at start of PostOperation (sync) | ||
| public Entity AsyncPostImage { get; set; } // fetched before async staging | ||
|
|
||
| // Output — set by the main operation stage | ||
| public OrganizationResponse Response { get; set; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| using DG.Tools.XrmMockup.Database; | ||
| using Microsoft.Xrm.Sdk; | ||
| using Microsoft.Xrm.Sdk.Metadata; | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace DG.Tools.XrmMockup.Internal | ||
| { | ||
| /// <summary> | ||
| /// Infrastructure contract that Core exposes to the pipeline and its managers. | ||
| /// The pipeline orchestrates execution stages; Core provides the underlying services. | ||
| /// PluginManager, WorkflowManager, and PluginTrigger also depend on this interface | ||
| /// so they can be used from the pipeline without a direct Core reference. | ||
| /// </summary> | ||
| internal interface ICoreOperations | ||
| { | ||
| // Identity | ||
| Guid OrganizationId { get; } | ||
| string OrganizationName { get; } | ||
|
|
||
| // Time — used by workflow execution and formula fields | ||
| TimeSpan TimeOffset { get; } | ||
|
|
||
| // DB helpers | ||
| Entity TryRetrieve(EntityReference reference); | ||
| DbRow GetDbRow(EntityReference reference); | ||
| EntityReference GetBusinessUnit(EntityReference owner); | ||
| EntityMetadata GetEntityMetadata(string logicalName); | ||
|
|
||
| // Pre-context setup | ||
| void HandleInternalPreOperations(OrganizationRequest request, EntityReference userRef); | ||
|
|
||
| // Post-operation image helper | ||
| void CopySystemAttributes(Entity postImage, Entity target); | ||
|
|
||
| // Request handler list — used by pipeline for security check and pre-op init | ||
| List<RequestHandler> RequestHandlers { get; } | ||
|
|
||
| // Recursive entry point for nested requests (Assign → Update, SetState → Update) | ||
| OrganizationResponse Execute(OrganizationRequest request, EntityReference userRef, PluginContext parentPluginContext); | ||
|
|
||
| // Dispatch helpers — Core owns the managers so the pipeline delegates through these | ||
| OrganizationResponse ExecuteAction(OrganizationRequest request); | ||
| bool HandlesCustomApi(string requestName); | ||
| OrganizationResponse ExecuteCustomApi(OrganizationRequest request, PluginContext pluginContext); | ||
| bool IsExceptionFreeRequest(string requestName); | ||
|
|
||
| // Extension stage support | ||
| bool HasMockupExtensions { get; } | ||
| IOrganizationService CreateMockupService(Guid? userId, PluginContext pluginContext); | ||
| void TriggerExtension(IOrganizationService service, OrganizationRequest request, Entity entity, Entity preImage, EntityReference userRef); | ||
|
|
||
| // Service factories — used by PluginTrigger and WorkflowManager to create execution providers | ||
| MockupServiceProviderAndFactory ServiceFactory { get; } | ||
| ITracingServiceFactory TracingServiceFactory { get; } | ||
| MockupServiceProviderAndFactory CreateServiceProviderAndFactory(PluginContext pluginContext); | ||
|
|
||
| // Settings — used by WorkflowManager | ||
| XrmMockupSettings GetMockupSettings(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.