Classes and interfaces

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

Kipon.Xrm.Attributes.MergedimageAttribute

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

using Kipon.Xrm.Attributes;

namespace Kipon.PluginExample.Plugins.AttributeExamples
{
    public class MergedimagePlugin : Kipon.Xrm.BasePlugin
    {
        // 1 best pratcise for injecting ... the IOwnershipLogging is a jummy jummy interface extending IAccountMergedimage
        public void OnPreCreate(Entities.Account.IOwnershipLogging account) { }

        // 2 less good pratcise, injecting the full account merged image by naming convention
        public void OnPreCreate(Entities.Account mergedimage) { }

        // 3 less good pratcise, injecting the full account merged by parameter decorator
        public void OnCreate([Mergedimage]Entities.Account account, ServiceAPI.IAccountOwnershipService service) { }
    }
}

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

The IOwnershipLogging interface looks like this:


using Kipon.Xrm.Attributes;

namespace Kipon.PluginExample.Entities
{
    public partial class Account : Account.IOwnershipLogging
    {
        bool IOwnershipLogging.DescriptionChanged => this.TargetAttributes.ContainsKey(nameof(Description).ToLower());

        public interface IOwnershipLogging : IAccountMergedimage
        {
            [TargetFilter]
            Microsoft.Xrm.Sdk.EntityReference OwnerId { get; set; }

            [TargetFilter]
            string Description { get; set; }

            bool DescriptionChanged { 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, 2024. 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.