private static void NormalRun() { Directory.CreateDirectory("Write"); var sum = 0; var elapsed = new TimeSpan(); var T = 10; for (int i = 1; i <= T; i++) { int n = 40, m = 1; var clusterCountVizitor = new ClusterCountVizitor(); var allClusterVizitor = new AllClusterCountVisitor(); using (var spreadSheet = new XslWriter("Write/optim6.xls", T, n, "multi thread mix no4")) { try { var clusterWriter = new ClusterWriter(i, "v2cluster40"); clusterWriter.WriteCluster(n, m); var coordinates = clusterWriter.CreateMappingCoordinates(); var treeFactory = new TreeFactory(coordinates); treeFactory.AttachVisitor(clusterCountVizitor); // treeFactory.AttachVisitor(allClusterVizitor); var tree = treeFactory.create(); var timeElapsed = new TimeStamp().GetTimeStamp(() => tree.Search()); spreadSheet.write("A" + i, int.Parse(clusterCountVizitor.ToString())); spreadSheet.write("B" + i, timeElapsed.TotalSeconds); spreadSheet.write("C" + i, treeFactory.ToString()); spreadSheet.write("D" + i, timeElapsed); //spreadSheet.write("D" + i, allClusterVizitor.ToString()); elapsed = elapsed.Add(timeElapsed); sum += Int32.Parse(clusterCountVizitor.ToString()); } catch (Exception err) { spreadSheet.write("A" + i, err.Message); spreadSheet.write("B" + i, clusterCountVizitor.ToString()); } } using (var stremWriter = new StreamWriter("Write/limit3", true)) { stremWriter.WriteLine(); stremWriter.WriteLine(sum / T); stremWriter.WriteLine(new TimeSpan(elapsed.Ticks / T)); } } }
public void BuildTreeWithDepth1() { TreeFactory factory = new TreeFactory(); var treeSystem = factory.Create(1); treeSystem.Tree.Should().NotBeNull(); treeSystem.Tree.Should().BeOfType(typeof(Gate)); treeSystem.Tree.As <Gate>().LeftNode.Should().BeOfType(typeof(Container)); treeSystem.Tree.As <Gate>().RightNode.Should().BeOfType(typeof(Container)); treeSystem.Containers.Count.Should().Be(2); treeSystem.Containers[0].ContainerNumber.Should().Be(0); treeSystem.Containers[1].ContainerNumber.Should().Be(1); }
/// <summary> /// Visit a parse tree produced by <see cref="CodeQueryParser.ConstantBoolean" />. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)" /> /// on <paramref name="context" />. /// </para> /// </summary> public override Object VisitConstantBoolean(CodeQueryParser.ConstantBooleanContext context) { switch (context.BOOLEAN().GetText()) { case "false": return(TreeFactory.CreateBoolean(false)); case "true": return(TreeFactory.CreateBoolean(true)); default: throw new NotSupportedException("Not supported boolean value!"); } }
void Start() { TreeFactory[] coloredTreeFactories = new TreeFactory[3]; coloredTreeFactories[0] = new GreenTreeFactory(); coloredTreeFactories[1] = new BlueTreeFactory(); coloredTreeFactories[2] = new OrangeTreeFactory(); foreach (TreeFactory colorFactory in coloredTreeFactories) { foreach (Tree t in colorFactory.TreeList) { Instantiate(t.TreePrefab, t.Position, Quaternion.identity); } } }
public static ISettingsNode Convert(IDictionary configuration) { var result = null as ISettingsNode; foreach (DictionaryEntry entry in configuration) { var node = TreeFactory.CreateTreeByMultiLevelKey( null, entry.Key.ToString().Replace(" ", "").Split(Separators, StringSplitOptions.RemoveEmptyEntries), entry.Value.ToString()); result = SettingsNodeMerger.Merge(result, node, null); } return(result); }
public override Object VisitCommandExpression(CodeQueryParser.CommandExpressionContext context) { var expression = context.Expression.Accept(this); if (expression is CommandCallElement) { var methodCall = (CommandCallElement)expression; return(TreeFactory.CreateControlFlow(methodCall)); } else if (expression is SelectorElementBase) { var selector = (SelectorElementBase)expression; return(TreeFactory.CreateControlFlow(selector)); } return(base.VisitCommandExpression(context)); }
public void InitializeFactoryAndTree() { string[] input = new string[] { "7 19", "7 21", "7 14", "19 1", "19 12", "19 31", "14 23", "14 6" }; this._treeFactory = new TreeFactory(); this._tree = this._treeFactory.CreateTreeFromStrings(input); }
// Output D, B, E, A, C public List<string> Traverse() { BinaryNode<int> root = TreeFactory.GetBinaryTreeWithHeight3(); Queue<IBinaryNode<int>> children = new Queue<IBinaryNode<int>>(); children.Enqueue(root); while (children.Count!=0) { var node = children.Dequeue(); // <Process node> Console.WriteLine(node.Data); if (node.LeftNode!=null) children.Enqueue(node.LeftNode); if (node.RightNode != null) children.Enqueue(node.RightNode); } return new List<string>(); }
} = new string[5]; // X,Y,AreaSideLength,TDBPath,DEMPath // as base game doesn't contain a full System.XML.LINQ namespace and the .NET 4.8 is easier to work with, // other external process was created for TDB parsing internal void ProcessTDBExternally() { UnityEngine.Debug.Log(modDirectory); var psi = new ProcessStartInfo(); psi.FileName = $"{modDirectory}GMLParserPL.exe"; psi.CreateNoWindow = true; psi.RedirectStandardOutput = true; psi.RedirectStandardInput = true; psi.RedirectStandardError = true; psi.UseShellExecute = false; psi.Arguments = "\"" + Arguments[0] + "\"" + " " + "\"" + Arguments[1] + "\"" + " " + "\"" + Arguments[2] + "\"" + " " + "\"" + Arguments[3] + "\""; var p = new Process(); p.StartInfo = psi; p.Start(); NetFactory netFactory = new NetFactory(); BuildingFactory buildingFactory = new BuildingFactory(); PropFactory propFactory = new PropFactory(); ResourceFactory resourceFactory = new ResourceFactory(); TreeFactory treeFactory = new TreeFactory(); WaterFactory waterFactory = new WaterFactory(); waterFactory.SetSeaLevelTo0(); while (!p.StandardOutput.EndOfStream) { string line = p.StandardOutput.ReadLine(); SelectFactory(line, netFactory, buildingFactory, propFactory, resourceFactory, treeFactory, waterFactory); } netFactory.UpdateSegments(); UnityEngine.Debug.Log("TDB loaded"); UnityEngine.Debug.Log($"Buildings loaded/called/max: {buildingFactory.Temp}/{timesBuildingUsed}/{BuildingManager.MAX_BUILDING_COUNT}"); UnityEngine.Debug.Log($"Segments loaded/called/max: {netFactory.TempS}/{timesNetUsed}/{NetManager.MAX_SEGMENT_COUNT}"); UnityEngine.Debug.Log($"Net nodes loaded/max: {netFactory.TempN}/{NetManager.MAX_NODE_COUNT}"); UnityEngine.Debug.Log($"Props loaded/called/max: {propFactory.Temp}/{timesPropUsed}/{PropManager.MAX_PROP_COUNT}"); UnityEngine.Debug.Log($"Trees loaded/called/max: {treeFactory.Temp}/{timesTreeUsed}/{TreeManager.MAX_TREE_COUNT}"); UnityEngine.Debug.Log($"Resources loaded/called: {resourceFactory.Temp}/{timesResourceUsed}"); UnityEngine.Debug.Log($"Resources loaded/called: {waterFactory.Temp}/{timesWaterUsed}"); }
private void RegTree() { TreeFactory.Register <PanelSetting_ChildNormal>("panelChild_normal"); TreeFactory.Register <PanelSetting_ChildManual>("panelChild_manual"); TreeFactory.Register <PanelSetting_ChildSelect>("panelChild_select"); TreeFactory.Register <PanelSetting_ChildStack>("panelChild_stack"); TreeFactory.Register <PanelSetting_Scene>("panelScene"); TreeFactory.Register <PanelSetting_AutoClose>("panelAutoClose"); TreeFactory.Register <PanelSetting_Lua>("panelLua"); TreeFactory.Register <PanelSetting_OpenToObject>("panelOpenToObject"); TreeFactory.Register <PanelSetting_Cull>("panelCull"); TreeFactory.Register <PanelSetting_Module>("panelModule"); TreeFactory.Register <PanelSetting_Panel>("panelCell"); TreeFactory.Register <PanelSetting_Root>("panelRoot"); TreeFactory.Register <FireFx_Parallel>("pal"); TreeFactory.Register <FireFx_Phase>("fxphase"); TreeFactory.Register <FireFx_Sequence>("seq"); TreeFactory.Register <BulletEmitter_Line>("emitline"); TreeFactory.Register <BulletEmitter_Normal>("emitnormal"); TreeFactory.Register <FireFxRoot>("firefxroot"); TreeFactory.Register <BulletFx_BoneBoundler>("bonefx"); TreeFactory.Register <BulletFx_Chain>("fxchain"); TreeFactory.Register <BulletFx_Create>("create"); TreeFactory.Register <BulletFx_Fall>("fall"); TreeFactory.Register <BulletFx_Fly>("fly"); TreeFactory.Register <BulletFx_Follow>("fxfollow"); TreeFactory.Register <BulletFx_LookAt>("lookAt"); TreeFactory.Register <BulletFx_Parabola>("parabola"); TreeFactory.Register <BulletFx_Play>("play"); TreeFactory.Register <BulletFx_Seek>("seek"); TreeFactory.Register <BulletFx_Tween>("tween"); TreeFactory.Register <BulletPos_Area>("posarea"); TreeFactory.Register <BulletPos_DividSpace>("posdividspace"); TreeFactory.Register <BulletPos_Line>("posline"); TreeFactory.Register <BulletPos_Ring>("posring"); TreeFactory.Register <BulletPos_Sector>("possector"); TreeFactory.Register <FireFx_Animation>("anim"); TreeFactory.Register <FireFx_ChangeWeapon>("fxchangeweapon"); TreeFactory.Register <FireFx_Hit>("hit"); TreeFactory.Register <FireFx_Move>("move"); TreeFactory.Register <FireFx_Pull>("pull"); TreeFactory.Register <FireFx_TimeScale>("fxtimescale"); }
/* * 10 * / \ * 5 15 * / \ \ * 3 9 21 * */ public static void Main(string[] args) { var tree = new TreeFactory().PlantTree(10); tree.AddLeaf(5); tree.AddLeaf(15); tree.AddLeaf(3); tree.AddLeaf(9); tree.AddLeaf(21); tree.AddLeaf(6); Console.WriteLine(tree.Root.Value); Console.WriteLine(tree.Root.LeftChild.Value); Console.WriteLine(tree.Root.LeftChild.LeftChild.Value); Console.WriteLine(tree.Root.LeftChild.RightChild.Value); Console.WriteLine(tree.Root.RightChild.Value); Console.WriteLine(tree.Root.RightChild.RightChild.Value); Console.WriteLine(tree.Root.LeftChild.RightChild.LeftChild.Value); }
private static void HandLabeledTree() { Console.WriteLine("Hand-Labeled Tree:"); var t = new TreeFactory <State_Content_Pair <string> >(); var tree = t.Branch ( t.Leaf(new State_Content_Pair <string>(0, "a")), t.Branch ( t.Branch ( t.Leaf(new State_Content_Pair <string>(1, "b")), t.Leaf(new State_Content_Pair <string>(2, "c")) ), t.Leaf(new State_Content_Pair <string>(3, "d")) ) ); tree.Show(2); }
public void TreeAllSubtreesWithGivenSumShouldWorkCorrectly3() { string[] input = new string[] { "7 33", "7 2", "7 1", }; this._treeFactory = new TreeFactory(); Tree <int> tree = this._treeFactory.CreateTreeFromStrings(input); List <Tree <int> > subtrees = tree.SubTreesWithGivenSum(43); Assert.AreEqual(1, subtrees.Count); string treeAsString = subtrees[0].GetAsString(); Assert.IsTrue(treeAsString.Contains("7")); Assert.IsTrue(treeAsString.Contains("33")); Assert.IsTrue(treeAsString.Contains("2")); Assert.IsTrue(treeAsString.Contains("1")); }
private static StateM <int, Tree <State_Content_Pair <T> > > MLabel_Rec <T>(Tree <T> tree) { var t = new TreeFactory <T>(); var s = new StateMonadFactory <int, Tree <State_Content_Pair <T> > >(); if (tree is Leaf <T> ) { var leaf = (Leaf <T>)tree; return(UpdateState().Bind(n => s.Unit(t.LabeledLeaf(leaf.Content, n)))); } else if (tree is Branch <T> ) { var branch = (Branch <T>)tree; return(MLabel_Rec(branch.Left).Bind(labeledLeft => MLabel_Rec(branch.Right).Bind(labeledRight => s.Unit(t.LabeledBranch(labeledLeft, labeledRight))))); } else { throw new Exception("MakeMonad/MLabel: impossible tree subtype"); } }
public void TreeDeepestLeftmostNodeShouldWorkCorrectlyWithOtherLevel() { string[] input = new string[] { "7 19", "7 21", "7 14", "19 1", "19 12", "19 31", "14 23", "14 6", "12 77", "31 75", "75 29" }; this._treeFactory = new TreeFactory(); this._tree = this._treeFactory.CreateTreeFromStrings(input); Tree <int> deepestNode = this._tree.GetDeepestLeftomostNode(); Assert.AreEqual(29, deepestNode.Key); }
private static Tree <string> UnlabeledTree() { Console.WriteLine("Unlabeled Tree:"); var t = new TreeFactory <string>(); var tree = new Branch <string> ( t.Leaf("a"), t.Branch ( t.Branch ( t.Leaf("b"), t.Leaf("c") ), t.Leaf("d") ) ); tree.Show(2); return(tree); }
public TreeUI(TreeFactory treeFactory, int tableWith) : base(tableWith) { _treeFactory = treeFactory; }
/// <summary> /// 重新生成PDF /// </summary> /// <param name="FileID">节点ID</param> private void ConvertAllEFileToPDF(string FileID) { BLL.T_FileList_BLL fileBLL = new ERM.BLL.T_FileList_BLL(); MDL.T_FileList fileMDL = fileBLL.Find(FileID, Globals.ProjectNO); BLL.T_CellAndEFile_BLL cellBLL = new ERM.BLL.T_CellAndEFile_BLL(); IList <MDL.T_CellAndEFile> cellList = cellBLL.FindByGdFileID(FileID, Globals.ProjectNO); System.Collections.ArrayList fileArryList = new System.Collections.ArrayList(); bool isUpdateFileSelect_flg = false; foreach (MDL.T_CellAndEFile cellMDL in cellList) { string pdfPath = ""; if (cellMDL.DocYs == null || cellMDL.DocYs == 1 || cellMDL.fileTreePath == String.Empty || cellMDL.fileTreePath == "") { if (!isUpdateFileSelect_flg) { isUpdateFileSelect_flg = true; } using (ConvertCell2PDF c1 = new ConvertCell2PDF()) { try { int iPageCount = c1.PrintCellToPDF(Globals.ProjectPath + cellMDL.filepath, Globals.ProjectPath + "PDF\\" + cellMDL.CellID + ".pdf"); if (iPageCount == 0) { cellMDL.fileTreePath = ""; } else { cellMDL.fileTreePath = "PDF\\" + cellMDL.CellID + ".pdf"; } cellMDL.DocYs = 0; cellMDL.DoStatus = 1; cellMDL.ys = iPageCount; cellBLL.Update(cellMDL); } catch (Exception e) { cellMDL.fileTreePath = ""; MyCommon.WriteLog("PDF转换失败!错误信息:" + e.Message); } pdfPath = cellMDL.fileTreePath; } } else { pdfPath = cellMDL.fileTreePath; } if (!System.IO.File.Exists(Globals.ProjectPath + pdfPath)) { continue; } fileArryList.Add(Globals.ProjectPath + pdfPath); } string[] FileList = new string[fileArryList.Count]; for (int i = 0; i < fileArryList.Count; i++) { FileList[i] = fileArryList[i].ToString(); } using (ConvertCell2PDF c1 = new ConvertCell2PDF()) { int iPageCount = 0; if (FileList.Length > 0) { try { iPageCount = c1.MergePDF(FileList, Globals.ProjectPath + "MPDF\\" + FileID + ".pdf"); if (iPageCount == 0) { fileMDL.filepath = ""; } else { fileMDL.filepath = "MPDF\\" + FileID + ".pdf"; } } catch (Exception ex) { iPageCount = 0; fileMDL.filepath = ""; MyCommon.WriteLog("合并PDF失败!错误信息:" + ex.Message); } } else { fileMDL.filepath = ""; } //1 文字数量 2声像 3照片数量 int EFileType_flg = 1; TreeFactory treeFactory = new TreeFactory(); treeFactory.GetParentNodeType(FileID, ref EFileType_flg); if (EFileType_flg == 1) { fileMDL.sl = iPageCount; } else if (EFileType_flg == 3) { int tzz = MyCommon.ToInt(fileMDL.tzz); int dtz = MyCommon.ToInt(fileMDL.dtz); int zpz = MyCommon.ToInt(fileMDL.zpz); int dpz = MyCommon.ToInt(fileMDL.dpz); fileMDL.dw = (iPageCount + dtz).ToString(); fileMDL.tzz = (iPageCount).ToString(); fileMDL.dtz = dtz.ToString(); fileMDL.wzz = (zpz + dpz).ToString(); fileMDL.zpz = zpz.ToString(); fileMDL.dpz = dpz.ToString(); } else if (EFileType_flg == 2) { int tzz = MyCommon.ToInt(fileMDL.tzz); int dtz = MyCommon.ToInt(fileMDL.dtz); int zpz = MyCommon.ToInt(fileMDL.zpz); int dpz = MyCommon.ToInt(fileMDL.dpz); fileMDL.dw = (tzz + dtz).ToString(); fileMDL.tzz = tzz.ToString(); fileMDL.dtz = dtz.ToString(); fileMDL.wzz = (iPageCount + dpz).ToString(); fileMDL.zpz = (iPageCount).ToString(); fileMDL.dpz = dpz.ToString(); } fileMDL.selected = 0; fileBLL.Update(fileMDL); } }
public Tree(double x, double y, string name, Color color, string data) { X = x; Y = y; Type = TreeFactory.GetTreeType(name, color, data); }
public override Tree normalizeWholeTree(Tree tree, TreeFactory tf) { return(base.normalizeWholeTree(tree, tf)); }
// Output A C B E D public List <string> Go() { TraversePostorder(TreeFactory.GetBinaryTreeWithHeight3()); return(new List <string>()); }
void Awake() { Tree = new TreeFactory(); Tree.treeSetup(); Question.text = Guess(); }
private void tsNewScan_Click(object sender, EventArgs e) { if (!imageScan.ScannerAvailable()) { MessageBox.Show("没有扫描仪,无法扫描!"); return; } if (MessageBox.Show("你确定要替换扫描吗?", "替换扫描", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { if (curSelNoFrmThum == 0) { return; } int selNo = curSelNoFrmThum; if (selNo == 0) { return; } string pathSrc = arrPic[selNo - 1].ToString(); string nameDaf = pathSrc; nameDaf = nameDaf.Substring(nameDaf.LastIndexOf("\\") + 1); nameDaf = nameDaf.Substring(0, nameDaf.LastIndexOf(".") + 1) + "daf"; string pathDaf = Globals.SPDFPath + "\\" + nameDaf; System.IO.File.Delete(pathSrc); System.IO.File.Delete(pathDaf); if (NewNode.ImageIndex == 2) { frmFileAdd fileAdd = new frmFileAdd(_parentForm); fileAdd.Regist(NewNode); } imageScan.OpenScanner(); string newName = Guid.NewGuid().ToString(); axImgEdit1.ImagePalette = ImgeditLibCtl.ImagePaletteConstants.wiPaletteRGB24; imageScan.ScanTo = ScanLibCtl.ScanToConstants.FileOnly; imageScan.MultiPage = true; imageScan.FileType = ScanLibCtl.FileTypeConstants.TIFF; imageScan.Image = Globals.ODOCPath + "\\" + newName + ".tif"; if (tscmbDisp.SelectedItem.ToString() == "不显示扫描设置") { imageScan.ShowSetupBeforeScan = false; } else { imageScan.ShowSetupBeforeScan = true; } int iScan = imageScan.StartScan(); if (iScan > 0) { return; } string strScanFileName = string.Empty; System.IO.DirectoryInfo dcInfo = new System.IO.DirectoryInfo(imageScan.Image); strScanFileName = dcInfo.Name; imageScan.CloseScanner(); if (strScanFileName != "") { PrintToPDF(Globals.ODOCPath + "\\" + newName + ".tif", null, newName); axImgAdmin1.DeletePages(selNo, 1); axImgAdmin1.Insert(Globals.ODOCPath + "\\" + newName + ".tif", 1, selNo, 1); axImgAdmin1.Refresh(); axImgEdit1.ImagePalette = ImgeditLibCtl.ImagePaletteConstants.wiPaletteRGB24; arrPic[selNo - 1] = Globals.ODOCPath + "\\" + newName + ".tif"; this.axImgEdit1.Image = arrPic[selNo - 1].ToString(); this.axImgEdit1.Display(); axImgThumbnail1.Image = reportsPath + "temp.tif"; axImgThumbnail1.Refresh(); for (int i = 1; i < selNo; i++) { axImgThumbnail1.ScrollThumbs(0, 0); } hasEdit = false; string strSql = "update attachment set yswjpath='" + newName + ".tif',ext='tif',filepath='" + newName + ".daf'"; strSql += " where ProjectNO='" + Globals.ProjectNO + "' and yswjpath='" + pathSrc.Substring(pathSrc.LastIndexOf("\\") + 1) + "'"; Digi.DBUtility.DbHelperOleDb.ExecuteSql(strSql); RegistEnum treeEnum = RegistEnum.FULL; TreeFactory treeFactory = new TreeFactory(); treeFactory.RefreshFileNode(NewNode, true, Globals.ProjectNO, true, false, treeEnum, true); MessageBox.Show("替换扫描成功!"); } } ////取待删除的文件名 ////扫描 }
/// <summary> /// Visit a parse tree produced by <see cref="CodeQueryParser.ConstantString" />. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)" /> /// on <paramref name="context" />. /// </para> /// </summary> public override Object VisitConstantString(CodeQueryParser.ConstantStringContext context) { var value = context.STRING().GetText().Trim('"'); return(TreeFactory.CreateString(value)); }
private void SelectFactory(string line, NetFactory netFactory, BuildingFactory buildingFactory, PropFactory propFactory, ResourceFactory resourceFactory, TreeFactory treeFactory, WaterFactory waterFactory) { if (!line.IsNullOrWhiteSpace()) { List <string> arguments = line.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); float[] points; float angle; switch (arguments[0]) { case "Resource": points = ReturnFloatsFromArg(arguments); NaturalResourceManager.Resource resource = (NaturalResourceManager.Resource)Enum .Parse(typeof(NaturalResourceManager.Resource), arguments[1], true); resourceFactory.CreateResource(new Vector2(points[0], points[1]), resource); timesResourceUsed++; break; case "Water": points = ReturnFloatsFromArg(arguments); var flowInOut = arguments[3].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => uint.Parse(x, CultureInfo.InvariantCulture)) .ToArray(); waterFactory.NewWaterSource(new Vector2(points[0], points[1]), flowInOut[0], flowInOut[1], flowInOut[2]); timesWaterUsed++; break; case "Net": points = ReturnFloatsFromArg(arguments); netFactory.Create(new Vector2(points[0], points[1]), new Vector2(points[2], points[3]), arguments[1]); timesNetUsed++; break; case "Building": points = ReturnFloatsFromArg(arguments); angle = float.Parse(arguments[3], CultureInfo.InvariantCulture); buildingFactory.Create(new Vector2(points[0], points[1]), angle, arguments[1]); timesBuildingUsed++; break; case "Tree": points = ReturnFloatsFromArg(arguments); treeFactory.Create(new Vector2(points[0], points[1]), arguments[1]); timesTreeUsed++; break; case "Prop": points = ReturnFloatsFromArg(arguments); angle = float.Parse(arguments[3], CultureInfo.InvariantCulture); propFactory.Create(new Vector2(points[0], points[1]), angle, arguments[1]); timesPropUsed++; break; case "Error": UnityEngine.Debug.Log(arguments[1]); break; default: UnityEngine.Debug.Log(arguments[0]); break; } } }
private static ISettingsNode ParseSettings(string[] args, string defaultKey, string defaultValue) { var resultBuilder = new ObjectNodeBuilder(); var valueNodeIndex = new Dictionary <string, List <ValueNode> >(StringComparer.OrdinalIgnoreCase); var objectNodeIndex = new Dictionary <string, ISettingsNode>(StringComparer.OrdinalIgnoreCase); foreach (var pair in CommandLineArgumentsParser.Parse(args ?? Array.Empty <string>())) { var key = pair.key ?? defaultKey; if (key == null) { continue; } var value = pair.value ?? defaultValue; if (value == null) { continue; } var node = TreeFactory.CreateTreeByMultiLevelKey(null, key.Split('.'), value).Children.Single(); var name = node.Name ?? string.Empty; if (node is ObjectNode objectNode) { var currentNode = objectNodeIndex.TryGetValue(name, out var current) ? current : null; objectNodeIndex[name] = SettingsNodeMerger.Merge(currentNode, objectNode, null); } else if (node is ValueNode valueNode) { if (!valueNodeIndex.TryGetValue(name, out var nodes)) { valueNodeIndex[name] = nodes = new List <ValueNode>(); } nodes.Add(valueNode); } } foreach (var pair in valueNodeIndex) { if (pair.Value.Count == 1) { resultBuilder.SetChild(pair.Value.Single()); } else { resultBuilder.SetChild(new ArrayNode(pair.Key, pair.Value.Select((node, index) => new ValueNode(index.ToString(), node.Value)).ToArray())); } } foreach (var pair in objectNodeIndex) { resultBuilder.SetChild(pair.Value); } var result = resultBuilder.Build(); if (result.ChildrenCount > 0) { return(result); } return(null); }
static void Main(string[] args) { //test Console.WriteLine("Start Program"); iTreeFactory treeFactory = new TreeFactory(); iWoodFactory woodFactory = new WoodFactory(treeFactory); iMonkeyFactory monkeyFactory = new MonkeyFactory(); iDatabaseFiller dbWriter = new BulkDatabaseUploader(); ReportWriter reportWriter = new ReportWriter(); BitmapDrawer mapDrawer = new BitmapDrawer(); List <iMonkey> monkeys1 = monkeyFactory.GetMonkeys(4, MonkeyTypes.Standard); List <iMonkey> monkeys2 = monkeyFactory.GetMonkeys(8, MonkeyTypes.Standard); var wood1 = woodFactory.CreateWood(100, 100, 500, monkeys1); var wood2 = woodFactory.CreateWood(200, 200, 1500, monkeys2); Thread letLooseW1 = new Thread(wood1.LetTheMonkeysLoose); letLooseW1.Start(); Thread letLooseW2 = new Thread(wood2.LetTheMonkeysLoose); letLooseW2.Start(); //upload the layout of the woods(no monkey movement needed) Thread treeUploader1 = new Thread(() => dbWriter.UploadWoodRecords(wood1)); treeUploader1.Start(); Thread treeUploader2 = new Thread(() => dbWriter.UploadWoodRecords(wood2)); treeUploader2.Start(); //report on the first one letLooseW1.Join(); Thread draw1 = new Thread(() => mapDrawer.DrawMap(wood1)); draw1.Start(); Thread logUploader1 = new Thread(() => dbWriter.UploadLogs(wood1)); logUploader1.Start(); Thread monkeyUploader1 = new Thread(() => dbWriter.UploadMonkeyRecords(wood1)); monkeyUploader1.Start(); Thread reporter1 = new Thread(() => reportWriter.WriteReport(wood1)); reporter1.Start(); //report on the second one letLooseW2.Join(); Thread draw2 = new Thread(() => mapDrawer.DrawMap(wood2)); draw2.Start(); Thread logUploader2 = new Thread(() => dbWriter.UploadLogs(wood2)); logUploader2.Start(); Thread monkeyUploader2 = new Thread(() => dbWriter.UploadMonkeyRecords(wood2)); monkeyUploader2.Start(); Thread reporter2 = new Thread(() => reportWriter.WriteReport(wood2)); reporter2.Start(); }
public ThreadsPoolFrame(TreeFactory treeFactory) { this.treeFactory = treeFactory; eventsList = new HashSet <AutoResetEvent>(); }
public CreateTreeInfo(string kind, Group group, TreeFactory <TreeType> treeFactory) { this.kind = kind; this.group = group; this.treeFactory = treeFactory; }
public TreeBuilder Add(ClusterConfigPath path, string[] values) => Add(TreeFactory.CreateTreeByMultiLevelKey(null, path.Segments.ToArray(), values));