private void ReorderMembers(CodeElement2 type, IEnumerable <CodeMember> members, string orderedCode, TextPoint startPoint)
        {
            // Removing members will shift the startPoint back one line.
            // So we'll use the absolute offset to jump back to that insert point.
            int startPointOffset = 0;

            if (startPoint != null)
            {
                startPointOffset = startPoint.AbsoluteCharOffset;
            }

            FileCodeModel2 codeModel = this.textHandler.Document.ProjectItem.FileCodeModel as FileCodeModel2;

            codeModel.BeginBatch();
            try
            {
                foreach (CodeMember member in members)
                {
                    member.Remove();
                }
            }
            finally
            {
                codeModel.EndBatch();
            }

            if (startPoint != null)
            {
                EditPoint startEdit = startPoint.CreateEditPoint();
                startEdit.MoveToAbsoluteOffset(startPointOffset);
                startEdit.StartOfLine();

                // If the line above startEdit isn't empty and isn't the start of the class/struct/interface/enum,
                // then insert a blank line so the sortedCode will be separated from the code above it.
                EditPoint lineAboveEdit = startEdit.CreateEditPoint();
                lineAboveEdit.LineUp();
                lineAboveEdit.StartOfLine();
                string lineText = lineAboveEdit.GetText(lineAboveEdit.LineLength).Trim();
                if (lineText.Length != 0 &&
                    lineAboveEdit.Line > type.StartPoint.Line &&
                    (this.language != Language.CSharp || lineText != "{"))
                {
                    startEdit.Insert(Environment.NewLine);
                }

                startEdit.Insert(orderedCode);

                // If the line after startEdit isn't empty and isn't the end of the class/struct/interface/enum,
                // then insert a blank line so the sortedCode will be separated from the code below it.
                startEdit.StartOfLine();
                lineText = startEdit.GetText(startEdit.LineLength).Trim();
                if (lineText.Length != 0 &&
                    startEdit.Line < type.EndPoint.Line &&
                    (this.language != Language.CSharp || lineText != "}"))
                {
                    startEdit.Insert(Environment.NewLine);
                }
            }
        }