private void Initialize(StringBuilder sb, int startIndex, int endIndex, FileSection parent = null) { gscope = sb; if (parent != null) { Parent = parent; si = parent.si + parent.ResolveNegativeIndex(startIndex); ei = parent.si + parent.ResolveNegativeIndex(endIndex); parent.IndexChanged += Parent_IndexChanged; } else { Parent = new NullFileSection(gscope.Length); si = Util.ResolveNegativeIndex(startIndex, sb.Length); ei = Util.ResolveNegativeIndex(endIndex, sb.Length); } this.IndexChanged += FileSection_IndexChanged; }
/// <summary> /// Creates a new child FileSection with the specified parent, starting at <paramref name="startIndex"/> and ending at <paramref name="endIndex"/> of the string /// </summary> /// <param name="parent">The parent FileSection of this FileSection</param> /// <param name="startIndex">The index of <paramref name="parent"/> this FileSection will start at</param> /// <param name="endIndex">The index of <paramref name="parent"/> this FileSection will end at</param> public FileSection(FileSection parent, int startIndex, int endIndex) { Initialize(parent.gscope, startIndex, endIndex, parent); }