in SamplesV1/ADFCustomActivityRunner/CustomActivityRunner/CustomActivityBase.cs [26:57]
public CustomActivityBase()
{
if (Debugger.IsAttached)
{
var attributes = this.GetType().GetMethod("RunActivity").CustomAttributes;
var customActivityAttribute = attributes.FirstOrDefault(x => x.AttributeType.Name == "CustomActivityAttribute");
string activityName = customActivityAttribute?.NamedArguments?.FirstOrDefault(x => x.MemberName == "ActivityName").TypedValue.Value?.ToString();
string pipelineLocation = customActivityAttribute?.NamedArguments?.FirstOrDefault(x => x.MemberName == "PipelineLocation").TypedValue.Value?.ToString();
string deployConfig = customActivityAttribute?.NamedArguments?.FirstOrDefault(x => x.MemberName == "DeployConfig").TypedValue.Value?.ToString();
if (!string.IsNullOrEmpty(activityName) || !string.IsNullOrEmpty(pipelineLocation))
{
string dataFactoryProjLocation =
Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..\\..", Path.GetDirectoryName(pipelineLocation)));
DotNetActivityContext context = Runner.DeserializeActivity(Path.GetFileName(pipelineLocation), activityName, deployConfig, dataFactoryProjLocation);
LinkedServices = context.LinkedServices;
Datasets = context.Datasets;
Activity = context.Activity;
Logger = context.Logger;
typeProperties = Activity.TypeProperties as DotNetActivity;
}
else
{
throw new Exception($"The CustomActivity attribute needs to have the following properties populated: {nameof(CustomActivityAttribute.PipelineLocation)} and {nameof(CustomActivityAttribute.ActivityName)}");
}
}
}