コード例 #1
0
        private void CheckRecursion(Spreadsheet spreadsheet, Cell current, ISet <CellAddress> stack)
        {
            try
            {
                var dependencies = PooledHashSet <CellAddress> .GetInstance();

                try
                {
                    GetDependencies(current.Expression, dependencies);
                    if (dependencies.Overlaps(stack))
                    {
                        throw new CircularCellRefereceException(Resources.CircularReference);
                    }

                    stack.Add(current.Address);
                    foreach (var address in dependencies)
                    {
                        CheckRecursion(spreadsheet, spreadsheet[address], stack);
                    }
                    stack.Remove(current.Address);
                }
                finally
                {
                    dependencies.Free();
                }
            }
            catch (CircularCellRefereceException ex)
            {
                throw SpreadsheetException.AddCellAddressToErrorStack(ex, current.Address);
            }
        }
コード例 #2
0
 public object Evaluate(SpreadsheetProcessor processor)
 {
     try
     {
         return(Expression.Evaluate(processor));
     }
     catch (SpreadsheetException exception)
     {
         throw SpreadsheetException.AddCellAddressToErrorStack(exception, Address);
     }
     catch (Exception exception)
     {
         throw SpreadsheetException.AddCellAddressToErrorStack(new ExpressionEvaluationException(exception.Message, exception), Address);
     }
 }