protected override void Execute(IPluginContext context) { var attributes = _attributes; if (attributes == null) { return; } var target = context.GetTargetEntity(); var create = context.IsCreateMessage(); var messages = new StringBuilder(); foreach (var attribute in attributes) { var tuple = Helper.GetAttributeNameAndLabel(attribute); if (create && !target.EnsureAttributeRequired(tuple.Item1)) { messages.AppendLine(String.Format(message, tuple.Item2)); } else if (!create && !target.EnsureAttributeRequired(tuple.Item1, ensureAttributePresent: false)) { messages.AppendLine(String.Format(message, tuple.Item2)); } } if (messages.Length > 0) { throw new InvalidPluginExecutionException(messages.ToString().TrimEnd('\r', '\n')); } }