本文整理汇总了C#中SpreadsheetUtilities.DependencyGraph类的典型用法代码示例。如果您正苦于以下问题:C# DependencyGraph类的具体用法?C# DependencyGraph怎么用?C# DependencyGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DependencyGraph类属于SpreadsheetUtilities命名空间,在下文中一共展示了DependencyGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Spreadsheet
/// <summary>
///
/// </summary>
/// <param name="isValid"></param>
/// <param name="normalize"></param>
/// <param name="version"></param>
public Spreadsheet (Func<string, bool> isValid, Func<string, string> normalize, string version)
: base(isValid, normalize, version)
{
allCells = new Dictionary<string, Cell>();
graph = new DependencyGraph();
isChanged = false;
}
示例2: Spreadsheet
/// <summary>
/// Constructor which takes in delegate values from the user
/// </summary>
/// <param name="isValid">Validity delegate</param>
/// <param name="normalize">Normalization delegate</param>
/// <param name="version">Version of spreadsheet</param>
public Spreadsheet(Func<string, bool> isValid, Func<string, string> normalize, string version)
: base(isValid, normalize, version)
{
dependency_graph = new DependencyGraph();
cell = new Dictionary<String, Cell>();
Changed = false; //Test
}
示例3: Spreadsheet
/// <summary>
/// Contructs a new spreadsheet, (4 arguments from user)
/// </summary>
public Spreadsheet(string path, Func<string, bool> isValid, Func<string, string> normalize, string version)
: base(isValid, normalize, version)
{
cells = new Dictionary<string, Cell>();
dependencyGraph = new DependencyGraph();
GetSavedVersion(path);
}
示例4: AddTest2Test
public void AddTest2Test()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("A3", "A2");
t.AddDependency("A1", "A2");
Assert.AreEqual(2, t.Size);
}
示例5: Spreadsheet
/// <summary>
/// Reads a saved spreadsheet from file and uses it to construct a new spreadsheet.
/// The spreadsheet uses the provided validity delegate, normalization delegate and verson.
/// </summary>
/// <param name="file"></param>
/// <param name="isValid"></param>
/// <param name="normalize"></param>
/// <param name="version"></param>
public Spreadsheet(string file, Func<string, bool> isValid, Func<string, string> normalize, string version)
: base(isValid, normalize, version)
{
spreadsheet = new Dictionary<string, Cell>();
dependencyGraph = new DependencyGraph();
ReadFile(file);
}
示例6: EmptyTest11
public void EmptyTest11()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("x", "y");
Assert.AreEqual(t.Size, 1);
t.RemoveDependency("x", "y");
t.RemoveDependency("x", "y");
}
示例7: EmptyTest10
public void EmptyTest10()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("x", "y");
Assert.AreEqual(1, t["y"]);
t.RemoveDependency("x", "y");
Assert.AreEqual(0, t["y"]);
}
示例8: Spreadsheet
public Spreadsheet()
: base(s=>true, s => s, "default")
{
this.IsValid = IsValid;
this.Normalize = Normalize;
dg = new DependencyGraph();
cells = new HashSet<Cell>();
change = false;
}
示例9: EmptyTest12
public void EmptyTest12()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("x", "y");
Assert.AreEqual(t.Size, 1);
t.RemoveDependency("x", "y");
t.ReplaceDependents("x", new HashSet<string>());
t.ReplaceDependees("y", new HashSet<string>());
}
示例10: AddTest1Test
public void AddTest1Test()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("A1", "A2");
t.AddDependency("A1", "A3");
t.RemoveDependency("A1", "A2");
Assert.AreEqual(1, t.Size);
t.AddDependency("A1", "A4");
Assert.AreEqual(2, t.Size);
HashSet<string> test = new HashSet<string>();
test.Add("A3");
test.Add("A4");
Assert.AreEqual(true, test.SetEquals(t.GetDependents("A1")));
}
示例11: PrivateDataTest
public void PrivateDataTest()
{
try
{
DependencyGraph dg = new DependencyGraph();
dg.AddDependency("a", "b");
dg.AddDependency("a", "c");
ICollection<string> temp = (ICollection<string>)dg.GetDependents("a");
temp.Add("d");
Assert.IsTrue(new HashSet<string> { "b", "c", "d" }.SetEquals(temp));
Assert.IsTrue(new HashSet<string> { "b", "c" }.SetEquals(dg.GetDependents("a")));
}
catch (Exception e)
{
if (!(e is NotSupportedException || e is InvalidCastException))
Assert.Fail();
}
}
示例12: Spreadsheet
/// <summary>
/// Opens a saved spreadsheet and puts it back together
/// </summary>
/// <param name="myPath"></param>
/// <param name="myValid"></param>
/// <param name="myNormalize"></param>
/// <param name="myVersion"></param>
public Spreadsheet(string myPath, Func<string, bool> myValid, Func<string, string> myNormalize, string myVersion)
: base(myValid, myNormalize, myVersion)
{
mySpreadsheet = new Dictionary<string, Cell>();
dependentCells = new DependencyGraph();
//GetSavedVersion(myPath);
using (XmlReader myReader = XmlReader.Create(myPath))
{
string myContent = null;
while (myReader.Read())
{
if (myReader.IsStartElement())
{
switch (myReader.Name)
{
case "Version Information":
break;
case "cell":
break;
case "name":
myReader.Read();
myContent = myReader.Value;
break;
case "contents":
myReader.Read();
HashSet<string> mySet = new HashSet<string>();
//Foreach look sets the cell contents and evaluates the value of any direct or indirect dependents
foreach (string s in SetContentsOfCell(myContent, myReader.Value))
{
mySpreadsheet[s].myValue = myEvaluate(s);
}
break;
}
}
}
}
Changed = false;
}
示例13: Spreadsheet
/// <summary>
/// Constructs an abstract spreadsheet by recording its variable validity test,
/// its normalization method, and its version information. The variable validity
/// test is used throughout to determine whether a string that consists of one or
/// more letters followed by one or more digits is a valid cell name. The variable
/// equality test should be used thoughout to determine whether two variables are
/// equal.
/// </summary>
public Spreadsheet(string filePath, Func<string, bool> isValid, Func<string, string> normalize, string version)
: base(isValid, normalize, version)
{
//read save file from filePath
spreadsheet = new Dictionary<string, Cell> { };
dependency_graph = new DependencyGraph();
has_changed = false;
try
{
using (XmlReader read_file = XmlReader.Create(filePath))
{
if (GetSavedVersion(filePath) != version)
{
throw new SpreadsheetReadWriteException("File versions are not the same.");
}
try
{
string cell_name = "";
while (read_file.Read())
{
if (read_file.IsStartElement())
{
switch (read_file.Name)
{
case "spreadsheet":
break;
case "cell":
break;
case "name":
read_file.Read();
cell_name = read_file.Value;
break;
case "contents":
read_file.Read();
try
{
SetContentsOfCell(cell_name, read_file.Value);
}
catch (Exception ex)
{
throw new SpreadsheetReadWriteException(ex.Message);
}
break;
}
}
}
}
catch
{
throw new SpreadsheetReadWriteException("Error while reading from file");
}
}
}
catch (Exception ex)
{
throw new SpreadsheetReadWriteException(ex.Message);
}
has_changed = false;
}
示例14: Spreadsheet
/// <summary>
/// The three argument constructor; this allows the user to provide a validity delegate, a normalization delegate,
/// and a version (third parameter).
/// </summary>
/// <param name="isValid"></param>
/// <param name="normalize"></param>
/// <param name="version"></param>
public Spreadsheet(Func<string, bool> isValid, Func<string, string> normalize, string version)
: base(isValid, normalize, version)
{
//Setup data structures that keep track of which cells depend on which, and the association between cells and cell names.
dependencies = new DependencyGraph();
cells = new SortedDictionary<string, Cell>();
Changed = false;
}
示例15: EmptyTest8
public void EmptyTest8()
{
DependencyGraph t = new DependencyGraph();
t.AddDependency("a", "b");
}