Using System;
using System.Collections.Generic;
using Formulas;
namespace SS
{
///
///
///
public class CircularException : Exception
{
}
///
///namenull
///
public class InvalidNameException : Exception
{
}
///
///
///
public struct FormulaError
{
///
/// FormulaError
///
public FormulaError(String reason)
: this()
{
Reason = reason;
}
///
///The reason why this FormulaError was created. FormulaError
///
public string Reason { get; private set; }
}
///
/// AbstractSpreadsheetobject
/// strings
///A15a15XY32BC7ZX07hello
///
///
/// 1string2double3formula Excel
///
/// 1string2double3FormulaError Excel
/// stringstring
/// doubledouble
/// FormuladoubleFormulaError
/// Formula
valuedoubleFormulaErrordoubleFormula.Evaluate
///
///A1B1 * 2B1C1 * 2C1A1 * 2
/// A1B1C1A1
///
public abstract class AbstractSpreadsheet
{
///
/// Enumerates the names of all the non-empty cells in the spreadsheet.
///
public abstract IEnumerable
///
/// namenullinvalidInvalidNameException
stringdoubleFormula
///
public abstract object GetCellContents(String name);
///
/// namenullinvalidInvalidNameException
///
/// nameA1B1A1 * 2C1B1 + A1{A1B1C1}
///
public abstract ISet
///
/// textnullArgumentNullException
/// namenullInvalidNameException
/// text
///nameA1B1A1 * 2C1B1 + A1return{A1B1C1}
///
public abstract ISet
///
/// formula
/// namenullInvalidNameException
/// CircularException
/// formulareturnnamenameSet
///nameA1B1A1 * 2C1B1 + A1{A1B1C1}
///
public abstract ISet
///
/// namenullArgumentNullException.
/// namenameInvalidNameException.
///
A13B1A1*A1 C1B1+A1D1B1-C1.A1B1C1
///
protected abstract IEnumerable
///
///
///
protected IEnumerable
{
LinkedList
HashSet
foreach (String name in names)
{
if (!visited.Contains(name))
{
Visit(name, name, visited, changed);
}
}
return changed;
}
///
///GetCellsToRecalculate
///
protected IEnumerable
{
return GetCellsToRecalculate(new HashSet
}
///
/// A helper for the GetCellsToRecalculate method.
///
private void Visit(String start, String name, ISet
{
visited.Add(name);
foreach (String n in GetDirectDependents(name))
{
if (n.Equals(start))
{
throw new CircularException();
}
else if (!visited.Contains(n))
{
Visit(start, n, visited, modified);
}
}
modified.AddFirst(name);
}
}
}
Reviews
There are no reviews yet.