private IEnumerator RelinkRouterJob(ChainNode respawn) { //yield return null; //yield return null; // Ensure that the nodes we're looking for exist try { foreach (var state in router.Keys) { foreach (var target in router[state]) { respawn.Router[state].AddTarget( ChainView.Instance.RootGroupView.RecursiveNodeViewsEnumerable.First( cnv => cnv.ChainNode.JsonId == target).ChainNode, false); } } if (parentJsonID == -1) { yield break; } var parentRouter = ChainView.Instance.RootGroupView.RecursiveNodeViewsEnumerable.First( cnv => cnv.ChainNode.JsonId == parentJsonID).ChainNode.Router; foreach (var state in parentStates) { parentRouter[state].AddTarget(respawn, false); } } catch (Exception) { } }
public static Include <T> ExtractNavigations <T>(this Include <T> include, IModel model) where T : class { void extractNavigationsAppendKeyLeafsRecursive(ChainNode source, ChainNode destination) { var entityType = model.FindEntityType(source.Type); if (entityType != null) { var navigationPropertyInfos = entityType.GetNavigations().Select(e => e.PropertyInfo).ToList(); foreach (var n in source.Children) { var child = n.Value; var propertyInfo = navigationPropertyInfos.FirstOrDefault(e => e.Name == child.MemberName); if (propertyInfo != null) { var childDestination = child.CloneChainMemberNode(destination); //childDestination.AddChild(propertyInfo); extractNavigationsAppendKeyLeafsRecursive(child, childDestination); } } } } var root = include.CreateChainNode(); var destinaion = new ChainNode(root.Type); extractNavigationsAppendKeyLeafsRecursive(root, destinaion); var @value = destinaion.ComposeInclude <T>(); return(@value); }
public NodeDelete(ChainNode deletedNode) { var recievingGroup = ChainView.Instance.RootGroupView.RecursiveGroupViewsEnumerable.First( cgv => cgv.Group.Nodes.Contains(deletedNode)); var chainNodeView = recievingGroup.NodeViewsEnumerable.First(cnv => cnv.ChainNode == deletedNode); jsonid = deletedNode.JsonId; nodeDragId = chainNodeView.Draggable.DragID; groupDragId = recievingGroup.BackgroundPanel.Draggable.DragID; initialLocation = chainNodeView.transform.position; try { var parent = StateRouter.NodeParents[deletedNode]; parentJsonID = parent.Node.JsonId; parentStates = parent.States.Select(s => s.Name).ToArray(); } catch (KeyNotFoundException) { parentJsonID = -1; parentStates = new string[] { }; } router = new Dictionary <string, int[]>(); foreach (var state in deletedNode.Router.SelectionStatesEnumerable) { router[state.Name] = state.TargetsEnumerable.Select(cn => cn.JsonId).ToArray(); } deletedNode.Router.UntargetAllTargets(); deletedNode.RequestUntargeting(); json = JsonConvert.SerializeObject(deletedNode, Formatting.Indented, HaxxisPackage.GetSerializationSettings(TypeNameHandling.All)); }
public ChainNodeView FindChainNodeView(ChainNode node, bool recurse) { var foundNode = NodeViews.FirstOrDefault(view => view.ChainNode == node); if (foundNode != null) { return(foundNode); } if (!recurse) { return(null); } foreach (var view in GroupViews) { foundNode = view.FindChainNodeView(node, true); if (foundNode != null) { return(foundNode); } } return(null); }
public void PointerDown() { if (SequanceManager.Instance.ConnectObjects.Count == 0) { SequanceManager.Instance.AddChainNode(this); } else { ChainNode lastChainNode = (ChainNode)SequanceManager.Instance.ConnectObjects.Last(); if (lastChainNode == this) { print("前のノードと同じノードが選択されました"); return; } var connectEdge = lastChainNode.SearchConnectEdge(this); if (connectEdge == null) { print("前のノードと接続されていないノードが選択されました"); return; } bool b = SequanceManager.Instance.SerchConnectedEdge(connectEdge); if (b) { print("既に接続されているエッジを通ります"); return; } StartCoroutine(lastChainNode.Connect(this, connectEdge)); SequanceManager.Instance.AddChainNode(this, connectEdge); } }
private void Delete() { ApiInvokeMap.MapCore.GetInstance().Increase("Delete"); lock (add_look_obj) { if (_currlength == 0) { return; } if (_tailNode.preNode != null) { _tailNode.preNode.nextNode = null; _tailNode = _tailNode.preNode; _currlength--; } else { _currlength = 0; _headNode = null; _tailNode = null; } } }
public Delegate GetFormatter <T, TParameters>( // TODO: // Include<T,TParameters> include = null, Include <T> include = null, Func <ChainNode, IEnumerable <MemberInfo> > leafRule = null, Action <RulesDictionary <T> > config = null, bool useToString = false, string dateTimeFormat = null, string floatingPointFormat = null, bool objectAsArray = false, bool handleEmptyObjectLiteral = true, bool handleEmptyArrayLiteral = true, Func <StringBuilder, bool> nullSerializer = null, bool handleNullProperty = true, Func <StringBuilder, bool> nullArraySerializer = null, bool handleNullArrayProperty = true, string rootAsProperty = null, Action <IJsonRootPropertyAppender, TParameters> rootPropertyAppender = null, bool rootHandleNull = true, bool rootHandleEmptyLiteral = true, int stringBuilderCapacity = 16) { if (formatter != null) { return(formatter); } else { ChainNode root = IncludeExtensions.CreateChainNode(include); if (include == null) { var type = typeof(T); if (type.IsAssociativeArrayType()) { root.AppendLeafs(leafRule ?? LeafRuleManager.DefaultEfCore); } } else { if (leafRule != null) { root.AppendLeafs(leafRule); } } formatter = JsonManager.ComposeFormatter <T, TParameters>(root: root, config: config, useToString: useToString, dateTimeFormat: dateTimeFormat, floatingPointFormat: floatingPointFormat, objectAsArray: objectAsArray, handleEmptyObjectLiteral: handleEmptyObjectLiteral, handleEmptyArrayLiteral: handleEmptyArrayLiteral, nullSerializer: nullSerializer, handleNullProperty: handleNullProperty, nullArraySerializer: nullArraySerializer, handleNullArrayProperty: handleNullArrayProperty, rootAsProperty: rootAsProperty, rootPropertyAppender: rootPropertyAppender, rootHandleNull: rootHandleNull, rootHandleEmptyLiteral: rootHandleEmptyLiteral, stringBuilderCapacity); return(formatter); } }
public void RemoveTargetCheckbox(ChainNode targetNode) { var targetCheckbox = TargetsToTargetCheckboxes[targetNode]; Destroy(targetCheckbox.gameObject); TargetsToTargetCheckboxes.Remove(targetNode); }
public NodeAdd(ChainNode addedNode, ChainGroupView recievingGroup, Vector3 spawnLocation) { jsonid = addedNode.JsonId; nodeDragId = recievingGroup.NodeViewsEnumerable.First(cnv => cnv.ChainNode == addedNode).Draggable.DragID; groupDragId = recievingGroup.BackgroundPanel.Draggable.DragID; NodeType = addedNode.GetType(); initialLocation = spawnLocation; }
private void HandleGroupNodeRemoved(ChainNode node, bool isTransfer) { if (isTransfer) { return; } RemoveChainNodeView(node, true); }
public RouterConnection(ChainNode to, SelectionState state, bool add) { idTo = to.JsonId; this.state = state.Name; idFrom = ChainView.Instance.RootGroupView.RecursiveNodeViewsEnumerable.First( cnv => cnv.ChainNode.Router[this.state] == state).ChainNode.JsonId; wasAdd = add; }
public void ChainNode() { Nohros.Configuration.Configuration config = Nohros.Configuration.Configuration.DefaultConfiguration; ChainNode pseudo_chain = config.ChainNodes["pseudo-chain"] as ChainNode; Assert.IsNotNull(pseudo_chain); Assert.AreEqual("SmsMessenger", pseudo_chain.Nodes[0]); Assert.AreEqual("EmailMessenger", pseudo_chain.Nodes[1]); }
private void AddChainNodeView(ChainNode chainNode) { var viewGo = Instantiate(NodeViewPrefab, NodeAttachmentPoint); var view = viewGo.GetComponent <ChainNodeView>(); view.ChainNode = chainNode; //view.Expanded = true; AddChainNodeView(view); }
/// <summary> /// このノードが行き止まりかどうか /// </summary> /// <param name="node">調べるノード</param> /// <returns>行き止まりならtrue</returns> public bool CheckDeadEndNode(ChainNode node) { foreach (var edge in node.ConnectedChainEdges) { if (!CheckEdgePass(edge)) { return(false); } } return(true); }
private void RemoveUniqueTarget(ChainNode targetNode) { RemoveTargetLabel(targetNode); foreach (var stateView in StateViews) { stateView.RemoveTargetCheckbox(targetNode); } UniqueTargetsChanged(); }
public static ChainNode ShallowClone(ChainNode tnode) { var newnode = new ChainNode(tnode.token) { accessCount = tnode.accessCount, nextNode = tnode.nextNode, preNode = tnode.preNode, used = tnode.used }; return(newnode); }
internal InternalNodeOptions GeInternalNodeOptions(ChainNode node) { var theDictionary = GetDictionary(node); var serializationType = Nullable.GetUnderlyingType(node.Type) ?? node.Type; var options = default(InternalNodeOptions); if (theDictionary.TryGetValue(serializationType, out SerializerOptions rule)) { options = rule.InternalNodeOptions; } return(options ?? internalNodeOptions); }
private void HandleStateTargetRemoved(SelectionState state, ChainNode target) { if (!TargetsToTargetCheckboxes.ContainsKey(target)) { return; } var checkbox = TargetsToTargetCheckboxes[target]; checkbox.Checked = false; UpdateCheckboxes(); }
private void HandleTargetChecked(ChainNode target, bool isChecked) { // This is setting actual targets in the state. if (isChecked && !SelectionState.Contains(target)) { SelectionState.AddTarget(target); } else if (!isChecked && SelectionState.Contains(target)) { SelectionState.RemoveTarget(target); } }
private void HandleGroupNodeAdded(ChainNode node, bool isTransfer) { if (isTransfer) { return; } AddChainNodeView(node); if (!node.SuppressUndos) { UndoLord.Instance.Push(new NodeAdd(node, this, NewNodePosition)); } }
private void AddTargetLabel(ChainNode targetNode) { var targetLabelGo = Instantiate(TargetLabelPrefab); var targetLabel = targetLabelGo.GetComponent <StateRouterTargetLabelView>(); targetLabel.Target = targetNode; targetLabel.transform.SetParent(TargetLabelRootTransform, false); TargetLabels.Add(targetLabel); IndexAndPositionTargetLabels(); }
private void RemoveTargetLabel(ChainNode targetNode) { var label = TargetLabels.FirstOrDefault(l => l.Target == targetNode); if (label == null) { return; } TargetLabels.Remove(label); Destroy(label.gameObject); IndexAndPositionTargetLabels(); }
public void AddNode(ChainNode <TRequestContext> node) { if (firstChainNode == null) { firstChainNode = node; lastChainNode = node; } else { lastChainNode.Successor = node; lastChainNode = lastChainNode.Successor; } ++Count; }
private void CreateTargetCheckbox(ChainNode target) { var newTargetItemGo = Instantiate(TargetUiPrefab); var newTargetItem = newTargetItemGo.GetComponent <StateRouterTargetCheckboxView>(); newTargetItem.transform.SetParent(TargetItemRootTransform, false); if (SelectionState != null && SelectionState.Contains(target)) { newTargetItem.Checked = true; } newTargetItem.CheckedChanged += isChecked => HandleTargetChecked(target, isChecked); TargetsToTargetCheckboxes.Add(target, newTargetItem); }
/// <summary> /// 接続してるエッジの先に引数のノードがあるか調べる /// </summary> /// <param name="connectNode">接続されているか調べるノード</param> /// <returns>接続されていればその接続エッジ,なければnull</returns> public ChainEdge SearchConnectEdge(ChainNode connectNode) { foreach (var connectEdge in connectedChainEdges) { if (connectEdge == null) { continue; } var connectingNode = connectEdge.GetConnectedOtherNode(connectNode); if (connectingNode != null) { return(connectEdge); } } return(null); }
public static Func <IEnumerable <T>, TP, string> ComposeEnumerableFormatter <T, TP>( this Include <T> include , Action <RulesDictionary <T> > config = null , bool useToString = false , string dateTimeFormat = null , string floatingPointFormat = null , bool objectAsArray = false , bool handleEmptyObjectLiteral = true , bool handleEmptyArrayLiteral = true , Func <StringBuilder, bool> nullSerializer = null , bool handleNullProperty = true , Func <StringBuilder, bool> nullArraySerializer = null , bool handleNullArrayProperty = true , string rootAsProperty = null , Action <IJsonRootPropertyAppender, TP> rootPropertyAppender = null , bool rootHandleNull = true , bool rootHandleEmptyLiteral = true , int stringBuilderCapacity = 16 , Func <LambdaExpression, Delegate> compile = null , bool doCompileInnerLambdas = true) { if (compile == null) { compile = StandardCompile; } ChainNode root = IncludeExtensions.CreateChainNode(include); if (include == null && config == null) { var type = typeof(T); if (type.IsAssociativeArrayType()) { root.AppendLeafs(); } } return(ComposeEnumerableFormatter(root: root, config: config, useToString: useToString, dateTimeFormat: dateTimeFormat, floatingPointFormat: floatingPointFormat, objectAsArray: objectAsArray, handleEmptyObjectLiteral: handleEmptyObjectLiteral, handleEmptyArrayLiteral: handleEmptyArrayLiteral, nullSerializer: nullSerializer, handleNullProperty: handleNullProperty, nullArraySerializer: nullArraySerializer, handleNullArrayProperty: handleNullArrayProperty, rootAsProperty: rootAsProperty, rootPropertyAppender: rootPropertyAppender, rootHandleNull: rootHandleNull, rootHandleLiteral: rootHandleEmptyLiteral, stringBuilderCapacity: stringBuilderCapacity, compile: compile, doCompileInnerLambdas: doCompileInnerLambdas)); }
private void Sort() { ApiInvokeMap.MapCore.GetInstance().Increase("Sort"); lock (add_look_obj) { if (_currlength == 0) { return; } List <ChainNode> tosortlist = new List <ChainNode>(_currlength); var tempnode = _headNode; //var curr_first = _headNode; while (tempnode != null) { tosortlist.Add(ChainNode.ShallowClone(tempnode)); tempnode = tempnode.nextNode; } tosortlist.Sort((x, y) => { return(y.accessCount - x.accessCount); }); //relink tosortlist[0].preNode = null; tosortlist[tosortlist.Count - 1].nextNode = null; tosortlist[0].accessCount = 0; tosortlist[tosortlist.Count - 1].accessCount = 0; if (tosortlist.Count > 1) { tosortlist[0].nextNode = tosortlist[1]; tosortlist[tosortlist.Count - 1].preNode = tosortlist[tosortlist.Count - 2]; } else { tosortlist[0].nextNode = null; tosortlist[tosortlist.Count - 1].preNode = null; } for (int i = 1; i < tosortlist.Count - 1; i++) { tosortlist[i].preNode = tosortlist[i - 1]; tosortlist[i].nextNode = tosortlist[i + 1]; tosortlist[i].accessCount = 0; } _tailNode = tosortlist[tosortlist.Count - 1]; _headNode = tosortlist[0]; } }
internal SerializerOptions GetLeafSerializerOptions(ChainNode node) { var theDictionary = GetDictionary(node); var serializationType = Nullable.GetUnderlyingType(node.Type) ?? node.Type; if (!theDictionary.TryGetValue(serializationType, out SerializerOptions rule)) { var @delegate = CreateGeneralSerializer(serializationType, useToString); rule = new SerializerOptions(@delegate, nullSerializer, handleNullProperty, internalNodeOptions); } if (rule?.Serializer == null) { throw new NotConfiguredException($"Node '{node.FindLinkedRootXPath()}' included as leaf but serializer for its type '{serializationType.FullName}' is not configured"); } return(rule); }
private bool InitAdd(Token t) { ApiInvokeMap.MapCore.GetInstance().Increase("InitAdd"); lock (add_look_obj) { if (_currlength != 0) { return(false); } ChainNode nodeitem = new ChainNode(t); _headNode = nodeitem; _tailNode = nodeitem; _currlength = 1; return(true); } }
public ChainNode GetConnectedOtherNode(ChainNode chainNode) { Debug.Assert(connectedChainNodes.Length == 2); if (connectedChainNodes[0] != chainNode && connectedChainNodes[1] != chainNode) { return(null); } if (connectedChainNodes[0] == chainNode) { return(connectedChainNodes[1]); } else { return(connectedChainNodes[0]); } }
public void Add(Token t) { lock (add_look_obj) { ApiInvokeMap.MapCore.GetInstance().Increase("Add"); if (_currlength == 0) { if (InitAdd(t)) { return; } } if (_currlength == _maxlength) { Delete(); } ChainNode nodeitem = new ChainNode(t); _headNode.preNode = nodeitem; nodeitem.nextNode = _headNode; _headNode = nodeitem; _currlength++; } }
public static ChainNode ShallowClone(ChainNode tnode) { var newnode = new ChainNode(tnode.token) { accessCount = tnode.accessCount, nextNode = tnode.nextNode, preNode = tnode.preNode, used = tnode.used }; return newnode; }
private void Sort() { ApiInvokeMap.MapCore.GetInstance().Increase("Sort"); lock (add_look_obj) { if (_currlength == 0) return; List<ChainNode> tosortlist = new List<ChainNode>(_currlength); var tempnode = _headNode; //var curr_first = _headNode; while (tempnode != null) { tosortlist.Add(ChainNode.ShallowClone(tempnode)); tempnode = tempnode.nextNode; } tosortlist.Sort((x, y) => { return y.accessCount - x.accessCount; }); //relink tosortlist[0].preNode = null; tosortlist[tosortlist.Count - 1].nextNode = null; tosortlist[0].accessCount = 0; tosortlist[tosortlist.Count - 1].accessCount = 0; if (tosortlist.Count > 1) { tosortlist[0].nextNode = tosortlist[1]; tosortlist[tosortlist.Count - 1].preNode = tosortlist[tosortlist.Count - 2]; } else { tosortlist[0].nextNode = null; tosortlist[tosortlist.Count - 1].preNode = null; } for (int i = 1; i < tosortlist.Count - 1; i++) { tosortlist[i].preNode = tosortlist[i - 1]; tosortlist[i].nextNode = tosortlist[i + 1]; tosortlist[i].accessCount = 0; } _tailNode = tosortlist[tosortlist.Count - 1]; _headNode = tosortlist[0]; } }
private bool InitAdd(Token t) { ApiInvokeMap.MapCore.GetInstance().Increase("InitAdd"); lock (add_look_obj) { if (_currlength != 0) return false; ChainNode nodeitem = new ChainNode(t); _headNode = nodeitem; _tailNode = nodeitem; _currlength = 1; return true; } }
private void Delete() { ApiInvokeMap.MapCore.GetInstance().Increase("Delete"); lock (add_look_obj) { if (_currlength == 0) return; if (_tailNode.preNode != null) { _tailNode.preNode.nextNode = null; _tailNode = _tailNode.preNode; _currlength--; } else { _currlength = 0; _headNode = null; _tailNode = null; } } }
private void BatchDelete() { ApiInvokeMap.MapCore.GetInstance().Increase("BatchDelete"); if (_tailNode != null) { ChainNode result_node = null; var tn = _tailNode; int r_count = 0; while (tn != null && !tn.used) { result_node = tn; tn = tn.preNode; r_count++; } if (result_node != null) { if (result_node.preNode != null) { lock (result_node.preNode) { result_node.preNode.nextNode = null; } _tailNode = result_node.preNode; } else { _tailNode = null; _headNode = null; } lock (result_node) { result_node.abort = true; _currlength -= r_count; } } } }