public Project ProjectOf(GenericNode node) { GenericNode p = node; while (p != null && !(p is ProjectNode)) p = p.Parent as GenericNode; if (p is ProjectNode) return (p as ProjectNode).ProjectRef; return null; }
public void RefreshNode(GenericNode node) { // refresh the first parent that *can* be refreshed while (node != null && !node.IsRefreshable) { node = node.Parent as GenericNode; } if (node == null) return; // if you refresh a SwfFileNode this way (by asking for it), you get // special feedback SwfFileNode swfNode = node as SwfFileNode; if (swfNode != null) swfNode.RefreshWithFeedback(true); else node.Refresh(true); }
public IDiagramNodeItem GetDataObject(GenericNode node) { if (IsAlias) return node; if (PropertyInfo != null) { var result = PropertyInfo.GetValue(node, null) as GenericSlot; if (result == null) { var slot = Activator.CreateInstance((Type)PropertyInfo.PropertyType) as GenericSlot; slot.Node = node; slot.Name = AttributeInfo.Name; PropertyInfo.SetValue(node, slot, null); return slot; } return result; } return node.GetConnectionReference(ReferenceType); }
public void Add(T content) { //Make a new node to add to the linked list GenericNode<T> node = new GenericNode<T>(); //Set the data to the passed in content node.Data = content; //This will add the first element to our list if (Head == null) { Head = node; } //Not the first node, so set the new node to the current node's next variable else { last.Next = node; } //Move down the list. Set current to the new node we added. last = node; }
public void RemoveFirst() { head = head.next; }
public ProjectSelectionState(ProjectTreeView tree) { if (tree == null || tree.SelectedNodes.Count == 0) { return; } foreach (TreeNode node in tree.SelectedNodes) { if (node is FileNode) { Files++; } else if (node is DirectoryNode) { Dirs++; } else { return; // unknown node in selection - no action } GenericNode gnode = (GenericNode)node; if (gnode.Meta == null || !gnode.Meta.ContainsKey(OverlayManager.META_STATUS) || !gnode.Meta.ContainsKey(OverlayManager.META_VC)) { return; // incomplete status } if (Manager == null) { Manager = gnode.Meta[OverlayManager.META_VC] as IVCManager; } else if (gnode.Meta[OverlayManager.META_VC] != Manager) { return; // several managers... } VCItemStatus status = (VCItemStatus)(gnode.Meta[OverlayManager.META_STATUS]); if (status == VCItemStatus.Unknown) { Unknown++; } else if (status == VCItemStatus.Ignored) { Ignored++; } else if (status == VCItemStatus.Added) { Added++; } else if (status == VCItemStatus.Conflicted) { Conflict++; } else if (status == VCItemStatus.Modified) { Modified++; Revert++; Diff++; } else if (status == VCItemStatus.Deleted) { Revert++; Diff++; } else if (status == VCItemStatus.Replaced) { Replaced++; Revert++; } else { Other++; } Total++; } }
internal void SetPrevNode(GenericNode <T> value) { this._PrevNode = value; }
public INode GenerateTree(IParseTree tree, Declaration declaration) { INode node = default; switch (tree) { case VBAParser.ForNextStmtContext _: case VBAParser.ForEachStmtContext _: case VBAParser.WhileWendStmtContext _: case VBAParser.DoLoopStmtContext _: node = new LoopNode(tree); break; case VBAParser.IfStmtContext _: case VBAParser.ElseBlockContext _: case VBAParser.ElseIfBlockContext _: case VBAParser.SingleLineIfStmtContext _: case VBAParser.SingleLineElseClauseContext _: case VBAParser.CaseClauseContext _: case VBAParser.CaseElseClauseContext _: node = new BranchNode(tree); break; case VBAParser.BlockContext _: node = new BlockNode(tree); break; case VBAParser.LetStmtContext _: case VBAParser.SetStmtContext _: node = new AssignmentExpressionNode(tree); break; } if (declaration.Context == tree) { node = new DeclarationNode(tree) { Declaration = declaration }; } var reference = declaration.References.SingleOrDefault(w => w.Context == tree); if (reference != null) { if (reference.IsAssignment) { node = new AssignmentNode(tree) { Reference = reference }; } else { node = new ReferenceNode(tree) { Reference = reference }; } } if (node == null) { node = new GenericNode(tree); } var children = new List <INode>(); for (var i = 0; i < tree.ChildCount; i++) { var nextChild = GenerateTree(tree.GetChild(i), declaration); nextChild.SortOrder = i; nextChild.Parent = node; if (nextChild.Children.Any() || nextChild.GetType() != typeof(GenericNode)) { children.Add(nextChild); } } node.Children = children.ToImmutableList(); return(node); }
// Méthodes abstrates, donc à surcharger obligatoirement avec override dans une classe fille public override bool IsEqual(GenericNode N2) { Node2 N2bis = (Node2)N2; return(numero == N2bis.numero); }
public void SortByType() { //Bucket Sort /* A arry to be sorted n is length of A for i = 1 to n insert A[i] into B bucket (queue) for i = 0 to n-1 sort B */ //Generic Stack for each droid type Stack<Droid> protocolStack = new Stack<Droid>(); Stack<Droid> utilityStack = new Stack<Droid>(); Stack<Droid> janitorStack = new Stack<Droid>(); Stack<Droid> astromechStack = new Stack<Droid>(); //Create a Queue for Droids Queue<Droid> droidQueue = new Queue<Droid>(); //Create a linked list for the droids LinkedList<Droid> droidLinkedList = new LinkedList<Droid>(); int n = droidCollection.Length; //Move droid type into the bucket foreach (int i in droidCollection) { //check if value is not null if(droidCollection[i] != null) { //Add a droid to the linked list droidLinkedList.AddLast(droidCollection); } //Add a new node for the data in the linked list GenericNode<Droid> node = new GenericNode<Droid>(); node.Next; droidQueue.enqueue(droidLinkedList); } //Push the droids into the queue(enqueue) and sort by pushing into their respected stacks foreach (int i in droidQueue) { switch (droidQueue.Equals) { case "Protocol": //take out of queue //Add to the respected stack protocolStack.push(droidQueue.dequeue()); break; case "Utility": utilityStack.push(droidQueue.dequeue()); break; case "Janitor": droidQueue.dequeue(); janitorStack.push(droidQueue.dequeue()); break; case "Astromech": droidQueue.dequeue(); astromechStack.push(droidQueue.dequeue()); break; } } }
public static bool IsAPropertyOrField(ref GenericNode node) { return(node.Kind == Kind.Property || node.Kind == Kind.Field); }
/* * public THashSet<int> testSet(THashSet<int> thing) * { * Console.WriteLine("testSet:" + thing.ToString()); * * return thing; * } */ public void testStruct() { GenericTree input1 = new GenericTree(); input1.setName("thing"); input1.setParamType(TypeEnum.SYNTHETIC_TYPE); input1.setThrfitType("STRUCT"); input1.setType("Xtruct"); GenericTree prop1 = new GenericTree(); prop1.setName("String_thing"); prop1.setParamType(TypeEnum.PRIMITIVE_TYPE); prop1.setThrfitType("STRING"); GenericTree prop2 = new GenericTree(); prop2.setName("Byte_thing"); prop2.setParamType(TypeEnum.PRIMITIVE_TYPE); prop2.setThrfitType("SBYTE"); GenericTree prop3 = new GenericTree(); prop3.setName("I32_thing"); prop3.setParamType(TypeEnum.PRIMITIVE_TYPE); prop3.setThrfitType("I32"); GenericTree prop4 = new GenericTree(); prop4.setName("I64_thing"); prop4.setParamType(TypeEnum.PRIMITIVE_TYPE); prop4.setThrfitType("I64"); Dictionary <string, GenericTree> children = new Dictionary <string, GenericTree>(); children.Add("String_thing", prop1); children.Add("Byte_thing", prop2); children.Add("I32_thing", prop3); children.Add("I64_thing", prop4); input1.setChildren(children); List <GenericTree> inputGenericTrees = new List <GenericTree> { input1 }; GenericTree input2 = new GenericTree(); input2.setName("thing"); input2.setParamType(TypeEnum.SYNTHETIC_TYPE); input2.setThrfitType("STRUCT"); input2.setType("Xtruct"); GenericTree prop11 = new GenericTree(); prop11.setName("String_thing"); prop11.setParamType(TypeEnum.PRIMITIVE_TYPE); prop11.setThrfitType("STRING"); prop11.setParent(input2); GenericTree prop12 = new GenericTree(); prop12.setName("Byte_thing"); prop12.setParamType(TypeEnum.PRIMITIVE_TYPE); prop12.setThrfitType("SBYTE"); GenericTree prop13 = new GenericTree(); prop13.setName("I32_thing"); prop13.setParamType(TypeEnum.PRIMITIVE_TYPE); prop13.setThrfitType("I32"); GenericTree prop14 = new GenericTree(); prop14.setName("I64_thing"); prop14.setParamType(TypeEnum.PRIMITIVE_TYPE); prop14.setThrfitType("I64"); Dictionary <string, GenericTree> children2 = new Dictionary <string, GenericTree>(); children2.Add("String_thing", prop11); children2.Add("Byte_thing", prop12); children2.Add("I32_thing", prop13); children2.Add("I64_thing", prop14); input2.setChildren(children2); // 参数值 List <Object> inputVals = new List <object>(); Dictionary <string, object> row = new Dictionary <string, object>(); row.Add("String_thing", "stringValue3"); row.Add("Byte_thing", Convert.ToSByte(127)); row.Add("I32_thing", 99999); row.Add("I64_thing", 9999900001111); inputVals.Add(row); //出参 string method = SERVICE_NAME + "testStruct"; GenericNode genericNode = new GenericNode(); genericNode.setInputs(inputGenericTrees); genericNode.setMethodName(method); genericNode.setValues(inputVals); genericNode.setOutput(input2); object obj = genericAnalyser.syncProcess(protocol, genericNode); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); }
//public Xtruct testMultiException(string arg0, string arg1) //{ // Console.WriteLine("testMultiException:" + arg0 + " " + arg1 + " "); // Xtruct info = new Xtruct() // { // String_thing = arg0 + arg1 // }; // return info; //} public void testNest(Xtruct2 thing) { GenericTree input1 = new GenericTree(); input1.setName("thing"); input1.setParamType(TypeEnum.SYNTHETIC_TYPE); input1.setThrfitType("STRUCT"); input1.setType("XStruct2"); GenericTree prop1 = new GenericTree(); prop1.setName("Byte_thing"); prop1.setParamType(TypeEnum.PRIMITIVE_TYPE); prop1.setThrfitType("SBYTE"); prop1.setParent(input1); GenericTree prop2 = new GenericTree(); prop2.setName("Xstruct_thing"); prop2.setParamType(TypeEnum.SYNTHETIC_TYPE); prop2.setThrfitType("STRUCT"); prop2.setType("XStruct"); GenericTree prop31 = new GenericTree(); prop31.setName("String_thing"); prop31.setParamType(TypeEnum.PRIMITIVE_TYPE); prop31.setThrfitType("STRING"); prop31.setParent(prop2); GenericTree prop32 = new GenericTree(); prop32.setName("Byte_thing"); prop32.setParamType(TypeEnum.PRIMITIVE_TYPE); prop32.setThrfitType("SBYTE"); prop32.setParent(prop2); GenericTree prop33 = new GenericTree(); prop33.setName("I32_thing"); prop33.setParamType(TypeEnum.PRIMITIVE_TYPE); prop33.setThrfitType("I32"); prop33.setParent(prop2); GenericTree prop34 = new GenericTree(); prop34.setName("I64_thing"); prop34.setParamType(TypeEnum.PRIMITIVE_TYPE); prop34.setThrfitType("I64"); prop34.setParent(prop2); prop2.setParent(input1); GenericTree prop3 = new GenericTree(); prop3.setName("I32_thing"); prop3.setParamType(TypeEnum.PRIMITIVE_TYPE); prop3.setThrfitType("I32"); prop3.setParent(input1); List <GenericTree> inputGenericTrees = new List <GenericTree> { input1 }; // 参数值 List <Object> inputVals = new List <object>(); Dictionary <string, object> xstruct2 = new Dictionary <string, object>(); xstruct2["Byte_thing"] = thing.Byte_thing; xstruct2["I32_thing"] = thing.I32_thing; xstruct2["Xstruct_thing"] = new Dictionary <string, object> { { "Byte_thing", thing.Struct_thing.Byte_thing } , { "String_thing", thing.Struct_thing.String_thing } , { "I32_thing", thing.Struct_thing.I32_thing } , { "I64_thing", thing.Struct_thing.I64_thing } }; inputVals.Add(xstruct2); string method = SERVICE_NAME + "testNest"; GenericNode genericNode = new GenericNode(); genericNode.setInputs(inputGenericTrees); genericNode.setMethodName(method); genericNode.setValues(inputVals); genericNode.setOutput(input1); object obj = genericAnalyser.syncProcess(protocol, genericNode); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); }
public void testMulti(sbyte arg0, int arg1, long arg2, Dictionary <short, string> arg3, Numberz arg4, long arg5) { // 返回 Xtruct GenericTree _arg0 = new GenericTree(); _arg0.setName("arg0"); _arg0.setParamType(TypeEnum.PRIMITIVE_TYPE); _arg0.setThrfitType("SBYTE"); GenericTree _arg1 = new GenericTree(); _arg1.setName("_arg1"); _arg1.setParamType(TypeEnum.PRIMITIVE_TYPE); _arg1.setThrfitType("I32"); GenericTree _arg2 = new GenericTree(); _arg2.setName("_arg2"); _arg2.setParamType(TypeEnum.PRIMITIVE_TYPE); _arg2.setThrfitType("I64"); GenericTree _arg3 = new GenericTree(); _arg3.setName("_arg3"); _arg3.setParamType(TypeEnum.COLLECTION_TYPE); _arg3.setThrfitType("MAP"); GenericTree innerKey = new GenericTree(); innerKey.setName("innerKey"); innerKey.setParamType(TypeEnum.PRIMITIVE_TYPE); innerKey.setThrfitType("I16"); GenericTree innerValue = new GenericTree(); innerValue.setName("innerValue"); innerValue.setParamType(TypeEnum.PRIMITIVE_TYPE); innerValue.setThrfitType("STRING"); Dictionary <string, GenericTree> children = new Dictionary <string, GenericTree>(); children.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, innerKey); children.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, innerValue); _arg3.setChildren(children); GenericTree _arg4 = new GenericTree(); _arg4.setName("_arg4"); _arg4.setParamType(TypeEnum.PRIMITIVE_TYPE); _arg4.setThrfitType("I32"); GenericTree _arg5 = new GenericTree(); _arg5.setName("_arg5"); _arg5.setParamType(TypeEnum.PRIMITIVE_TYPE); _arg5.setThrfitType("I64"); List <GenericTree> inputGenericTrees = new List <GenericTree> { _arg0, _arg1, _arg2, _arg3, _arg4, _arg5 }; GenericTree input2 = new GenericTree(); input2.setName("thing"); input2.setParamType(TypeEnum.SYNTHETIC_TYPE); input2.setThrfitType("STRUCT"); input2.setType("Xtruct"); GenericTree prop11 = new GenericTree(); prop11.setName("String_thing"); prop11.setParamType(TypeEnum.PRIMITIVE_TYPE); prop11.setThrfitType("STRING"); prop11.setParent(input2); GenericTree prop12 = new GenericTree(); prop12.setName("Byte_thing"); prop12.setParamType(TypeEnum.PRIMITIVE_TYPE); prop12.setThrfitType("SBYTE"); prop12.setParent(input2); GenericTree prop13 = new GenericTree(); prop13.setName("I32_thing"); prop13.setParamType(TypeEnum.PRIMITIVE_TYPE); prop13.setThrfitType("I32"); prop13.setParent(input2); GenericTree prop14 = new GenericTree(); prop14.setName("I64_thing"); prop14.setParamType(TypeEnum.PRIMITIVE_TYPE); prop14.setThrfitType("I64"); prop14.setParent(input2); // 参数值 List <Object> inputVals = new List <object>(); inputVals.Add(arg0); inputVals.Add(arg1); inputVals.Add(arg2); inputVals.Add(arg3); inputVals.Add(arg4); inputVals.Add(arg5); //出参 string method = SERVICE_NAME + "testMulti"; GenericNode genericNode = new GenericNode(); genericNode.setInputs(inputGenericTrees); genericNode.setMethodName(method); genericNode.setValues(inputVals); genericNode.setOutput(input2); object obj = genericAnalyser.syncProcess(protocol, genericNode); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); }
public void testMapMap(int hello) { GenericTree input1 = new GenericTree(); input1.setName("thing"); input1.setParamType(TypeEnum.COLLECTION_TYPE); input1.setThrfitType("MAP"); GenericTree innerKey = new GenericTree(); innerKey.setName("thing1"); innerKey.setParamType(TypeEnum.PRIMITIVE_TYPE); innerKey.setThrfitType("I32"); GenericTree innerValue = new GenericTree(); innerValue.setName("thing2"); innerValue.setParamType(TypeEnum.COLLECTION_TYPE); innerValue.setThrfitType("MAP"); Dictionary <string, GenericTree> valueChildren = new Dictionary <string, GenericTree>(); valueChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, innerKey); valueChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, innerKey); innerValue.setChildren(valueChildren); Dictionary <string, GenericTree> children = new Dictionary <string, GenericTree>(); children.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, innerKey); children.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, innerValue); input1.setChildren(children); List <GenericTree> inputGenericTrees = new List <GenericTree> { innerKey }; // 参数值 List <Object> inputVals = new List <object>(); inputVals.Add(hello); //出参 GenericTree output = new GenericTree(); output.setParamType(TypeEnum.COLLECTION_TYPE); output.setThrfitType("MAP"); output.setName("returnModel"); GenericTree outKey = new GenericTree(); outKey.setName("thing"); outKey.setParamType(TypeEnum.PRIMITIVE_TYPE); outKey.setThrfitType("I32"); GenericTree outValue = new GenericTree(); outValue.setName("thing"); outValue.setParamType(TypeEnum.COLLECTION_TYPE); outValue.setThrfitType("MAP"); Dictionary <string, GenericTree> outValueChildren = new Dictionary <string, GenericTree>(); outValueChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, outKey); outValueChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, outKey); outValue.setChildren(outValueChildren); Dictionary <string, GenericTree> outputChildren = new Dictionary <string, GenericTree>(); outputChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, outKey); outputChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, outValue); output.setChildren(outputChildren); string method = SERVICE_NAME + "testMapMap"; GenericNode genericNode = new GenericNode(); genericNode.setInputs(inputGenericTrees); genericNode.setMethodName(method); genericNode.setValues(inputVals); genericNode.setOutput(output); object obj = genericAnalyser.syncProcess(protocol, genericNode); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); }
public void testInsanity(string argument) { // Dictionary<long, Dictionary<Numberz, Insanity>> GenericTree input1 = new GenericTree(); input1.setName("argument"); input1.setParamType(TypeEnum.SYNTHETIC_TYPE); input1.setThrfitType("STRUCT"); Dictionary <string, GenericTree> insanity = new Dictionary <string, GenericTree>(); GenericTree userMap = new GenericTree(); userMap.setName("userMap"); userMap.setParamType(TypeEnum.COLLECTION_TYPE); userMap.setThrfitType("MAP"); GenericTree xtructs = new GenericTree(); xtructs.setName("xtructs"); xtructs.setParamType(TypeEnum.COLLECTION_TYPE); xtructs.setThrfitType("LIST"); insanity.Add("userMap", userMap); insanity.Add("xtructs", xtructs); input1.setChildren(insanity); List <GenericTree> inputGenericTrees = new List <GenericTree> { input1 }; // 参数值 List <Object> inputVals = new List <object>(); inputVals.Add(argument); //出参 GenericTree output = new GenericTree(); output.setParamType(TypeEnum.PRIMITIVE_TYPE); output.setThrfitType("STRING"); output.setName("returnModel"); string method = SERVICE_NAME + "testInsanity"; GenericNode genericNode = new GenericNode(); genericNode.setInputs(inputGenericTrees); genericNode.setMethodName(method); genericNode.setValues(inputVals); genericNode.setOutput(output); object obj = genericAnalyser.syncProcess(protocol, genericNode); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj)); }
public override double GetArcCost(GenericNode N2) { Node2 N2bis = (Node2)N2; return(FormDijkstra.matrice[numero, N2bis.numero]); }
private void UpdateListWithFeatured(ref List <ProductTileViewModel> productViewModels, GenericNode node) { if (!node.FeaturedProducts?.FilteredItems?.Any() ?? true) { return; } var market = _currentMarket.GetCurrentMarket(); var currency = _currencyService.GetCurrentCurrency(); var index = 0; foreach (var item in node.FeaturedProducts.FilteredItems) { var content = item.GetContent(); if (content is EntryContentBase featuredEntry) { if (productViewModels.Any(x => x.Code.Equals(featuredEntry.Code))) { productViewModels.RemoveAt(productViewModels.IndexOf(productViewModels.First(x => x.Code.Equals(featuredEntry.Code)))); } else { productViewModels.RemoveAt(productViewModels.IndexOf(productViewModels.Last())); } productViewModels.Insert(index, featuredEntry.GetProductTileViewModel(market, currency, true)); index++; } else if (content is GenericNode featuredNode) { foreach (var nodeEntry in _contentLoader.GetChildren <EntryContentBase>(content.ContentLink) .Where(x => !(x is VariationContent)) .Take(featuredNode.PartialPageSize)) { if (productViewModels.Any(x => x.Code.Equals(nodeEntry.Code))) { productViewModels.RemoveAt(productViewModels.IndexOf(productViewModels.First(x => x.Code.Equals(nodeEntry.Code)))); } else { productViewModels.RemoveAt(productViewModels.IndexOf(productViewModels.Last())); } productViewModels.Insert(index, nodeEntry.GetProductTileViewModel(market, currency, true)); index++; } } } }
public void Delete() { var id = node1.Id; node1.Delete(); node1 = DataSet.GetNode(id, Ids.System, MaxAge.Now); Assert.IsFalse(node1.IsLoaded); // Need to recreate so that the cleanup won't fail.. node1 = DataSet.SystemCreateNode(domainSystem, ANodeType.Base.Id, Ids.System); }
private void ROOT_COMPSTMT_STMTLIST_STMT_COMMAND(AstNode node, AstNode next) { GenericNode genNode = node as GenericNode; if (genNode == null) { return; } string att = String.Empty; string res = String.Empty; AstNode args = null; AstNode block = null; int type = 0; // 0 = resource 1 = attribute foreach (AstNode child in genNode.ChildNodes.Where(child => child != null)) { if (child is Token) { Token token = child as Token; if (token.Terminal.Category != TokenCategory.Content) { continue; } if (next != null) { if (next.ToString() != "BLOCK") { continue; } // Next node is BLOCK: then COMMAND represent a Chef resource, set type to 1 (resource) res = token.Text; block = next; type = 1; } else { // It is a Chef attribute, set type to 0 (attribute) att = token.Text; type = 0; } } else { if (child.ToString() == "CALL_ARGS") { args = child; } } } switch (type) { case 0: Attribute(att, args); break; case 1: Resource(res, args, block); break; } }
/// <summary> /// Inserts a node in the correct location (sorting alphabetically by /// directories first, then files). /// </summary> /// <param name="node"></param> private static void InsertNode(TreeNodeCollection nodes, GenericNode node) { bool inserted = false; for (int i=0; i<nodes.Count; i++) { GenericNode existingNode = nodes[i] as GenericNode; if (node is FileNode && existingNode is DirectoryNode) continue; if ((node is DirectoryNode && existingNode is FileNode) || string.Compare(existingNode.Text, node.Text, true) > 0) { nodes.Insert(i,node); inserted = true; break; } } if (!inserted) nodes.Add(node); // append to the end of the list // is the tree looking to have this node selected? if (Tree.PathToSelect == node.BackingPath) { // use SelectedNode so multiselect treeview can handle painting Tree.SelectedNodes = new ArrayList(new object[]{node}); } }
//public class CodeGeneratorFactory : DesignerGeneratorFactory<TNode> //{ // public override IEnumerable<OutputGenerator> CreateGenerators(IGraphConfiguration graphConfig, TNode item) // { // if (item.Precompiled) yield break; // if (!item.IsValid) yield break; // var config = Container.GetNodeConfig<TNode>(); // if (config.CodeGenerators == null) yield break; // var generatorArgs = new ConfigCodeGeneratorSettings() // { // Data = item, // }; // foreach (var outputGenerator in config.OutputGenerators) // { // var generator = outputGenerator(); // generator.ObjectData = item; // yield return generator; // } // foreach (var generatorMethod in config.CodeGenerators) // { // var result = generatorMethod(generatorArgs); // if (result != null) // { // if (config.TypeGeneratorConfigs != null && config.TypeGeneratorConfigs.ContainsKey(result.GetType())) // { // var generatorConfig = // config.TypeGeneratorConfigs[result.GetType()] as NodeGeneratorConfig<TNode>; // if (generatorConfig != null) // { // if (generatorConfig.Condition != null && !generatorConfig.Condition(item)) continue; // if (result.IsDesignerFile) // { // if (generatorConfig.DesignerFilename != null) // result.Filename = generatorConfig.DesignerFilename.GetValue(item); // } // else // { // if (generatorConfig.Filename != null) // result.Filename = generatorConfig.Filename.GetValue(item); // } // } // } // yield return result; // } // } // } //} //public NodeConfig<TNode> AddFlag(string flag) //{ // Container.RegisterInstance<IDiagramNodeCommand>(new GraphItemFlagCommand<TNode>(flag, flag), typeof(TNode).Name + flag + "FlagCommand"); // return this; //} //public NodeConfig<TNode> AddFlag(string flag, Func<TNode, bool> get, Action<TNode, bool> set) //{ // Container.RegisterInstance<IDiagramNodeCommand>(new GraphItemFlagCommand<TNode>(flag, flag) // { // IsProperty = true, // Get = get, // Set = set // }, flag + "Command"); // return this; //} public override bool IsValid(GenericNode node) { return(!Validate(node as TNode).Any()); }
public bool Delete(int Position) { //Set current to Head. Need to walk through it from the beginning current = Head; //If the position is the very first node in the list if (Position == 1) { //Set the Head to the next node in the list. This will be the 2nd one. Head = current.Next; //Delete the current.Next pointer so there is no reference from current to //another node current.Next = null; //current = null because we want the garbage collector to come pick it up. current = null; //it was successfull so, return true; return true; } //Check to make sure that at least a positive number was entered. //Should also check to make sure that the position is less than the //size of the array so that we aren't looking for something that doesn't //exist. Adding a size property will be more work. //TODO: Add a size property if (Position > 1) { //Make a temp node that starts at the Head. This way we don't need to actually //move the Head pointer. We can just use the temp node GenericNode<T> tempNode = Head; //Set a previous node to null. It will be used for the delete GenericNode<T> previousTempNode = null; //Start a counter to know if we have reached the position yet or not. int count = 0; //while the tempNode is NOT null, we can continue to walk through the //linked list. If it is null, then we have reached the end. while (tempNode != null) { //If the count is the same as the position entered - 1, then we have found //the one we would like to delete. if (count == Position - 1) { //Set the last node's Next property to the TempNodes Next Property //Jumping over the tempNode. The previous node's next will now point //to the node AFTER the tempNode previousTempNode.Next = tempNode.Next; if (tempNode.Next == null) { last = previousTempNode; } //Remove the next pointer of the tempnode tempNode.Next = null; //Return True because it was successfull return true; } //Increment the counter since we are going to move forward in the list count++; //Set the lastNode equal to the tempNode. Now both variables are pointing to //the exact same node. previousTempNode = tempNode; //Now set the tempNode to tempNodes Next node. This will move tempNode //one more location forward in the list. tempNode = tempNode.Next; } } //tempNode became null, so apparently we did not find it. Return false. return false; }
public ANode(GenericNode node) : base(node) { }
public void ToDigitTest_2() { int val = GenericNode.ToDigit(false); Assert.AreEqual(0, val); }
//------------------------------------------------- void GenericNode <T> .INodeNotificationListener.Notify(GenericNode <T> .NodeNotification Notification_in) { this._Notify(Notification_in); return; }
public abstract bool IsValid(GenericNode node);
//------------------------------------------------- public virtual void OnNodeUpdate(GenericNode <S> Node_in) { return; }
//------------------------------------------------- public GenericNode <T> RelativeNode(NodeRelationships Relationship_in) { GenericNode <T> nodePrev = _PrevNode; GenericNode <T> nodeNext = _NextNode; GenericNode <T> nodeRoot = this; GenericNode <T> nodeSib = this; GenericNode <T> nodeChild = null; while (true) { if ((Relationship_in == NodeRelationships.None)) { break; } else if ((Relationship_in == NodeRelationships.PrevNode)) { return(_PrevNode); } else if ((Relationship_in == NodeRelationships.NextNode)) { return(_NextNode); } else if ((Relationship_in == NodeRelationships.FirstNode)) { if ((nodePrev == null)) { return(this); } if ((nodePrev._PrevNode == null)) { return(nodePrev); } nodePrev = nodePrev._PrevNode; } else if ((Relationship_in == NodeRelationships.LastNode)) { if ((nodeNext == null)) { return(this); } if ((nodeNext._NextNode == null)) { return(nodeNext); } nodeNext = nodeNext._NextNode; } else if ((Relationship_in == NodeRelationships.RootNode)) { if ((nodePrev == null)) { return(nodeRoot); } if ((nodePrev._Indent < nodeRoot._Indent)) { nodeRoot = nodePrev; } nodePrev = nodePrev._PrevNode; } else if ((Relationship_in == NodeRelationships.ParentNode)) { if ((nodePrev == null)) { break; } if ((nodePrev._Indent < _Indent)) { return(nodePrev); } nodePrev = nodePrev._PrevNode; } else if ((Relationship_in == NodeRelationships.PrevSibNode)) { if ((nodePrev == null)) { break; } if ((nodePrev._Indent < _Indent)) { break; } if ((nodePrev._Indent == _Indent)) { return(nodePrev); } nodePrev = nodePrev._PrevNode; } else if ((Relationship_in == NodeRelationships.NextSibNode)) { if ((nodeNext == null)) { break; } if ((nodeNext._Indent < _Indent)) { break; } if ((nodeNext._Indent == _Indent)) { return(nodeNext); } nodeNext = nodeNext._NextNode; } else if ((Relationship_in == NodeRelationships.FirstSibNode)) { if ((nodePrev == null)) { return(nodeSib); } if ((nodePrev._Indent < _Indent)) { return(nodeSib); } if ((nodePrev._Indent == _Indent)) { nodeSib = nodePrev; } nodePrev = nodePrev._PrevNode; } else if ((Relationship_in == NodeRelationships.LastSibNode)) { if ((nodeNext == null)) { return(nodeSib); } if ((nodeNext._Indent < _Indent)) { return(nodeSib); } if ((nodeNext._Indent == _Indent)) { nodeSib = nodeNext; } nodeNext = nodeNext._NextNode; } else if ((Relationship_in == NodeRelationships.FirstChildNode)) { if ((nodeNext == null)) { break; } if ((nodeNext._Indent <= _Indent)) { break; } if ((nodeNext._Indent == (_Indent + 1))) { return(nodeNext); } nodeNext = nodeNext._NextNode; } else if ((Relationship_in == NodeRelationships.LastChildNode)) { if ((nodeNext == null)) { return(nodeChild); } if ((nodeNext._Indent <= _Indent)) { return(nodeChild); } if ((nodeNext._Indent == (_Indent + 1))) { nodeChild = nodeNext; } nodeNext = nodeNext._NextNode; } else if ((Relationship_in == NodeRelationships.FirstDescNode)) { if ((nodeNext != null)) { if ((nodeNext._Indent > _Indent)) { return(nodeNext); } } break; } else if ((Relationship_in == NodeRelationships.LastDescNode)) { if ((nodeNext == null)) { return(nodeChild); } if ((nodeNext._Indent <= _Indent)) { return(nodeChild); } if ((nodeNext._Indent > _Indent)) { nodeChild = nodeNext; } nodeNext = nodeNext._NextNode; } else { break; } } return(null); }
//------------------------------------------------- public virtual void OnNodeAddChild(GenericNode <S> Node_in, GenericNode <S> ChildNode_in) { return; }
internal void SetNextNode(GenericNode <T> value) { this._NextNode = value; }
//------------------------------------------------- public virtual void OnRemoveChild(GenericNode <S> Node_in, GenericNode <S> ChildNode_in) { return; }
public FormDijkstra(Controller c) { Controller = c; InitializeComponent(); pictureBox1.Image = Image.FromFile("Images/Partie2_Dijkstra.PNG"); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; try { StreamReader monStreamReader = new StreamReader("dijkstra.txt"); // Lecture du fichier avec un while, évidemment ! // 1ère ligne : "nombre de noeuds du graphe string ligne = monStreamReader.ReadLine(); int i = 0; while (ligne[i] != ':') { i++; } string strnbnoeuds = ""; i++; // On dépasse le ":" while (ligne[i] == ' ') { i++; // on saute les blancs éventuels } while (i < ligne.Length) { strnbnoeuds = strnbnoeuds + ligne[i]; i++; } nbnodes = Convert.ToInt32(strnbnoeuds); Random rand = new Random(); int startNode = rand.Next(0, nbnodes / 2); int endNode = rand.Next((nbnodes / 2) + 2, nbnodes); textBoxStartNode.Text = startNode + ""; textBoxEndNode.Text = endNode + ""; matrice = new double[nbnodes, nbnodes]; for (i = 0; i < nbnodes; i++) { for (int j = 0; j < nbnodes; j++) { matrice[i, j] = -1; } } // Ensuite on a ls tructure suivante : // arc : n°noeud départ n°noeud arrivée valeur // exemple 4 : ligne = monStreamReader.ReadLine(); while (ligne != null) { i = 0; while (ligne[i] != ':') { i++; } i++; // on passe le : while (ligne[i] == ' ') { i++; // on saute les blancs éventuels } string strN1 = ""; while (ligne[i] != ' ') { strN1 = strN1 + ligne[i]; i++; } int N1 = Convert.ToInt32(strN1); // On saute les blancs éventuels while (ligne[i] == ' ') { i++; } string strN2 = ""; while (ligne[i] != ' ') { strN2 = strN2 + ligne[i]; i++; } int N2 = Convert.ToInt32(strN2); // On saute les blancs éventuels while (ligne[i] == ' ') { i++; } string strVal = ""; while ((i < ligne.Length) && (ligne[i] != ' ')) { strVal = strVal + ligne[i]; i++; } double val = Convert.ToDouble(strVal); matrice[N1, N2] = val; matrice[N2, N1] = val; listBoxgraphe.Items.Add(Convert.ToString(N1) + "--->" + Convert.ToString(N2) + " : " + Convert.ToString(matrice[N1, N2])); ligne = monStreamReader.ReadLine(); } // Fermeture du StreamReader (obligatoire) monStreamReader.Close(); numinitial = Convert.ToInt32(textBoxStartNode.Text); numfinal = Convert.ToInt32(textBoxEndNode.Text); g = new SearchTree(); Node2 N0 = new Node2(); N0.numero = numinitial; textBoxFermes.Text = ""; textBoxOuverts.Text = "" + numinitial; textBoxRepFerme.Text = ""; textBoxRepOuvert.Text = "" + numinitial; N = g.InitialiserSolution(N0); } catch (Exception exp) { MessageBox.Show("Erreur lors du chargement du fichier 'dijkstra.txt'.\n Erreur :" + exp.Message); } }
//------------------------------------------------- public virtual void OnClearChildren(GenericNode <S> Node_in) { return; }
public Queue() { Front = null; Rear = null; }
public ResultantNodes GetNodes(IEnumerable<Xid> ids, Xid requestingNodeId, MaxAge maxAge) { if (null == ids) { throw new ArgumentNullException("ids"); } if ((int)maxAge < -2) { throw new ArgumentOutOfRangeException("maxAge", "must be at least -2"); // -1 means infinate, -2 means noload } var output = new List<GenericNode>(); var pending = new HashSet<Xid>(ids); // If we want to load... if (maxAge != MaxAge.NoLoad) { // Fetch from cache if ((int)maxAge > 0) { foreach (var record in GenericNode.GetFromCache(Variant, pending, maxAge)) { pending.Remove(record.Id); } } // Cache any remaining items if (pending.Count > 0) { foreach (var record in GenericNode.GetFromDatabase(Variant, pending)) { pending.Remove(record.Id); } } // Add nodes to output output.AddRange(ids.Select(id => new GenericNode(Variant, id, requestingNodeId, MaxAge.Any))); } // Add non-existant nodes to output foreach (var id in pending) { var node = new GenericNode(Variant, id, requestingNodeId, MaxAge.NoLoad); // TODO: We know that this is non-existant - save a server call? output.Add(node); } return new ResultantNodes(output, maxAge); }
public void testInit() { // TODO How to I add multiple groups to a domain Admin = ANodeDomainType.Base.Admin; User = new GroupType("QssObZZOF0uULXq19YWOhg"); domainSystem = DataSet.SystemCreateDomain(Ids.System); domainAdmin = DataSet.SystemCreateDomain(Admin.Id); domainUser = DataSet.SystemCreateDomain(User.Id); node1 = DataSet.SystemCreateNode(domainSystem, ANodeType.Base.Id, Ids.System); node2 = DataSet.SystemCreateNode(domainSystem, ANodeType.Base.Id, Ids.System); nodeUnloaded = DataSet.GetNode(node2.Id, Ids.System, MaxAge.NoLoad); }
public virtual object VisitGenericDefinition(GenericNode genericNode, object data) { stackMap.Push(genericNode); genericNode.Constraints.AcceptVisitor(this, data); genericNode.TypeParameters.AcceptVisitor(this, data); stackMap.Pop(); return null; }
public void Delete2() { var id = node1.Id; node2.SetLinked(1, node1.Id, true); Assert.IsTrue(node2.IsLinked(1, node1.Id)); node1.Delete(); node2.Reload(MaxAge.Now); Assert.IsFalse(node2.IsLinked(1, node1.Id)); // Need to recreate so that the cleanup won't fail.. node1 = DataSet.SystemCreateNode(domainSystem, ANodeType.Base.Id, Ids.System); }
private void EnsureParentedBy(GenericNode child, GenericNode parent) { if (child.Parent != parent) { child.Parent.Nodes.Remove(child); InsertNode(parent.Nodes, child); } }
protected void CreateContentByConfiguration(IEnumerable <GraphItemConfiguration> graphItemConfigurations, GenericNode node = null) { foreach (var item in graphItemConfigurations.OrderBy(p => p.OrderIndex)) { var proxyConfig = item as ConfigurationProxyConfiguration; if (proxyConfig != null) { if (!IsVisible(proxyConfig.Visibility)) { continue; } CreateContentByConfiguration(proxyConfig.ConfigSelector(DataObject as GenericNode)); continue; } var inputConfig = item as NodeInputConfig; if (inputConfig != null) { if (inputConfig.IsOutput) { AddOutput(inputConfig, node); } else if (inputConfig.IsInput) { AddInput(inputConfig, node); } } var sectionConfig = item as NodeConfigSectionBase; if (sectionConfig != null) { AddSection(sectionConfig); } } }
public void InsertFile(IMainForm mainForm, Project project, string path, GenericNode node) { if (!mainForm.CurrentDocument.IsEditable) return; string nodeType = (node != null) ? node.GetType().ToString() : null; string export = (node != null && node is ExportNode) ? (node as ExportNode).Export : null; string textToInsert = project.GetInsertFileText(mainForm.CurrentDocument.FileName, path, export, nodeType); if (textToInsert == null) return; if (mainForm.CurrentDocument.IsEditable) { mainForm.CurrentDocument.SciControl.AddText(textToInsert.Length, textToInsert); mainForm.CurrentDocument.Activate(); } else { string msg = TextHelper.GetString("Info.EmbedNeedsOpenDocument"); ErrorManager.ShowInfo(msg); } }
public abstract void Convert(GenericNode <S> SourceNode, GenericNode <T> TargetNode);
protected SpecificNode(GenericNode genericNode) : base(genericNode) { }
public override void Convert(GenericNode <object> SourceNode, GenericNode <string> TargetNode) { TargetNode.Value = SourceNode.Value.ToString(); return; }
private void AddItems(MergableMenu menu, GenericNode node) { if (node.IsInvalid) return; string path = node.BackingPath; if (node is ProjectNode) AddProjectItems(menu); else if (node is ClasspathNode) AddClasspathItems(menu); else if (node is DirectoryNode) AddFolderItems(menu, path); else if (node is ProjectOutputNode) AddProjectOutputItems(menu, node as ProjectOutputNode); else if (node is ExportNode) AddExportItems(menu, node as ExportNode); else if (node is FileNode) { string ext = Path.GetExtension(path).ToLower(); if (FileInspector.IsActionScript(path, ext)) AddActionScriptItems(menu, path); else if (FileInspector.IsHaxeFile(path, ext)) AddHaxeFileItems(menu, path); else if (FileInspector.IsMxml(path, ext)) AddMxmlItems(menu, path); else if (FileInspector.IsCss(path, ext)) AddCssItems(menu, path); else if (FileInspector.IsSwf(path, ext)) AddSwfItems(menu, path); else if (FileInspector.IsSwc(path, ext)) AddSwcItems(menu, path); else if (FileInspector.IsResource(path, ext)) AddOtherResourceItems(menu, path); else AddGenericFileItems(menu, path); } }
public void ToDigitTest_1() { int val = GenericNode.ToDigit(true); Assert.AreEqual(1, val); }