Exemplo n.º 1
0
        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++;
            }
        }
Exemplo n.º 2
0
 internal static void AddStepIfNecessary(this List <ISourceCodeBuilderStep> steps, bool test, ISourceCodeBuilderStep step)
 {
     if (test)
     {
         steps.Add(step);
     }
 }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 private static bool DoesStepMatchType(ISourceCodeBuilderStep step, Type type)
 {
     return(type.IsAssignableFrom(step.GetType()));
 }