private void AddSubNodes(IStrategyAssembly assembly, string path, TreeNode treeNode) { IList <string> subPaths = assembly.GetSubPath(path); for (int i = 0; i < subPaths.Count; i++) { string subPath = subPaths[i]; string pathName = subPath.Substring(subPath.LastIndexOf("\\") + 1); TreeNode subNode = treeNode.Nodes.Add(pathName); subNode.Tag = subPath; AddSubNodes(assembly, subPaths[i], subNode); } IList <IStrategyInfo> strategies = assembly.GetSubStrategyInfo(path); for (int i = 0; i < strategies.Count; i++) { IStrategyInfo strategyInfo = strategies[i]; TreeNode subNode = treeNode.Nodes.Add(strategyInfo.Name); subNode.Tag = strategyInfo; if (strategyInfo.IsError) { subNode.Text += ":" + strategyInfo.ErrorInfo; subNode.ForeColor = Color.Red; } else { subNode.ForeColor = Color.Yellow; } } }
public void TestStrategyAssembly() { IStrategyAssemblyMgr strategyMgr = GetStrategyMgr(); IStrategyAssembly assembly1 = strategyMgr.GetStrategyAssembly(assemblyName1); string path1 = "com.wer.sc.plugin.mock.strategy"; string path2 = "com.wer.sc.plugin.mock.zb"; string path3 = "com.wer.sc.plugin.mock.strategy.complex"; IList <String> rootPaths = assembly1.GetRootPath(); Assert.AreEqual(1, rootPaths.Count); Assert.AreEqual("com.wer.sc.plugin.mock", rootPaths[0]); IList <String> firstSubPaths = assembly1.GetSubPath(rootPaths[0]); Assert.AreEqual(2, firstSubPaths.Count); //TODO Assert.AreEqual(path1, firstSubPaths[1]); Assert.AreEqual(path2, firstSubPaths[0]); IList <StrategyInfo> strategyInfos = assembly1.GetSubStrategies(path1); Assert.AreEqual(2, strategyInfos.Count); AssertMockStrategy_TurningPoint(strategyInfos[0]); AssertMockStrategy_Volume(strategyInfos[1]); strategyInfos = assembly1.GetSubStrategies(path2); Assert.AreEqual(1, strategyInfos.Count); AssertMockStrategy_Ma(strategyInfos[0]); IList <string> subPath2 = assembly1.GetSubPath(path1); Assert.AreEqual(1, subPath2.Count); Assert.AreEqual(path3, subPath2[0]); Assert.AreEqual(null, assembly1.GetSubPath(path2)); strategyInfos = assembly1.GetSubStrategies(path3); AssertMockStrategy_Complex(strategyInfos[0]); IStrategyAssembly assembly2 = strategyMgr.GetStrategyAssembly(assemblyName2); Assert.AreEqual(3, assembly2.GetAllStrategies().Count); }