Classes and interfaces

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

Kipon.Xrm.Attributes.PredimageAttribute

The [Preimage] attribute can be used to decorate a parameter for a plugin step, and that way indicate that the parameter should be parsed a pre 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]Preimage 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 "Preimage"

using Kipon.Xrm.Attributes;

namespace Kipon.PluginExample.Plugins.AttributeExamples
{
    public class PreimagePlugin : Kipon.Xrm.BasePlugin
    {
        // 1 best pratcise for injecting ... the ICurrentFullname is a jummy jummy interface extending IContactPreimage
        public void OnPreCreate(Entities.Contact.ICurrentFullname contact) { }

        // 2 less good pratcise, injecting the full contact pre image by naming convention
        public void OnPreCreate(Entities.Contact preimage) { }

        // 3 less good pratcise, injecting the full contact pre image by parameter decorator
        public void OnPreCreate([Preimage]Entities.Contact contact, ServiceAPI.IAccountOwnershipService service) { }
    }
}

Above example is demonstrating the three different ways you can inject the contact Pre 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.