private int GetArrayIndex(Char2 bracePosition, Char2[] braces) { for (var i = 0; i < braces.Length; i++) { if (braces[i].Position != bracePosition.Position) { continue; } return(i); } throw new IndexOutOfRangeException(); }
private void Draw(Char2 bracePosition) { var braces = this.chars.Where(x => x.IsBrace).ToArray(); int posStart, posEnd; if (bracePosition.Brace?.BraceState == BraceState.IsOpenBrace) { posStart = bracePosition.Position; posEnd = GetOppositePos(bracePosition, braces); } else { posStart = GetOppositePos(bracePosition, braces); posEnd = bracePosition.Position; } this.Draw(posStart, posEnd); }
private int GetOppositePos(Char2 bracePosition, Char2[] braces) { int arrayIndex = GetArrayIndex(bracePosition, braces); return(braces[braces.Length - 1 - arrayIndex].Position); }