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


C# SerializableDictionary.OrderBy方法代码示例

本文整理汇总了C#中SerializableDictionary.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# SerializableDictionary.OrderBy方法的具体用法?C# SerializableDictionary.OrderBy怎么用?C# SerializableDictionary.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SerializableDictionary的用法示例。


在下文中一共展示了SerializableDictionary.OrderBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SortServerLoad

        public static SerializableDictionary<string, int> SortServerLoad(SerializableDictionary<string, int> dic)
        {
            SerializableDictionary<string, int> res = new SerializableDictionary<string, int>();

            foreach (var item in dic.OrderBy(i => i.Value))
            {
                res.Add(item.Key, item.Value);
            }

            return res;
        }
开发者ID:nunofmaia,项目名称:padi-fs,代码行数:11,代码来源:Util.cs

示例2: GetTestSuites

        public UITestSuite[] GetTestSuites(string filename, string filename2)
        {
            List<UITestSuite> testSuites = new List<UITestSuite>();
            var dataProvider = new ExcelStorage(typeof(UIDataRaw));
            dataProvider.FileName = filename;
            dataProvider.StartRow = 2;
            dataProvider.StartColumn = 1;

            var sequenceList = new List<UICommandContainer>();
            var list = GetSequencesFromMaster(filename);
            var sequences = GetCommandSequences(filename2, list);
            foreach (var sequence in sequences.Sequences)
            {
                sequenceList.Add(sequence.Value);
            }

            foreach (var sheetName in Utility.GetExcelSheetNames(filename))
            {
                dataProvider.SheetName = sheetName;
                var data = (UIDataRaw[])dataProvider.ExtractRecords();
                var props = data.FirstOrDefault().GetType().GetProperties();
                var orderedSequences = new SerializableDictionary<int, UICommandContainer>();
                UITestSuite testSuite = null;
                for (int i = 0; i < data.Length; i++)
                {
                    TestCase testCase = null;
                    for (int x = 0; x < props.Count(); x++)
                    {
                        object val = data[i].GetType().GetProperty(props[x].Name).GetValue(data[i], null);
                        if (x==0 && val != null )
                        {
                            if (Utility.IsAllUpper(val.ToString()))
                            {
                                // add the last test case before creating new test suite and test case
                                if (testCase != null && !string.IsNullOrEmpty(testCase.GroupName))
                                {
                                    testSuite.Add(testCase.GroupName, testCase);
                                    testCase = new TestCase();
                                }

                                // add the previous test suite before creating a new one
                                if (testSuite != null) testSuites.Add(testSuite);
                                // get the suite name
                                testSuite = new UITestSuite();
                                testSuite.Name = val.ToString();
                                break;
                            }

                            object testcaseEnabled = data[i].GetType().GetProperty(props[x+1].Name).GetValue(data[i], null);
                            if (testcaseEnabled == null || ( testcaseEnabled.ToString().ToLower() != "y" && testcaseEnabled.ToString().ToLower() != "yes"))
                                continue; // this testcase is NOT enabled, so we skip processing

                            // get the testcase name
                            testCase = new TestCase();
                            testCase.GroupName = val.ToString();
                        }
                        if (x>1 && val != null && testCase!=null)
                        {
                            int sequencePosition = -1;
                            var sequencesPositions = val.ToString().Split(',');
                            foreach (var sPosition in sequencesPositions)
                            {
                                if (int.TryParse(sPosition, out sequencePosition))
                                {
                                    // get the ordered sequences for the test case
                                    var seq = sequenceList[x - (dataProvider.StartColumn + 1)];
                                    //testCase.CommandGroups.Sequences.Add(seq.Name,new UICommandContainer(seq.Name, seq.Commands.ToArray()));
                                    orderedSequences.Add(sequencePosition, seq);
                                }
                            }

                        }
                    }
                    // add testcase after constructed.  Skip test suites
                    if (testCase!=null && !string.IsNullOrEmpty(testCase.GroupName)) {

                        foreach (var uiCommandContainer in orderedSequences.OrderBy(x=>x.Key))
                        {
                            testCase.CommandGroups.Sequences.Add(uiCommandContainer.Value.Name+"("+uiCommandContainer.Key.ToString()+")", uiCommandContainer.Value);
                        }
                        orderedSequences = new SerializableDictionary<int, UICommandContainer>();
                        testSuite.Add(testCase.GroupName, testCase);
                        testCase = new TestCase();
                    }
                }
                // add the last test suite
                if (testSuite != null&&testSuite.Count>0) testSuites.Add(testSuite);
            }
            return testSuites.ToArray();
        }
开发者ID:ngocluu263,项目名称:WebAuto,代码行数:90,代码来源:ExcelRepository.cs


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