Skip to content

Instantly share code, notes, and snippets.

@gashupl
Created April 23, 2019 18:12
Show Gist options
  • Save gashupl/74c7ebe572c9583c30d55a5cc4da060d to your computer and use it in GitHub Desktop.
Save gashupl/74c7ebe572c9583c30d55a5cc4da060d to your computer and use it in GitHub Desktop.
protected T GetTargetEntity<T>(IPluginExecutionContext pluginExecutionContext) where T: Entity
{
if (pluginExecutionContext.InputParameters.Contains(TargetAttributeName) && pluginExecutionContext.InputParameters[TargetAttributeName] is Entity)
{
return ((Entity)pluginExecutionContext.InputParameters[TargetAttributeName])?.ToEntity<T>();
}
else
{
throw new InvalidPluginExecutionException(OperationStatus.Failed, "Missing target value or target is not an Entity");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment