Esempio n. 1
0
        public void When_HandleHorizontalDirection_And_FocusNodeCanNotHaveChilds_And_ParentFailToReplaceNode_Then_DisposeNewlyCreatedNodeAndAbort()
        {
            // Arrange
            var focusNode = NodeHelper.CreateMockNode(direction: Direction.Vertical);
            var newParent = NodeHelper.CreateMockContainer();
            var screen    = NodeHelper.CreateMockScreen(callPostInit: false, childs: focusNode.Object);
            var sut       = CreateSut(containerCreater: out Mock <IContainerNodeCreater> containerCreater, focusTracker: out Mock <FocusTracker> focusTracker, childs: new ScreenNode[] { screen.Object });

            focusTracker.Setup(m => m.FocusNode()).Returns(focusNode.Object);
            focusNode.SetupGet(m => m.CanHaveChilds).Returns(false);
            containerCreater.Setup(m => m.Create(It.IsAny <RECT>(), It.IsAny <IRenderer>(), Direction.Horizontal, It.IsAny <Node>(), It.IsAny <Node[]>())).Returns(newParent.Object);
            focusNode.Object.Parent = screen.Object;
            screen.Setup(m => m.ReplaceNode(It.IsAny <Node>(), It.IsAny <Node>())).Returns(false);

            // Act
            sut.HandleHorizontalDirection();

            // Assert
            newParent.Verify(m => m.AddNodes(It.IsAny <Node>()), Times.Never);
            newParent.Verify(m => m.Dispose());
        }
Esempio n. 2
0
        public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax node)
        {
            var hasMatch = NodeHelper.HasMatch(node.AttributeLists, Constants.Data.PROPERTY_ATTRIBUTE_NAME, Constants.Data.PROPERTY_IGNORE_ATTRIBUTE_NAME);

            if (!hasMatch)
            {
                var name      = SyntaxFactory.ParseName(Constants.Data.PROPERTY_ATTRIBUTE_NAME);
                var arguments = SyntaxFactory.ParseAttributeArgumentList($"(Order = {_startIndex})");
                var attribute = SyntaxFactory.Attribute(name, arguments); //DataMember(Order = 1)

                node = TriviaMaintainer.Apply(node, (innerNode, wp) =>
                {
                    var newAttributes = BuildAttribute(attribute, innerNode.AttributeLists, wp);

                    return(innerNode.WithAttributeLists(newAttributes).WithAdditionalAnnotations(Formatter.Annotation));
                });
                _startIndex++;
            }

            return(base.VisitPropertyDeclaration(node));
        }
Esempio n. 3
0
        public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            //each class needs to restat with the
            _startIndex = CalculateStartingIndex(node);
            var hasMatch = NodeHelper.HasMatch(node.AttributeLists, Constants.Data.CLASS_ATTRIBUTE_NAME);

            if (!hasMatch)
            {
                var name      = SyntaxFactory.ParseName(Constants.Data.CLASS_ATTRIBUTE_NAME);
                var attribute = SyntaxFactory.Attribute(name);

                node = TriviaMaintainer.Apply(node, (innerNode, wp) =>
                {
                    var newAttributes = BuildAttribute(attribute, innerNode.AttributeLists, wp);

                    return(innerNode.WithAttributeLists(newAttributes).WithAdditionalAnnotations(Formatter.Annotation));
                });
            }

            return(base.VisitClassDeclaration(node));
        }
Esempio n. 4
0
        private XmlElement CreateItemInfo(XmlNode parent, int i, ref Item[] slots, string name)
        {
            Item       item = slots[i];
            XmlElement node1;

            if (item.type < Main.maxItemTypes)
            {
                node1 = (XmlElement)NodeHelper.CreateNode(XMLDoc, parent, name + "_" + i,
                                                          item.type.ToString());
            }
            else
            {
                node1 = (XmlElement)NodeHelper.CreateNode(XMLDoc, parent, name + "_" + i,
                                                          "$" + item.modItem.GetType().FullName);
            }
            foreach (var pair in ModDataHooks.ItemExtraInfoTable)
            {
                node1.SetAttribute(pair.Key, pair.Value(slots[i]));
            }
            return(node1);
        }
Esempio n. 5
0
        public void When_DisconnectChild_And_NodeIsFloating_And_NodeIsMyFocusNode_Then_UpdateMyFocusNodeToFirstScreen()
        {
            // Arrange
            var floatingNode = new Mock <Node>(new RECT(), Direction.Horizontal, null)
            {
                CallBase = true
            };
            var screenSut = NodeHelper.CreateMockScreen();
            var sut       = CreateSut(childs: new ScreenNode[] { screenSut.Object });

            sut.AddFloatingNode(floatingNode.Object);
            floatingNode.Object.SetFocus();

            sut.MyFocusNode.Should().Be(floatingNode.Object);

            // Act
            sut.DisconnectChild(floatingNode.Object);

            // Assert
            sut.MyFocusNode.Should().Be(screenSut.Object);
        }
Esempio n. 6
0
        public ActionResult Index(string type, string path)
        {
            var nodeId    = NodeHelper.GetNodeIdFromPath(path);
            var imageName = NodeHelper.GetNameFromPath(path);

            bool IsAdmin = db2.Users.Any(u => u.Name == User.Identity.Name && u.Roles.Contains("Admin"));

            List <Medium> media = new List <Medium>();

            if (IsAdmin)
            {
                media = db.Media.Where(e => e.NaviNode_Id == nodeId).ToList();
            }
            else
            {
                media = db.Media.Where(e => e.NaviNode_Id == nodeId && e.CreatedBy.Equals(System.Web.HttpContext.Current.User.Identity.Name.ToString())).ToList();
            }

            ViewBag.NodeId = nodeId;
            return(PartialView(media));
            //return View();
        }
Esempio n. 7
0
        private string GetReturnParameters()
        {
            var builder = new StringBuilder();

            var returnParameters = NodeHelper.GetReturnParameters(this.Node).ToList();

            if (!returnParameters.Any())
            {
                return(builder.ToString());
            }

            builder.Append("returns(");

            var returnList = returnParameters.Select(parameter => $"{parameter.Name} {parameter.TypeDescriptions.TypeString}".Trim()).ToList();

            builder.Append(string.Join(", ", returnList));

            builder.Append(")");


            return(builder.ToString());
        }
        public ControllerService()
        {
            this.scopeProvider = ConnectorContext.ScopeProvider;
            using (var scope = scopeProvider.CreateScope(autoComplete: true))
            {
                this.database = scope.Database;
                ApiKeyCache.UpdateCache(scope.Database);
            }
            this.userGroupService = new UserGroupService(ConnectorContext.UserService, database, ConnectorContext.Logger);
            this.languageService  = new LanguageDictionaryService(ConnectorContext.LocalizationService, ConnectorContext.DomainService, ConnectorContext.Logger);
            this.homeNode         = new HomeContentNode(ConnectorContext.ContentService, ConnectorContext.LocalizationService, ConnectorContext.DomainService, ConnectorContext.ContentTypeService, ConnectorContext.Logger);
            this.apiService       = new ApiKeysService(database);
            this.nodeHelper       = new NodeHelper();

            SaveAndPublish = bool.Parse(TenantGenerationOptions.SaveAndPublish);
            SecureUrls     = bool.Parse(TenantGenerationOptions.SecureUrls);
            SetupLocalUrls = bool.Parse(TenantGenerationOptions.SetupLocalUrls);

#if DEBUG
            SetupLocalUrls = true;
#endif
        }
Esempio n. 9
0
        public string Serialize(Contract contract, string template, List <Contract> contracts)
        {
            var builder = new StringBuilder();
            var nodes   = NodeHelper.GetEnumerators(contract).ToList();

            if (!nodes.Any())
            {
                return(template.Replace("{{Enumerators}}", builder.ToString()));
            }

            builder.Append($"## {I18N.Enums}");
            builder.Append(Environment.NewLine);

            foreach (var node in nodes)
            {
                var enumbuilder = new EnumeratorBuilder(node);
                builder.Append(enumbuilder.Build());
            }

            template = template.Replace("{{Enumerators}}", builder.ToString());
            return(template);
        }
Esempio n. 10
0
        public NodeChain(NodeTree nodeTree, Node startingNode)
        {
            Variables = nodeTree.Variables;

            nodeTree = GeneralMethods.CopyObject(nodeTree);

            NodeTreeName = nodeTree.Name;
            CurrentNode  = nodeTree.Nodes.FirstOrDefault(n => n.ID == startingNode.ID);
            if (CurrentNode == null)
            {
                throw new Exception("Error: Node chain could not find starting node.");
            }

            Name        = CurrentNode.NodeChainName;
            Nodes       = NodeHelper.GetChainAsNodes(CurrentNode, nodeTree);
            ReturnType  = ((StartNode)CurrentNode).ReturnType;
            IntValue    = 0;
            ObjectValue = null;
            Done        = false;
            InitRefs();
            Variables.ForEach(v => v.ResetValue());
        }
Esempio n. 11
0
        public SyntaxList<AttributeListSyntax> BuildAttribute(AttributeSyntax attribute,
                                                                SyntaxList<AttributeListSyntax> attributeLists,
                                                                SyntaxTrivia trailingWhitspace)
        {
            var newAttribute = NodeHelper.BuildAttributeList(attribute);

            newAttribute = (AttributeListSyntax)VisitAttributeList(newAttribute);

            if (attributeLists.Count > 0)
            {
                //Existing attribute cause the alignment to be off, this is the adjustment
                newAttribute = newAttribute.WithLeadingTrivia(trailingWhitspace);
                newAttribute = newAttribute.WithTrailingTrivia(SyntaxFactory.CarriageReturnLineFeed);
            }
            else
            {
                newAttribute = newAttribute.WithTrailingTrivia(SyntaxFactory.CarriageReturnLineFeed, trailingWhitspace);
            }

            newAttribute = newAttribute.WithAdditionalAnnotations(Formatter.Annotation);
            return attributeLists.Add(newAttribute);
        }
Esempio n. 12
0
        public string Serialize(Contract contract, string template, List <Contract> contracts)
        {
            var modifierNodes = NodeHelper.GetModifiers(contract).ToList();

            if (!modifierNodes.Any())
            {
                return(Clean(template));
            }

            var definitionList = new List <string>();
            var modifierList   = modifierNodes.Select(node => $"- [{node.Name}](#{node.Name.ToLower()})").ToList();


            template = template.Replace("{{ModifierTitle}}", $"## {I18N.Modifiers}");

            foreach (var node in modifierNodes)
            {
                string modifierTemplate = TemplateHelper.Modifier;
                string documentation    = node.Documentation;
                string description      = DocumentationHelper.GetNotice(documentation);

                var argumentBuilder = new ArgumentBuilder(documentation, node.Parameters.Parameters);
                var codeBuilder     = new ModifierCodeBuilder(node);

                modifierTemplate = modifierTemplate.Replace("{{ModifierArgumentsHeading}}", $"**{I18N.Arguments}**");
                modifierTemplate = modifierTemplate.Replace("{{TableHeader}}", TemplateHelper.TableHeader);
                modifierTemplate = modifierTemplate.Replace("{{ModifierNameHeading}}", $"### {node.Name}");
                modifierTemplate = modifierTemplate.Replace("{{ModifierDescription}}", description);
                modifierTemplate = modifierTemplate.Replace("{{ModifierCode}}", codeBuilder.Build());
                modifierTemplate = modifierTemplate.Replace("{{ModifierArguments}}", argumentBuilder.Build());

                definitionList.Add(modifierTemplate);
            }

            template = template.Replace("{{ModifierList}}", string.Join(Environment.NewLine, modifierList));
            template = template.Replace("{{AllModifiers}}", string.Join(Environment.NewLine, definitionList));

            return(template);
        }
Esempio n. 13
0
        public override SyntaxNode VisitEnumDeclaration(EnumDeclarationSyntax node)
        {
            if (node.AttributeLists.Count > 0)
            {
                var newAttributeLists = new SyntaxList <AttributeListSyntax>();
                foreach (var attributeList in node.AttributeLists)
                {
                    var nodesToRemove = attributeList.Attributes.Where(attribute => NodeHelper.AttributeNameMatches(attribute, Constants.Proto.BASE_PROP_NAME)).ToArray();

                    // If the lists are the same length, we are removing all attributes and can just avoid populating newAttributes.
                    if (nodesToRemove.Length != attributeList.Attributes.Count)
                    {
                        var newAttribute = (AttributeListSyntax)VisitAttributeList(attributeList.RemoveNodes(nodesToRemove, SyntaxRemoveOptions.KeepNoTrivia));
                        newAttributeLists = newAttributeLists.Add(newAttribute);
                    }
                }
                var leadTriv = node.GetLeadingTrivia();
                node = node.WithAttributeLists(newAttributeLists);
                node = node.WithLeadingTrivia(leadTriv);
            }
            return(base.VisitEnumDeclaration(node));
        }
Esempio n. 14
0
    public void UpdateUIButton()
    {
        NodeHelper.Find("WeaponSelect", gameObject).SetActive(GameStateMgr.Ins.gameStatus.EnableWeaponChoose);
        NodeHelper.Find("SfxMenu", gameObject).SetActive(GameStateMgr.Ins.gameStatus.EnableDebugSFX);
        NodeHelper.Find("Robot", gameObject).SetActive(GameStateMgr.Ins.gameStatus.EnableDebugRobot && !U3D.IsMultiplyPlayer());
        NodeHelper.Find("MiniMap", gameObject).SetActive(true);

        if (UGUIJoystick.Ins != null)
        {
            UGUIJoystick.Ins.SetJoyEnable(GameStateMgr.Ins.gameStatus.JoyEnable);
        }

        if (UGUIJoystick.Ins != null)
        {
            UGUIJoystick.Ins.SetAnchor(GameStateMgr.Ins.gameStatus.JoyAnchor);
        }

        Prev.gameObject.SetActive(U3D.WatchAi);
        Next.gameObject.SetActive(U3D.WatchAi);
        int j = 0;

        for (int i = 0; i < clickPanel.transform.childCount; i++)
        {
            Transform tri = clickPanel.transform.GetChild(i);
            if (tri.name == "Direction")
            {
                continue;
            }
            RectTransform r = tri.GetComponent <RectTransform>();
            if (GameStateMgr.Ins.gameStatus.HasUIAnchor[j])
            {
                r.anchoredPosition = GameStateMgr.Ins.gameStatus.UIAnchor[j];
            }
            float scale = GameStateMgr.Ins.gameStatus.UIScale[j];
            r.localScale = new Vector3(scale, scale, 1);
            j++;
        }
    }
        /// <summary></summary>
        protected override void AddNextNodeToCycle(IFocusCyclableNodeState state)
        {
            FocusInsertionChildNodeIndexList CycleIndexList = state.CycleIndexList;
            Node          ParentNode = state.ParentState.Node;
            IFocusIndex   NodeIndex  = state.ParentIndex;
            CycleBodyInfo Info       = new();

            List <Type> BodyTypeList = new List <Type>()
            {
                Type.FromTypeof <EffectiveBody>(), Type.FromTypeof <DeferredBody>(), Type.FromTypeof <ExternBody>(), Type.FromTypeof <PrecursorBody>()
            };

            foreach (IFocusInsertionChildNodeIndex Index in CycleIndexList)
            {
                Body Body = (Body)Index.Node;

                if (BodyTypeList.Contains(Type.FromGetType(Body)))
                {
                    BodyTypeList.Remove(Type.FromGetType(Body));
                }

                Info.Update(Body);
            }

            // If the list is full, no need to add more nodes to the cycle.
            if (BodyTypeList.Count > 0)
            {
                Type NodeType = BodyTypeList[0];
                Node NewBody  = NodeHelper.CreateInitializedBody(NodeType, Info.Documentation, Info.RequireBlocks, Info.EnsureBlocks, Info.ExceptionIdentifierBlocks, Info.EntityDeclarationBlocks, Info.BodyInstructionBlocks, Info.ExceptionHandlerBlocks, Info.AncestorType);

                IFocusBrowsingInsertableIndex InsertableNodeIndex = NodeIndex as IFocusBrowsingInsertableIndex;
                Debug.Assert(InsertableNodeIndex != null);
                IFocusInsertionChildNodeIndex InsertionIndex = InsertableNodeIndex.ToInsertionIndex(ParentNode, NewBody) as IFocusInsertionChildNodeIndex;
                Debug.Assert(InsertionIndex != null);

                CycleIndexList.Add(InsertionIndex);
            }
        }
Esempio n. 16
0
        public void When_TransferFocusNodeToDesktop_And_NodeIsFloating_And_EverythingGoOk_Then_UntrackNode()
        {
            // Arrange
            var floatingNode = new Mock <Node>(new RECT(), Direction.Horizontal, null)
            {
                CallBase = true
            };
            var screenSut   = NodeHelper.CreateMockScreen();
            var screenDest  = NodeHelper.CreateMockScreen();
            var sut         = CreateSut(focusTracker: out Mock <FocusTracker> focusTracker, childs: new ScreenNode[] { screenSut.Object });
            var destination = CreateMockSut(childs: new ScreenNode[] { screenDest.Object });

            sut.AddFloatingNode(floatingNode.Object);
            destination.Setup(m => m.AddNodes(floatingNode.Object)).Returns(true).Verifiable("AddNodes should be called when moving a node");
            focusTracker.Setup(m => m.FocusNode()).Returns(floatingNode.Object);
            sut.FloatingNodes.Should().Contain((floatingNode.Object));

            // Act
            sut.TransferFocusNodeToDesktop(destination.Object);

            // Assert
            focusTracker.Verify(m => m.Untrack(floatingNode.Object));
        }
        public string GenerateIfDef(NodeHelper <TranslatedMaterialGraph.NodeInfo> node)
        {
            ++_ifDefCount;
            var ifDefName   = "ifdef" + _ifDefCount;
            var a           = GenerateCode(node.InputPins[0]);
            var b           = GenerateCode(node.InputPins[1]);
            var pinTypeName = node.OutputPins[0].Type;
            var actualType  = GetType(pinTypeName);

            {
                _writer.WriteLine(node.Extra.Define.IfDefExpression,
                                  "// based on node " + node.Name + " " + node.Value + " (type:" + node.Type + ", id:" + node.Id +
                                  ")");
                _writer.WriteLine(node.Extra.Define.IfDefExpression, actualType + " " + ifDefName + " = " + a + ";");
            }
            {
                _writer.WriteLine(node.Extra.Define.IfNotDefExpression,
                                  "// based on node " + node.Name + " " + node.Value + " (type:" + node.Type + ", id:" + node.Id +
                                  ")");
                _writer.WriteLine(node.Extra.Define.IfNotDefExpression, actualType + " " + ifDefName + " = " + b + ";");
            }
            return(ifDefName);
        }
Esempio n. 18
0
        public void When_TransferFocusNodeToDesktop_And_NodeIsFloating_And_DisconnectChildReturnFalse_Then_Abort()
        {
            // Arrange
            var floatingNode = new Mock <Node>(new RECT(), Direction.Horizontal, null)
            {
                CallBase = true
            };
            var screenSut   = NodeHelper.CreateMockScreen();
            var screenDest  = NodeHelper.CreateMockScreen();
            var mockSut     = CreateMockSut(focusTracker: out Mock <FocusTracker> focusTracker, childs: new ScreenNode[] { screenSut.Object });
            var sut         = mockSut.Object;
            var destination = CreateMockSut(childs: new ScreenNode[] { screenDest.Object });

            sut.AddFloatingNode(floatingNode.Object);
            mockSut.Setup(m => m.DisconnectChild(floatingNode.Object)).Returns(false).Verifiable();
            focusTracker.Setup(m => m.FocusNode()).Returns(floatingNode.Object);

            // Act
            sut.TransferFocusNodeToDesktop(destination.Object);

            // Assert
            destination.Verify(m => m.AddNodes(It.IsAny <Node>()), Times.Never());
        }
Esempio n. 19
0
        public void When_HandleSwitchFloating_And_FocusNodeIsNotFloating_Then_ChangeItToFloating()
        {
            // Arrange
            var child = new Mock <Node>(new RECT(), Direction.Horizontal, null)
            {
                CallBase = true
            };
            var screen = NodeHelper.CreateMockScreen(direction: Direction.Vertical, callPostInit: false);
            var sut    = CreateSut(out Mock <FocusTracker> focusTracker, childs: new ScreenNode[] { screen.Object });

            screen.Object.PostInit(child.Object);
            focusTracker.Setup(m => m.FocusNode()).Returns(child.Object);
            child.Object.Style = NodeStyle.Tile;

            // Act
            sut.HandleSwitchFloating();

            // Assert
            screen.Verify(m => m.DisconnectChild(child.Object));
            child.VerifySet(m => m.Parent = sut);
            child.VerifySet(m => m.Style  = NodeStyle.Floating);
            sut.FloatingNodes.Should().Contain(child.Object);
        }
Esempio n. 20
0
        public ActionResult Children(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return(JsonError("node.children-- key is empty"));
            }

            try
            {
                var node = NodeHelper.GetCacheNode(key);

                var list = new List <NodeModel>();

                if (node == null)
                {
                    return(JsonSuccess(list));
                }

                for (var i = 0; i < node.ChildCount; i++)
                {
                    var child = node.Child(i);

                    if (child == null)
                    {
                        continue;
                    }

                    list.Add(child.To());
                }

                return(JsonSuccess(list));
            }
            catch (Exception e)
            {
                return(JsonError(e.Message));
            }
        }
Esempio n. 21
0
        private void CutOrDelete(IDataObject dataObject, out bool isDeleted)
        {
            isDeleted = false;

            IFocusNodeState      State       = StateView.State;
            IFocusBlockListInner ParentInner = State.PropertyToInner(PropertyName) as IFocusBlockListInner;

            Debug.Assert(ParentInner != null);

            Debug.Assert(StartIndex <= EndIndex);

            int OldBlockCount  = ParentInner.BlockStateList.Count;
            int SelectionCount = EndIndex - StartIndex;

            if (SelectionCount < ParentInner.BlockStateList.Count || !NodeHelper.IsCollectionNeverEmpty(State.Node, PropertyName))
            {
                if (dataObject != null)
                {
                    List <IBlock> BlockList = new List <IBlock>();
                    for (int i = StartIndex; i < EndIndex; i++)
                    {
                        IFocusBlockState BlockState = (IFocusBlockState)ParentInner.BlockStateList[i];
                        BlockList.Add(BlockState.ChildBlock);
                    }

                    ClipboardHelper.WriteBlockList(dataObject, BlockList);
                }

                FocusController Controller = StateView.ControllerView.Controller;
                Controller.RemoveBlockRange(ParentInner, StartIndex, EndIndex);

                Debug.Assert(ParentInner.BlockStateList.Count == OldBlockCount - SelectionCount);

                StateView.ControllerView.ClearSelection();
                isDeleted = true;
            }
        }
Esempio n. 22
0
        private NodePremise CreatePremise()
        {
            NodePremise genNodePremise(Tree_PremiseNode preNode, NodePremise lastPre)
            {
                NodePremise nodePremise = preNode.GetRuntimePremise(this);

                if (lastPre != null)
                {
                    lastPre.otherPremise = nodePremise;
                }
                return(nodePremise);
            }

            List <Tree_PremiseNode> nodes = NodeHelper.GetNodeOutNodes <Tree_PremiseNode>(Owner, this);

            if (nodes.Count <= 0)
            {
                return(null);
            }
            NodePremise startPremise = null;
            NodePremise premise      = null;

            for (int i = 0; i < nodes.Count; i++)
            {
                if (i == 0)
                {
                    startPremise = genNodePremise(nodes[i], null);
                    premise      = startPremise;
                }
                else
                {
                    Tree_PremiseNode nextPreNode = nodes[i];
                    premise = genNodePremise(nextPreNode, premise);
                }
            }
            return(startPremise);
        }
Esempio n. 23
0
        public void When_HandleSwitchFloating_And_ConvertingToFloatingNode_And_DisconnectChildReturnFalse_Then_Abort()
        {
            // Arrange
            var child = new Mock <Node>(new RECT(), Direction.Horizontal, null)
            {
                CallBase = true
            };
            var screen = NodeHelper.CreateMockScreen(direction: Direction.Vertical, callPostInit: false);
            var sut    = CreateSut(focusTracker: out Mock <FocusTracker> focusTracker, childs: new ScreenNode[] { screen.Object });

            screen.Object.PostInit(child.Object);
            focusTracker.Setup(m => m.FocusNode()).Returns(child.Object);
            child.Object.Style = NodeStyle.Tile;
            screen.Setup(m => m.DisconnectChild(child.Object)).Returns(false).Verifiable();

            // Act
            sut.HandleSwitchFloating();

            // Assert
            screen.VerifyAll();
            child.Object.Parent.Should().NotBeEquivalentTo(sut);
            child.Object.Style.Should().NotBe(NodeStyle.Floating);
            sut.FloatingNodes.Should().NotContain(child.Object);
        }
Esempio n. 24
0
        public ActionResult File(string path)
        {
            var   nodeId    = NodeHelper.GetNodeIdFromPath(path);
            var   fileName  = NodeHelper.GetNameFromPath(path);
            var   mediaList = _mediaRepo.GetAll().Where(e => e.NaviNodeId == nodeId && e.File.FileName.Equals(fileName, StringComparison.InvariantCultureIgnoreCase)).Select(e => e).ToList();
            Media m;

            if (mediaList.Count > 0)
            {
                m = mediaList[0];
            }
            else
            {
                return(new HttpNotFoundResult("File not found"));
            }

            if (!this.IsModified(m.Modified))
            {
                return(this.NotModified());
            }

            Response.AddHeader("Last-Modified", m.Modified.ToUniversalTime().ToString("R"));
            return(File(m.File.FileContent, m.File.FileType));
        }
Esempio n. 25
0
        /// <summary>
        /// Checks if a node can be simplified.
        /// </summary>
        /// <param name="inner">Inner to use to replace the node upon return.</param>
        /// <param name="index">Index of the simpler node upon return.</param>
        /// <returns>True if a node can be simplified at the focus.</returns>
        public virtual bool IsItemSimplifiable(out IFocusInner inner, out IFocusInsertionChildIndex index)
        {
            inner = null;
            index = null;

            bool IsSimplifiable = false;

            IFocusNodeState CurrentState = Focus.CellView.StateView.State;

            // Search recursively for a simplifiable node.
            while (CurrentState != null)
            {
                if (NodeHelper.GetSimplifiedNode(CurrentState.Node, out Node SimplifiedNode))
                {
                    if (SimplifiedNode != null)
                    {
                        Type InterfaceType = CurrentState.ParentInner.InterfaceType;
                        if (InterfaceType.IsAssignableFrom(Type.FromGetType(SimplifiedNode)))
                        {
                            IFocusBrowsingChildIndex ParentIndex = CurrentState.ParentIndex as IFocusBrowsingChildIndex;
                            Debug.Assert(ParentIndex != null);

                            inner          = CurrentState.ParentInner;
                            index          = ((IFocusBrowsingInsertableIndex)ParentIndex).ToInsertionIndex(inner.Owner.Node, SimplifiedNode) as IFocusInsertionChildIndex;
                            IsSimplifiable = true;
                        }
                    }

                    break;
                }

                CurrentState = CurrentState.ParentState;
            }

            return(IsSimplifiable);
        }
        private void MarkClusterNodes(NodeHelper <LayoutInfo> node, int clusterId)
        {
            node.Extra.ClusterId = clusterId;
            foreach (var link in node.EnumerateLinks())
            {
                if (link.From.Node.Extra.ClusterId == 0)
                {
                    MarkClusterNodes(link.From.Node, clusterId);
                }
                else if (link.From.Node.Extra.ClusterId != clusterId)
                {
                    throw new InvalidOperationException();
                }

                if (link.To.Node.Extra.ClusterId == 0)
                {
                    MarkClusterNodes(link.To.Node, clusterId);
                }
                else if (link.To.Node.Extra.ClusterId != clusterId)
                {
                    throw new InvalidOperationException();
                }
            }
        }
        /// <summary></summary>
        protected override void AddNextNodeToCycle(IFocusCyclableNodeState state)
        {
            FocusInsertionChildNodeIndexList CycleIndexList = state.CycleIndexList;
            Node             ParentNode = state.ParentState.Node;
            IFocusNodeIndex  NodeIndex  = state.ParentIndex as IFocusNodeIndex;
            CycleFeatureInfo Info       = new();

            List <Type> FeatureTypeList = new List <Type>()
            {
                Type.FromTypeof <AttributeFeature>(), Type.FromTypeof <ConstantFeature>(), Type.FromTypeof <CreationFeature>(), Type.FromTypeof <FunctionFeature>(), Type.FromTypeof <ProcedureFeature>(), Type.FromTypeof <PropertyFeature>(), Type.FromTypeof <IndexerFeature>()
            };

            foreach (IFocusInsertionChildNodeIndex Index in CycleIndexList)
            {
                Feature Feature = Index.Node as Feature;
                Debug.Assert(Feature != null);

                if (FeatureTypeList.Contains(Type.FromGetType(Feature)))
                {
                    FeatureTypeList.Remove(Type.FromGetType(Feature));
                }

                Info.Update(Feature);
            }

            // If the list is full, no need to add more nodes to the cycle.
            if (FeatureTypeList.Count > 0)
            {
                Type NodeType = FeatureTypeList[0];

                Node NewFeature = NodeHelper.CreateInitializedFeature(NodeType, Info.Documentation, Info.ExportIdentifier, Info.Export, Info.EntityName, Info.EntityType, Info.EnsureBlocks, Info.ConstantValue, Info.CommandOverloadBlocks, Info.Once, Info.QueryOverloadBlocks, Info.PropertyKind, Info.ModifiedQueryBlocks, Info.GetterBody, Info.SetterBody, Info.IndexParameterBlocks, Info.ParameterEnd);

                IFocusInsertionChildNodeIndex InsertionIndex = (IFocusInsertionChildNodeIndex)((IFocusBrowsingInsertableIndex)NodeIndex).ToInsertionIndex(ParentNode, NewFeature);
                CycleIndexList.Add(InsertionIndex);
            }
        }
        public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax node)
        {
            var hasMatch = NodeHelper.HasMatch(node.AttributeLists, Constants.Proto.PROPERTY_ATTRIBUTE_NAME, Constants.Proto.PROPERTY_IGNORE_ATTRIBUTE_NAME);

            if (!hasMatch)
            {
                var name      = SyntaxFactory.ParseName(Constants.Proto.PROPERTY_ATTRIBUTE_NAME);
                var arguments = SyntaxFactory.ParseAttributeArgumentList($"({_startIndex})");
                var attribute = SyntaxFactory.Attribute(name, arguments); //ProtoMember("1")

                node = TriviaMaintainer.Apply(node, (innerNode, wp) =>
                {
                    var newAttributes = BuildAttribute(attribute, innerNode.AttributeLists, wp);

                    return(innerNode.WithAttributeLists(newAttributes).WithAdditionalAnnotations(Formatter.Annotation));
                });

                _startIndex++;
            }
            else
            {
                //renumber
                if (node.AttributeLists.Count > 0)
                {
                    var newAttributeLists = new SyntaxList <AttributeListSyntax>();
                    foreach (var attributeList in node.AttributeLists)
                    {
                        var attributeSyntaxes = attributeList.Attributes.Where(attribute => NodeHelper.AttributeNameMatches(attribute, Constants.Proto.PROPERTY_ATTRIBUTE_NAME)).ToArray();

                        var modifiedAttributeList = attributeList.Attributes;
                        foreach (var attributeSyntax in attributeSyntaxes)
                        {
                            //The first is always the order value with a protoMember
                            var value = attributeSyntax.ArgumentList?.Arguments.FirstOrDefault();
                            if (value == null)
                            {
                                continue;
                            }
                            var newValueExpression  = SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(_startIndex));
                            var newvalue            = value.Update(null, null, newValueExpression);
                            var newSeparatedArgList = attributeSyntax.ArgumentList.Arguments.Replace(value, newvalue);

                            var newAttributeArgumentListSyntax = attributeSyntax.ArgumentList.WithArguments(newSeparatedArgList);
                            var newAttributeSyntax             = attributeSyntax.Update(attributeSyntax.Name, newAttributeArgumentListSyntax);
                            modifiedAttributeList = modifiedAttributeList.Replace(attributeSyntax, newAttributeSyntax);
                            _startIndex++;
                        }
                        newAttributeLists = newAttributeLists.Add(attributeList.WithAttributes(modifiedAttributeList));
                    }
                    var leadTriv = node.GetLeadingTrivia();
                    node = node.WithAttributeLists(newAttributeLists);
                    node = node.WithLeadingTrivia(leadTriv);
                }
            }

            return(base.VisitPropertyDeclaration(node));
        }
Esempio n. 29
0
        public override Node Evaluate(Env env)
        {
            var found    = false;
            var closures = env.FindRulesets(Selector);

            if (closures == null)
            {
                throw new ParsingException(Selector.ToCSS(env).Trim() + " is undefined", Index);
            }

            env.Rule = this;

            var rules = new NodeList();

            foreach (var closure in closures)
            {
                var ruleset = closure.Ruleset;

                if (!ruleset.MatchArguements(Arguments, env))
                {
                    continue;
                }

                found = true;

                if (ruleset is MixinDefinition)
                {
                    try
                    {
                        var mixin = ruleset as MixinDefinition;
                        rules.AddRange(mixin.Evaluate(Arguments, env, closure.Context).Rules);
                    }
                    catch (ParsingException e)
                    {
                        throw new ParsingException(e.Message, e.Index, Index);
                    }
                }
                else
                {
                    if (ruleset.Rules != null)
                    {
                        var nodes = new List <Node>(ruleset.Rules);
                        NodeHelper.ExpandNodes <MixinCall>(env, nodes);

                        rules.AddRange(nodes);
                    }
                }
            }

            env.Rule = null;

            if (!found)
            {
                var message = String.Format("No matching definition was found for `{0}({1})`",
                                            Selector.ToCSS(env).Trim(),
                                            StringExtensions.JoinStrings(Arguments.Select(a => a.ToCSS(env)), ", "));
                throw new ParsingException(message, Index);
            }

            return(rules);
        }
Esempio n. 30
0
 public SortedSet(IComparer <T> comparer)
 {
     this.helper = NodeHelper.GetHelper(comparer);
     this.tree   = new RBTree(this.helper);
 }