コード例 #1
0
        CodeCellState InsertCodeCell(CodeCell newCell, Cell previousCell)
        {
            if (newCell == null)
            {
                throw new ArgumentNullException(nameof(newCell));
            }

            InsertCellInDocumentModel(newCell, previousCell);

            var previousCodeCell = newCell.GetPreviousCell <CodeCell> ();
            var nextCodeCell     = newCell.GetNextCell <CodeCell> ();

            var codeCellState = new CodeCellState(newCell);

            BindCodeCellToView(newCell, codeCellState);

            if (ClientSession.CompilationWorkspace != null)
            {
                codeCellState.CompilationWorkspace = ClientSession.CompilationWorkspace;
                codeCellState.DocumentId           = ClientSession.CompilationWorkspace.AddSubmission(
                    newCell.CodeAnalysisBuffer.CurrentText,
                    GetDocumentId(previousCodeCell),
                    GetDocumentId(nextCodeCell));
            }

            InsertCellInViewModel(newCell, previousCell);

            OutdateAllCodeCells(newCell);

            AppendCodeCell(codeCellState.Editor, codeCellState);

            return(codeCellState);
        }
コード例 #2
0
 CodeCellId GetCodeCellId(CodeCell codeCell)
 {
     if (codeCell?.View?.Editor != null &&
         CodeCells.TryGetValue(codeCell.View.Editor, out CodeCellState codeCellState))
     {
         return(codeCellState.CodeCellId);
     }
     return(null);
 }
コード例 #3
0
 void OutdateAllCodeCells(CodeCell codeCell)
 {
     while (codeCell != null)
     {
         var view = (ICodeCellView)codeCell.View;
         if (view != null)
         {
             view.IsOutdated = true;
         }
         codeCell = codeCell.GetNextCell <CodeCell> ();
     }
 }
コード例 #4
0
        CodeCellState InsertCodeCell(CodeCell newCell, Cell previousCell, bool isHidden = false)
        {
            if (newCell == null)
            {
                throw new ArgumentNullException(nameof(newCell));
            }

            InsertCellInDocumentModel(newCell, previousCell);

            var previousCodeCell = newCell.GetPreviousCell <CodeCell> ();
            var nextCodeCell     = newCell.GetNextCell <CodeCell> ();

            var codeCellState = new CodeCellState(newCell);

            if (isHidden)
            {
                // Set up editor, required as dictionary key
                codeCellState.Editor = new HiddenCodeCellEditor();
                codeCellState.View   = new HiddenCodeCellView {
                    Editor = codeCellState.Editor
                };
                newCell.View = codeCellState.View;
            }
            else
            {
                BindCodeCellToView(newCell, codeCellState);
            }

            if (ClientSession.CompilationWorkspace != null)
            {
                codeCellState.BindToWorkspace(
                    ClientSession.CompilationWorkspace,
                    ClientSession.CompilationWorkspace.InsertCell(
                        newCell.Buffer.Value,
                        GetCodeCellId(previousCodeCell),
                        GetCodeCellId(nextCodeCell)));
            }

            if (!isHidden)
            {
                InsertCellInViewModel(newCell, previousCell);
            }

            OutdateAllCodeCells(newCell);

            AppendCodeCell(codeCellState.Editor, codeCellState);

            return(codeCellState);
        }
コード例 #5
0
 public CodeCellState(CodeCell cell)
 => Cell = cell ?? throw new ArgumentNullException(nameof(cell));
コード例 #6
0
 protected abstract void BindCodeCellToView(CodeCell cell, CodeCellState codeCellState);