protected override void Execute(IPluginContext context)
        {
            this.EnsureNotNull(context, nameof(context));

            context.EnsureTargetLogicalName(LogEntryEntity.TypeName(_prefix));

            var target = context.GetTargetEntity();

            var user = target.GetAttributeValue <EntityReference>(LogEntryEntity.UserFieldName(_prefix));

            if (user == null)
            {
                user = new EntityReference(SystemUserEntity.TypeName, context.ExecutionContext.InitiatingUserId);

                target.AddOrUpdateAttribute(LogEntryEntity.UserFieldName(_prefix), user);
            }
        }
        protected override void Execute(IPluginContext context)
        {
            this.EnsureNotNull(context, nameof(context));

            context.EnsureTargetLogicalName(GlobalSettingEntity.TypeName(_prefix));

            var target = context
                         .GetTargetEntity();
            var image = context
                        .GetEntityImage(EntityImageType.PreImage, throwIfNull: context.IsUpdateMessage());

            var type = target
                       .GetAttributeValue <OptionSetValue>(GlobalSettingEntity.TypeFieldName(_prefix), image)?
                       .ToEnum <GlobalSettingType>() ?? GlobalSettingType.String;
            var value = target
                        .GetAttributeValue <String>(GlobalSettingEntity.ValueFieldName(_prefix), image);

            ValidateValue(type, value);
            SanitizeValue(target, type, value);
        }
Example #3
0
        protected virtual void Validate(IPluginContext context, Type pluginType)
        {
            var attributes = new PluginAttributesCollection(pluginType);

            if (attributes.ExecutionModes.Any())
            {
                context.EnsureSupportedExecutionMode(attributes.ExecutionModes.ToArray());
            }

            if (attributes.PipelineStages.Any())
            {
                context.EnsureSupportedPipelineStage(attributes.PipelineStages.ToArray());
            }

            if (attributes.PipelineMessages.Any())
            {
                context.EnsureSupportedMessage(attributes.PipelineMessages.ToArray());
            }

            if (!String.IsNullOrWhiteSpace(attributes.PrimaryEntityLogicalName))
            {
                context.EnsureTargetLogicalName(attributes.PrimaryEntityLogicalName);
            }
        }