Classes and interfaces

In this section, each class and interface of the concept will be explained in details.

Kipon.Xrm.Attributes.PostdimageAttribute

The [Postimage] attribute can be used to decorate a parameter for a plugin step, and that way indicate that the parameter should be parsed a post image.

You only need to use this attribute if you, for whatever reason, do not wish to follow one of the recommended approaches:

  • 1. Create a jummy jummy interface that extends the I[entity]Postimage interface. This is the most SOLID apprach, because creating and interface is removing the dependency to the underlying entity class implementation, and ensure that all dependencies are based on abstractions.
  • 2. Use the naming convention of the Kipon.Solid framework by naming the parameter "postimage"

using Kipon.Xrm.Attributes;

namespace Kipon.PluginExample.Plugins.AttributeExamples
{
    public class PostimagePlugin : Kipon.Xrm.BasePlugin
    {
        // 1 best pratcise for injecting ... the IFullNameResult is a jummy jummy interface extending IContactPostimage
        public void OnPostCreate(Entities.Contact.IFullNameResult contact) { }

        // 2 less good pratcise, injecting the full contact post image by naming convention
        public void OnPostCreate(Entities.Contact postimage) { }

        // 3 less good pratcise, injecting the full contact post by parameter decorator
        public void OnPostCreate([Postimage]Entities.Contact contact, ServiceAPI.IAccountOwnershipService service) { }
    }
}

Above example is demonstrating the three different ways you can inject the contact post image into plugin steps.

The IFullNameResult is defined like this:


namespace Kipon.PluginExample.Entities
{
    public partial class Contact : Contact.IFullNameResult
    {
        public interface IFullNameResult : IContactPostimage
        {
            string FullName { get; }
        }
    }
}

Images, (Pre, Post, Merged) can only be injected into plugin step. If you need them in a service, parse them to a method on that service

© Kipon ApS 2020, 2021, 2022, 2023. All content on the page is the property of Kipon ApS. Any republish or copy of this content is a violation. The content of this site is NOT open source, and cannot be copied, republished or used in any context without explcit permission from the owner.