-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #244: introduce fresh context for each predefined formula
- Loading branch information
Showing
2 changed files
with
59 additions
and
114 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/WpfMath/Parsers/PredefinedFormulae/PredefinedFormulaContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace WpfMath.Parsers.PredefinedFormulae | ||
{ | ||
/// <summary> | ||
/// This is a context for parsing a predefined formula. <c>PredefinedTexFormulas.xml</c> allows the users to | ||
/// introduce their own named formulae via <example><CreateFormula name="f"></example>, and then call methods | ||
/// on them. | ||
/// <para/> | ||
/// This context is the storage of these named formula values. | ||
/// </summary> | ||
internal class PredefinedFormulaContext | ||
{ | ||
private readonly Dictionary<string, TexFormula> _formulae = new Dictionary<string, TexFormula>(); | ||
public void AddFormula(string name, TexFormula formula) => _formulae.Add(name, formula); | ||
public TexFormula this[string name] => _formulae[name]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters