protected override void Execute(IPluginContext local)
        {
            var attributes = _attributes;

            if (attributes == null)
            {
                return;
            }

            var target = local.GetTargetEntity();
            var image  = local.GetEntityImage(EntityImageType.PreImage);

            var messages = new StringBuilder();

            foreach (var attribute in attributes)
            {
                var tuple = Helper.GetAttributeNameAndLabel(attribute);

                if (!target.EnsureAttributeReadOnly(image, tuple.Item1))
                {
                    messages.AppendLine(String.Format(message, tuple.Item2));
                }
            }

            if (messages.Length > 0)
            {
                throw new InvalidPluginExecutionException(messages.ToString().TrimEnd('\r', '\n'));
            }
        }
        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);
        }
 public static Entity GetEntityImage(this IPluginContext pluginContext, EntityImageType imageType, Boolean throwIfNull = false)
 {
     return(pluginContext.GetEntityImage(imageType.ToString(), imageType, throwIfNull));
 }