Ejemplo n.º 1
0
 private void ApplyChanges()
 {
     if (m_currentExpression != null)
     {
         if (m_currentExpression.Id != m_exprIdTxt.Text)
         {
             throw new Exception("UI is out of sync with data");
         }
         // apply changes.
         m_mgr.As <ITransactionContext>().DoTransaction(delegate
         {
             m_currentExpression.Label  = m_exprLabelTxt.Text;
             m_currentExpression.Script = m_exprTxt.Text;
         }, "Edit expression".Localize()
                                                        );
         m_numOfOperation++;
     }
     else if (!string.IsNullOrWhiteSpace(m_exprTxt.Text))
     {
         Expression expr = m_mgr.CreateExpression();
         expr.Label  = m_exprLabelTxt.Text;
         expr.Script = m_exprTxt.Text;
         m_mgr.As <ITransactionContext>().DoTransaction(delegate
         {
             m_mgr.Expressions.Add(expr);
         }, "Add expression".Localize()
                                                        );
         m_numOfOperation++;
         SetActiveExpression(expr);
     }
 }