Ejemplo n.º 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)
            {
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 8
0
        public void RemoveTargetCheckbox(ChainNode targetNode)
        {
            var targetCheckbox = TargetsToTargetCheckboxes[targetNode];

            Destroy(targetCheckbox.gameObject);

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

            RemoveChainNodeView(node, true);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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]);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 15
0
        private void RemoveUniqueTarget(ChainNode targetNode)
        {
            RemoveTargetLabel(targetNode);

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

            UniqueTargetsChanged();
        }
Ejemplo n.º 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);
            }
Ejemplo n.º 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);
        }
Ejemplo n.º 18
0
        private void HandleStateTargetRemoved(SelectionState state, ChainNode target)
        {
            if (!TargetsToTargetCheckboxes.ContainsKey(target))
            {
                return;
            }

            var checkbox = TargetsToTargetCheckboxes[target];

            checkbox.Checked = false;

            UpdateCheckboxes();
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 23
0
        public void AddNode(ChainNode <TRequestContext> node)
        {
            if (firstChainNode == null)
            {
                firstChainNode = node;
                lastChainNode  = node;
            }
            else
            {
                lastChainNode.Successor = node;
                lastChainNode           = lastChainNode.Successor;
            }

            ++Count;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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];
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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]);
     }
 }
Ejemplo n.º 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++;
            }
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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];

            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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;
             }
         }
     }
 }