internal SourceCodeStepRange( List <ISourceCodeBuilderStep> list, List <ISourceCodeBuilderStep> range, SourceCodePlaceholder startPlaceholder, SourceCodePlaceholder endPlaceholder) { OriginalList = list; Range = range; this.startPlaceholder = startPlaceholder; this.endPlaceholder = endPlaceholder; }
public static SourceCodeStepRange GetRange( this List <ISourceCodeBuilderStep> steps, SourceCodePlaceholder startPlaceholder, SourceCodePlaceholder endPlaceholder) { int?startIndex = steps.FindIndex(startPlaceholder); int?endIndex = steps.FindIndex(endPlaceholder); if (!startIndex.HasValue && !endIndex.HasValue) { return(null); } int length = endIndex.Value - startIndex.Value; if (length <= 0) { return(null); } return(new SourceCodeStepRange(steps, steps.GetRange(startIndex.Value, length), startPlaceholder, endPlaceholder)); }
internal static void AddPlaceholder(this List <ISourceCodeBuilderStep> steps, SourceCodePlaceholder placeholder) { steps.Add(new PlaceholderStep(placeholder)); }
public static int?FindIndex(this List <ISourceCodeBuilderStep> steps, SourceCodePlaceholder placeholder) { return(AsNullable(steps.FindIndex(GetPlaceholderPredicate(placeholder)))); }
private static Predicate <ISourceCodeBuilderStep> GetPlaceholderPredicate(SourceCodePlaceholder placeholder) { return(step => step is PlaceholderStep placeHolderStep && placeHolderStep.Placeholder == placeholder); }
public PlaceholderStep(SourceCodePlaceholder placeholder) { Placeholder = placeholder; }