• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SpreadsheetUtilities.DependencyGraph类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SpreadsheetUtilities.DependencyGraph的典型用法代码示例。如果您正苦于以下问题:C# DependencyGraph类的具体用法?C# DependencyGraph怎么用?C# DependencyGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DependencyGraph类属于SpreadsheetUtilities命名空间,在下文中一共展示了DependencyGraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
 }
开发者ID:HeroOfCanton,项目名称:CS3500,代码行数:13,代码来源:spreadsheet.cs


示例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
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:13,代码来源:Spreadsheet.cs


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


示例4: AddTest2Test

 public void AddTest2Test()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("A3", "A2");
     t.AddDependency("A1", "A2");
     Assert.AreEqual(2, t.Size);
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:7,代码来源:SpreadsheetUtilitiesTest.cs


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


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


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


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


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


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


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


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


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


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


示例15: EmptyTest8

 public void EmptyTest8()
 {
     DependencyGraph t = new DependencyGraph();
     t.AddDependency("a", "b");
 }
开发者ID:jimibue,项目名称:cs3505,代码行数:5,代码来源:DevelopmentTests.cs


示例16: EmptyTest7

 public void EmptyTest7()
 {
     DependencyGraph t = new DependencyGraph();
     t.RemoveDependency("a", "b");
     Assert.AreEqual(0, t.Size);
 }
开发者ID:jimibue,项目名称:cs3505,代码行数:6,代码来源:DevelopmentTests.cs


示例17: EmptyTest6

 public void EmptyTest6()
 {
     DependencyGraph t = new DependencyGraph();
     Assert.AreEqual(0, t["a"]);
 }
开发者ID:jimibue,项目名称:cs3505,代码行数:5,代码来源:DevelopmentTests.cs


示例18: EmptyTest5

 public void EmptyTest5()
 {
     DependencyGraph t = new DependencyGraph();
     Assert.IsFalse(t.GetDependents("a").GetEnumerator().MoveNext());
 }
开发者ID:jimibue,项目名称:cs3505,代码行数:5,代码来源:DevelopmentTests.cs


示例19: EmptyTest3

 public void EmptyTest3()
 {
     DependencyGraph t = new DependencyGraph();
     Assert.IsFalse(t.HasDependents("a"));
 }
开发者ID:jimibue,项目名称:cs3505,代码行数:5,代码来源:DevelopmentTests.cs


示例20: StressTest15

        public void StressTest15()
        {
            // Dependency graph
            DependencyGraph t = new DependencyGraph();

            // A bunch of strings to use
            const int SIZE = 100;
            string[] letters = new string[SIZE];
            for (int i = 0; i < SIZE; i++)
            {
                letters[i] = ("" + (char)('a' + i));
            }

            // The correct answers
            HashSet<string>[] dents = new HashSet<string>[SIZE];
            HashSet<string>[] dees = new HashSet<string>[SIZE];
            for (int i = 0; i < SIZE; i++)
            {
                dents[i] = new HashSet<string>();
                dees[i] = new HashSet<string>();
            }

            // Add a bunch of dependencies
            for (int i = 0; i < SIZE; i++)
            {
                for (int j = i + 1; j < SIZE; j++)
                {
                    t.AddDependency(letters[i], letters[j]);
                    dents[i].Add(letters[j]);
                    dees[j].Add(letters[i]);
                }
            }

            // Remove a bunch of dependencies
            for (int i = 0; i < SIZE; i++)
            {
                for (int j = i + 2; j < SIZE; j += 2)
                {
                    t.RemoveDependency(letters[i], letters[j]);
                    dents[i].Remove(letters[j]);
                    dees[j].Remove(letters[i]);
                }
            }

            // Replace a bunch of dependees
            for (int i = 0; i < SIZE; i += 4)
            {
                HashSet<string> newDees = new HashSet<String>();
                for (int j = 0; j < SIZE; j += 7)
                {
                    newDees.Add(letters[j]);
                }
                t.ReplaceDependees(letters[i], newDees);

                foreach (string s in dees[i])
                {
                    dents[s[0] - 'a'].Remove(letters[i]);
                }

                foreach (string s in newDees)
                {
                    dents[s[0] - 'a'].Add(letters[i]);
                }

                dees[i] = newDees;
            }

            // Make sure everything is right
            for (int i = 0; i < SIZE; i++)
            {
                Assert.IsTrue(dents[i].SetEquals(new HashSet<string>(t.GetDependents(letters[i]))));
                Assert.IsTrue(dees[i].SetEquals(new HashSet<string>(t.GetDependees(letters[i]))));
            }
        }
开发者ID:jimibue,项目名称:cs3505,代码行数:74,代码来源:DevelopmentTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SpreadsheetUtilities.Formula类代码示例发布时间:2022-05-26
下一篇:
C# Models.LoginViewModel类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap