Allow constructor dependency injection in Forms Actors

Member since: 2011

Why you are creating new actor instances via Activator.Createinstance (EPiServer.Forms.Core.PostSubmissionActor.ActorsExecutingService)?

#155277 Sep 13, 2016 12:57
  • Member since: 2009

    Hi Valdis,

    Please imagine the Actor is kind of "static" mission, executes after form posted, similar to

    • the task in schedule task runs on specific-time
    • InitModule runs on beginning of the web app

    ActorsExecutingService is used for executing the Actors. It is the default implementation and you can replace its business if you don't like the its business workflow.

    • Fetch all derived types of IPostSubmissionActor
    • And create instance via Reflection, yes
    • Provide context information (http request), form context (form id, submission id, submission data), configured model (from Editor UI)
    • and execute it

    I don't think it is kind of generic purpose instance that you instantiate and use it solely. If you need that kind of freedom in specific project, using the Event mechanism is better.

    #162841 Oct 18, 2016 4:48