CellsAutomate.Mutator.Mutations.DeleteCommandMutation.AssertCommandWithConstruction C# (CSharp) Method

AssertCommandWithConstruction() private method

private AssertCommandWithConstruction ( int index ) : void
index int
return void
        private void AssertCommandWithConstruction(int index)
        {
            if (_commands[index] is CloseCondition)
            {
                var countOfAnotherCloseConditions = 0;
                for (int i = index - 1; i >= 0; i--)
                {
                    if (_commands[i] is CloseCondition)
                    {
                        countOfAnotherCloseConditions++;
                        continue;
                    }
                    if (_commands[i] is Condition)
                    {
                        if (countOfAnotherCloseConditions > 0)
                        {
                            countOfAnotherCloseConditions--;
                            continue;
                        }
                        if (_marks[i]) return;
                        Delete(i);
                        break;
                    }
                }
            }
            if (_commands[index] is Condition)
            {
                var countOfAnotherConditions = 0;
                for (int i = index + 1; i < _commands.Count; i++)
                {
                    if (_commands[i] is Condition)
                    {
                        countOfAnotherConditions++;
                        continue;
                    }
                    if (_commands[i] is CloseCondition)
                    {
                        if (countOfAnotherConditions > 0)
                        {
                            countOfAnotherConditions--;
                            continue;
                        }
                        if (_marks[i]) return;
                        Delete(i);
                        break;
                    }
                }
            }
        }