当前位置: 首页>>代码示例>>C#>>正文


C# Formula.ToString方法代码示例

本文整理汇总了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));
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:8,代码来源:FormulaUnitTest1.cs

示例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());
 }
开发者ID:Buck417,项目名称:First-Half-CS-3500,代码行数:5,代码来源:UnitTest1.cs

示例3: TestToStringWithNormalizer

 public void TestToStringWithNormalizer()
 {
     Formula f = new Formula("a2*A4 + A5 / B2", VarToUpper, IsValid);
     Assert.AreEqual("A2*A4+A5/B2", f.ToString());
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:5,代码来源:FormulaUnitTest1.cs

示例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;
        }
开发者ID:HyveMynd,项目名称:CloudSpreadSheet,代码行数:65,代码来源:Spreadsheet.cs

示例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;
        }
开发者ID:jam98,项目名称:Spreadsheet,代码行数:15,代码来源:Spreadsheet.cs

示例6: TestToString2

        public void TestToString2()
        {
            Formula f = new Formula("x + Y");
            String temp = "x+Y";

            Assert.IsTrue(f.ToString().Equals(temp));
        }
开发者ID:HeroOfCanton,项目名称:CS3500,代码行数:7,代码来源:FormulaTester.cs

示例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);
 }
开发者ID:HeroOfCanton,项目名称:CS3500,代码行数:7,代码来源:GradingTests.cs

示例8: TestConstructorStandardParenthesis2

 public void TestConstructorStandardParenthesis2()
 {
     Formula testFormula = new Formula("(4.0 + 2.0)");
     Assert.AreEqual("(4.0+2.0)", testFormula.ToString());
 }
开发者ID:Buck417,项目名称:First-Half-CS-3500,代码行数:5,代码来源:UnitTest1.cs

示例9: PublicTestToString

 public void PublicTestToString()
 {
     Formula f1 = new Formula("5+5-A1/b4");
     Assert.AreEqual("5+5-A1/b4", f1.ToString());
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:5,代码来源:FormulaTester.cs

示例10: PublicTestConstructor1

 public void PublicTestConstructor1()
 {
     Formula f1 = new Formula("6/2+4 - (4+4)");
     Assert.AreEqual("6/2+4-(4+4)", f1.ToString());
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:5,代码来源:FormulaTester.cs

示例11: PublicTestConstructor

 public void PublicTestConstructor()
 {
     Formula f1 = new Formula("(5+5)");
     Assert.AreEqual("(5+5)", f1.ToString());
 }
开发者ID:Leyalic,项目名称:PS6_2015,代码行数:5,代码来源:FormulaTester.cs

示例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());
 }
开发者ID:HyveMynd,项目名称:CloudSpreadSheet,代码行数:7,代码来源:SpreadsheetTest.cs

示例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());
 }
开发者ID:HyveMynd,项目名称:CloudSpreadSheet,代码行数:6,代码来源:SpreadsheetTest.cs

示例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());
 }
开发者ID:HyveMynd,项目名称:CloudSpreadSheet,代码行数:8,代码来源:SpreadsheetTest.cs

示例15: TestConstructorStandard

 public void TestConstructorStandard()
 {
     Formula testFormula = new Formula("4.0 + 2.0");
     Assert.AreEqual("4.0+2.0", testFormula.ToString());
 }
开发者ID:Buck417,项目名称:First-Half-CS-3500,代码行数:5,代码来源:UnitTest1.cs


注:本文中的SpreadsheetUtilities.Formula.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。