Example #1
0
        public override Task InitializeAsync()
        {
            Active = false;
            LeafNodes.Add(1);

            return(base.InitializeAsync());
        }
Example #2
0
        public MerkleNode Add(ITimestamp proof)
        {
            var node = new MerkleNode(proof, HashAlgorithm);

            LeafNodes.Add(node);
            return(node);
        }
Example #3
0
        public List <RuleTreeNode <StyleData> > AddStyle(StyleRule rule, int importanceOffset = 0, bool mergeLayouts = false)
        {
            var added     = AddSelector(rule.SelectorText, importanceOffset);
            var addedList = added.ToList();

            foreach (var leaf in addedList)
            {
                var style = rule.Style;
                if (leaf.Data == null)
                {
                    leaf.Data = new StyleData();
                }
                var dic = RuleHelpers.GetRuleDic(style, false);
                leaf.Data.Rules.Add(dic);

                var lay = RuleHelpers.GetLayoutDic(style, false);
                if (lay != null)
                {
                    if (mergeLayouts)
                    {
                        leaf.Data.Rules.Add(lay.ToDictionary(x => x.prop.name, x => x.value));
                    }
                    else
                    {
                        leaf.Data.Layouts.AddRange(lay);
                    }
                }

                var importantDic = RuleHelpers.GetRuleDic(style, true);
                var importantLay = RuleHelpers.GetLayoutDic(style, true);
                if (importantDic.Count > 0 || importantLay != null)
                {
                    var importantLeaf = leaf.AddChildCascading("** !");
                    importantLeaf.Specifity = leaf.Specifity + RuleHelpers.ImportantSpecifity;
                    if (importantLeaf.Data == null)
                    {
                        importantLeaf.Data = new StyleData();
                    }
                    importantLeaf.Data.Rules.Add(importantDic);

                    if (importantLay != null)
                    {
                        if (mergeLayouts)
                        {
                            leaf.Data.Rules.Add(importantLay.ToDictionary(x => x.prop.name, x => x.value));
                        }
                        else
                        {
                            importantLeaf.Data.Layouts.AddRange(importantLay);
                        }
                    }

                    added.Add(importantLeaf);
                    LeafNodes.InsertIntoSortedList(importantLeaf);
                }
            }

            return(added);
        }
Example #4
0
 public void AddLeaf(DevInfo devInfo)
 {
     if (LeafNodes == null)
     {
         LeafNodes = new List <DevInfo>();
     }
     LeafNodes.Add(devInfo);
 }
Example #5
0
 internal void RefreshElementLeafViewModels()
 {
     LeafNodes.Clear();
     //foreach (var elementModel in PropModelServices.Instance().GetLeafNodes().Where(x => x.IsLightNode).OrderBy(x => x.Order))
     //{
     //	LeafNodes.Add(new ElementModelViewModel(elementModel, null));
     //}
     LeafNodes.AddRange(ElementModelLookUpService.Instance.GetAllModels().Where(x => x.IsLightNode).DistinctBy(x => x.ElementModel.Id).OrderBy(x => x.ElementModel.Order));
 }
Example #6
0
        /// <summary>
        /// Method to invoke when the ReverseSelected command is executed.
        /// </summary>
        private void ReverseSelected()
        {
            var workList = SelectedItems.ToList();
            int ctr      = 0;

            foreach (var elementModelViewModel in SelectedItems.Reverse().ToList())
            {
                LeafNodes.Remove(elementModelViewModel);
                LeafNodes.Insert(workList[ctr].ElementModel.Order - 1, elementModelViewModel);
                ctr++;
            }
            ReOrder();
        }
Example #7
0
        private void OnRemoveEdge(GraphEdge <T> edge)
        {
            edge.Sink.IncomingEdges.Remove(edge);
            edge.Source.OutgoingEdges.Remove(edge);

            if (edge.Sink.IsRootNode)
            {
                RootNodes.Add(edge.Sink);
            }

            if (edge.Source.IsLeafNode)
            {
                LeafNodes.Add(edge.Source);
            }
        }
Example #8
0
        private void OnRemoveNode(GraphNode <T> node)
        {
            RootNodes.Remove(node);
            var tempIncomingEdges = new List <GraphEdge <T> >(node.IncomingEdges);

            foreach (GraphEdge <T> incomingEdge in tempIncomingEdges)
            {
                RemoveEdge(incomingEdge);
            }

            LeafNodes.Remove(node);
            var tempOutgoingEdges = new List <GraphEdge <T> >(node.OutgoingEdges);

            foreach (GraphEdge <T> outgoingEdge in tempOutgoingEdges)
            {
                RemoveEdge(outgoingEdge);
            }
        }
Example #9
0
        /// <summary>
        /// Calculates hash values for the specified ordered data block collection and adds them to the tree.
        /// </summary>
        /// <param name="blocks">
        /// An ordered collection of data block objects to add to the hash tree.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="blocks" /> is <see langword="null" /> -or- <paramref name="blocks" /> contains a null data block object.
        /// </exception>
        /// <exception cref="SecurityException">
        /// An exception was raised during hashing or serialization.
        /// </exception>
        public void AddBlockRange(IEnumerable <TBlock> blocks)
        {
            if (blocks.Any() == false)
            {
                return;
            }

            using (var controlToken = StateControl.Enter())
            {
                var newNodes = blocks.RejectIf().IsNull(nameof(blocks)).TargetArgument.Select(block => CalculateHash(block.RejectIf().IsNull(nameof(blocks)).TargetArgument)).Select(hashValue => new HashTreeNode(hashValue));

                foreach (var node in newNodes)
                {
                    LeafNodes.Add(node);
                }

                PermuteRow(LeafNodes);
            }
        }
Example #10
0
        public void Select(IEnumerable <Guid> modelIds)
        {
            var modelsToSelect = LeafNodes.Where(x => modelIds.Contains(x.ElementModel.Id));

            modelsToSelect.ForEach(x => x.IsSelected = true);
        }
Example #11
0
        /// <summary>
        /// Gets the following state according the current state and input token.
        /// </summary>
        /// <param name="s">Current state.</param>
        /// <param name="t">Token to process.</param>
        /// <returns>If token is accepted by DFA then it returns the following state, otherwise it will returns a dead state.</returns>
        sealed protected override int DeltaTransition(int s, string t)
        {
            BTNode <Data> node;

            switch (t)
            {
            case "-":
            case "not":
                Sign = !Sign;
                return(_stateTable[s, (int)TokenType.SIGN]);

            case "(":
                OperatorsNodes.Push(new BTNode <Data>(new Data(Sign)));
                if (!Sign)
                {
                    Sign = true;
                }
                return(_stateTable[s, (int)TokenType.LB]);

            case ")":
                try
                {
                    Root       = OperatorsNodes.Pop();
                    Root.Right = LeafNodes.Pop();
                    Root.Left  = LeafNodes.Pop();
                    LeafNodes.Push(Root);
                }
                catch (InvalidOperationException)
                {
                    throw new InvalidOperationException("Parenthesis not balanced in expression.");
                }
                return(_stateTable[s, (int)TokenType.RB]);

            case "=>":
                node            = OperatorsNodes.Peek();
                node.Data.Value = t;
                if (!Sign)
                {
                    Sign = true;
                }
                return(_stateTable[s, (int)TokenType.THEN]);

            case "or":
                node            = OperatorsNodes.Peek();
                node.Data.Value = t;
                if (!Sign)
                {
                    Sign = true;
                }
                return(_stateTable[s, (int)TokenType.OR]);

            case "and":
                OperatorsNodes.Peek().Data.Value = t;
                if (!Sign)
                {
                    Sign = true;
                }
                return(_stateTable[s, (int)TokenType.AND]);

            default:
                if (!Regex.IsMatch(t, @"[a-zA-Z][a-zA-Z]*"))
                {
                    return(0);
                }
                LeafNodes.Push(new BTNode <Data>(new Data(Sign, t)));
                if (!Sign)
                {
                    Sign = true;
                }
                return(_stateTable[s, (int)TokenType.ATOM]);
            }
        }
Example #12
0
 private void OnAddNode(GraphNode <T> node)
 {
     RootNodes.Add(node);
     LeafNodes.Add(node);
 }