示例#1
0
 internal SourceCodeStepRange(
     List <ISourceCodeBuilderStep> list,
     List <ISourceCodeBuilderStep> range,
     SourceCodePlaceholder startPlaceholder,
     SourceCodePlaceholder endPlaceholder)
 {
     OriginalList          = list;
     Range                 = range;
     this.startPlaceholder = startPlaceholder;
     this.endPlaceholder   = endPlaceholder;
 }
示例#2
0
        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));
        }
示例#3
0
 internal static void AddPlaceholder(this List <ISourceCodeBuilderStep> steps, SourceCodePlaceholder placeholder)
 {
     steps.Add(new PlaceholderStep(placeholder));
 }
示例#4
0
 public static int?FindIndex(this List <ISourceCodeBuilderStep> steps, SourceCodePlaceholder placeholder)
 {
     return(AsNullable(steps.FindIndex(GetPlaceholderPredicate(placeholder))));
 }
示例#5
0
 private static Predicate <ISourceCodeBuilderStep> GetPlaceholderPredicate(SourceCodePlaceholder placeholder)
 {
     return(step => step is PlaceholderStep placeHolderStep && placeHolderStep.Placeholder == placeholder);
 }
示例#6
0
 public PlaceholderStep(SourceCodePlaceholder placeholder)
 {
     Placeholder = placeholder;
 }