c# – Running series of steps depending on implementation

What is the “best way” to implement something like this:

I have a list of steps that will be iterated and ran for an IContext instance. But, some steps will only apply to a specific instance derived from IContext, while other steps can apply to any instance implementing IContext.

I could create an abstract class ContextStep<TContext> : IStep that will implement the interface and do a type check and downcast the IContext to the generic type in Run(IContext), but I feel like there a better ways of doing this and I am describing an existing pattern.

Why: I want to be able to do stuff specific to a context in a step, e.g. on a DoorContext I want to call Close(), which is specific to the DoorContext.

Pseudo code:

interface IStep
      void Run(IContext context);

IContext context = new DoorContext();
// Steps is a collection of steps, of which some should only be ran for a specific context implementation.
foreach (var step in steps)