本文整理汇总了C#中SpreadsheetUtilities.Formula.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Formula.ToString方法的具体用法?C# Formula.ToString怎么用?C# Formula.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpreadsheetUtilities.Formula
的用法示例。
在下文中一共展示了Formula.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEqualsFromToString
public void TestEqualsFromToString()
{
string expression = "x + 2";
Formula a = new Formula(expression);
Formula b = new Formula(a.ToString());
Assert.AreEqual(true, a.Equals(b));
Assert.AreEqual(true, b.Equals(a));
}
示例2: TestConstructorFailFunc
public void TestConstructorFailFunc()
{
Formula testFormula = new Formula("3 + x", s => s.ToLower(), s => (s == "X") ? true : false);
Assert.AreEqual("3+X", testFormula.ToString());
}
示例3: TestToStringWithNormalizer
public void TestToStringWithNormalizer()
{
Formula f = new Formula("a2*A4 + A5 / B2", VarToUpper, IsValid);
Assert.AreEqual("A2*A4+A5/B2", f.ToString());
}
示例4: SetCellContents
/// <summary>
/// Takes in a cell name and a formula and returns the dependents
/// Calculates the value of the formula then recalculates the value of any cell that depends directly or inderectly on it.
/// </summary>
/// <param name="name"></param>
/// <param name="formula"></param>
/// <returns></returns>
protected override ISet<string> SetCellContents(string name, Formula formula)
{
name = Normalize(name);
HashSet<string> mySet = new HashSet<string>();
HashSet<string> replaceSet = new HashSet<string>();
if (Object.ReferenceEquals(formula, null))
{
throw new ArgumentNullException();
}
if (Object.ReferenceEquals(name, null))
{
throw new InvalidNameException();
}
if (!Regex.IsMatch(name, "^([a-z]|[A-Z])+\\d+$") | !IsValid(name))
{
throw new InvalidNameException();
}
try
{
foreach (string s in formula.GetVariables())
{
replaceSet.Add(s);
}
// dependentCells.ReplaceDependees(name, mySet);
dependentCells.ReplaceDependees(name, replaceSet);
GetCellsToRecalculate(name);
}
catch (CircularException)
{
throw new CircularException();
}
Formula myEvl = new Formula(formula.ToString(), IsValid, Normalize);
myCell = new Cell(formula, myEvl.Evaluate(myLookup));
if (mySpreadsheet.ContainsKey(name))
{
mySpreadsheet[name] = myCell;
}
else
{
mySpreadsheet.Add(name, myCell);
}
mySet.Add(name);
foreach (string s in GetCellsToRecalculate(name))
{
mySet.Add(s);
}
foreach (string s in mySet)
{
myCell = new Cell(GetCellContents(s), myEvaluate(s));
mySpreadsheet[s] = myCell;
}
Changed = true;
return mySet;
}
示例5: NormalizeFormula
/// <summary>
/// Returns the formula with all the variables replaced with their normalized counterpart.
/// </summary>
/// <param name="f"></param>
/// <returns></returns>
protected Formula NormalizeFormula(Formula f)
{
IEnumerable<string> e = f.GetVariables();
foreach (string s in e)
{
f = new Formula(Regex.Replace(f.ToString(), s, Normalize(s)));
}
return f;
}
示例6: TestToString2
public void TestToString2()
{
Formula f = new Formula("x + Y");
String temp = "x+Y";
Assert.IsTrue(f.ToString().Equals(temp));
}
示例7: Test51e
public void Test51e()
{
Formula f1 = new Formula("2");
Formula f2 = new Formula("3");
Assert.IsTrue(f1.ToString().IndexOf("2") >= 0);
Assert.IsTrue(f2.ToString().IndexOf("3") >= 0);
}
示例8: TestConstructorStandardParenthesis2
public void TestConstructorStandardParenthesis2()
{
Formula testFormula = new Formula("(4.0 + 2.0)");
Assert.AreEqual("(4.0+2.0)", testFormula.ToString());
}
示例9: PublicTestToString
public void PublicTestToString()
{
Formula f1 = new Formula("5+5-A1/b4");
Assert.AreEqual("5+5-A1/b4", f1.ToString());
}
示例10: PublicTestConstructor1
public void PublicTestConstructor1()
{
Formula f1 = new Formula("6/2+4 - (4+4)");
Assert.AreEqual("6/2+4-(4+4)", f1.ToString());
}
示例11: PublicTestConstructor
public void PublicTestConstructor()
{
Formula f1 = new Formula("(5+5)");
Assert.AreEqual("(5+5)", f1.ToString());
}
示例12: SetCellContentsFormulaNull
public void SetCellContentsFormulaNull()
{
Spreadsheet target = new Spreadsheet();
Formula formula = new Formula("a1+3", s => true, s => s);
formula = null;
target.SetContentsOfCell("a7", formula.ToString());
}
示例13: SetCellContentsFormulaInvalidName
public void SetCellContentsFormulaInvalidName()
{
Spreadsheet target = new Spreadsheet();
Formula formula = new Formula("i4+78-98.7", s => true, s => s);
target.SetContentsOfCell("a0a", formula.ToString());
}
示例14: SetCellContentsCircularException
public void SetCellContentsCircularException()
{
Spreadsheet target = new Spreadsheet();
Formula formula = new Formula("b1+b1", s => true, s => s);
target.SetContentsOfCell("b1", "=b1+b1");
formula=new Formula("b1+b1",s=>true,s=>s);
target.SetContentsOfCell("a1", formula.ToString());
}
示例15: TestConstructorStandard
public void TestConstructorStandard()
{
Formula testFormula = new Formula("4.0 + 2.0");
Assert.AreEqual("4.0+2.0", testFormula.ToString());
}