예제 #1
0
        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)
            {
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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);
        }
예제 #5
0
 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);
     }
 }
예제 #6
0
        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;
                }
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        public void RemoveTargetCheckbox(ChainNode targetNode)
        {
            var targetCheckbox = TargetsToTargetCheckboxes[targetNode];

            Destroy(targetCheckbox.gameObject);

            TargetsToTargetCheckboxes.Remove(targetNode);
        }
예제 #9
0
 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;
 }
예제 #10
0
        private void HandleGroupNodeRemoved(ChainNode node, bool isTransfer)
        {
            if (isTransfer)
            {
                return;
            }

            RemoveChainNodeView(node, true);
        }
예제 #11
0
 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;
 }
예제 #12
0
        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]);
        }
예제 #13
0
        private void AddChainNodeView(ChainNode chainNode)
        {
            var viewGo = Instantiate(NodeViewPrefab, NodeAttachmentPoint);
            var view   = viewGo.GetComponent <ChainNodeView>();

            view.ChainNode = chainNode;

            //view.Expanded = true;

            AddChainNodeView(view);
        }
예제 #14
0
 /// <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);
 }
예제 #15
0
        private void RemoveUniqueTarget(ChainNode targetNode)
        {
            RemoveTargetLabel(targetNode);

            foreach (var stateView in StateViews)
            {
                stateView.RemoveTargetCheckbox(targetNode);
            }

            UniqueTargetsChanged();
        }
예제 #16
0
            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);
            }
예제 #17
0
        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);
        }
예제 #18
0
        private void HandleStateTargetRemoved(SelectionState state, ChainNode target)
        {
            if (!TargetsToTargetCheckboxes.ContainsKey(target))
            {
                return;
            }

            var checkbox = TargetsToTargetCheckboxes[target];

            checkbox.Checked = false;

            UpdateCheckboxes();
        }
예제 #19
0
        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);
            }
        }
예제 #20
0
        private void HandleGroupNodeAdded(ChainNode node, bool isTransfer)
        {
            if (isTransfer)
            {
                return;
            }

            AddChainNodeView(node);

            if (!node.SuppressUndos)
            {
                UndoLord.Instance.Push(new NodeAdd(node, this, NewNodePosition));
            }
        }
예제 #21
0
        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();
        }
예제 #22
0
        private void RemoveTargetLabel(ChainNode targetNode)
        {
            var label = TargetLabels.FirstOrDefault(l => l.Target == targetNode);

            if (label == null)
            {
                return;
            }

            TargetLabels.Remove(label);

            Destroy(label.gameObject);

            IndexAndPositionTargetLabels();
        }
예제 #23
0
        public void AddNode(ChainNode <TRequestContext> node)
        {
            if (firstChainNode == null)
            {
                firstChainNode = node;
                lastChainNode  = node;
            }
            else
            {
                lastChainNode.Successor = node;
                lastChainNode           = lastChainNode.Successor;
            }

            ++Count;
        }
예제 #24
0
        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);
        }
예제 #25
0
 /// <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);
 }
예제 #26
0
        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));
        }
예제 #27
0
        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];
            }
        }
예제 #28
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);
        }
예제 #29
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);
            }
        }
예제 #30
0
 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]);
     }
 }
예제 #31
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++;
            }
        }
예제 #32
0
 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;
 }
예제 #33
0
        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];

            }
        }
예제 #34
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;
            }
        }
예제 #35
0
        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;
                }
            }
        }
예제 #36
0
 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;
             }
         }
     }
 }