public static void ReplaceAll( this List <ISourceCodeBuilderStep> steps, Type stepType, ISourceCodeBuilderStep replacementStep) { int index = 0; foreach (ISourceCodeBuilderStep step in steps.ToArray()) { if (DoesStepMatchType(step, stepType)) { steps[index] = replacementStep; } index++; } }
internal static void AddStepIfNecessary(this List <ISourceCodeBuilderStep> steps, bool test, ISourceCodeBuilderStep step) { if (test) { steps.Add(step); } }
public static void InsertBefore(this List <ISourceCodeBuilderStep> steps, Type type, ISourceCodeBuilderStep step) { int?index = steps.FindIndex(type); if (index.HasValue) { steps.Insert(index.Value, step); } }
private static bool DoesStepMatchType(ISourceCodeBuilderStep step, Type type) { return(type.IsAssignableFrom(step.GetType())); }