Skip to content

Instantly share code, notes, and snippets.

@furkankaracan
Last active April 5, 2023 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furkankaracan/9598a806157f3702ca6cada65e3257a1 to your computer and use it in GitHub Desktop.
Save furkankaracan/9598a806157f3702ca6cada65e3257a1 to your computer and use it in GitHub Desktop.
public void Execute(IServiceProvider serviceProvider)
{
// Obtain the tracing service
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext executionContext = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext))
int counter = 0;
//Check existence of shared variable and fetch the value from executionContext
if (executionContext.ParentContext != null && executionContext.ParentContext.SharedVariables.ContainsKey("Counter"))
{
counter = (int)executionContext.SharedVariables.ContainsKey("Counter");
}
executionContext.SharedVariables.Add("Counter",counter++);
// your logic
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment