Ejemplo n.º 1
0
        public override IOrder GetNewOrder()
        {
            var order = base.GetNewOrder() as NodeOrder;

            orderRoot.Add(order);
            return(order);
        }
Ejemplo n.º 2
0
        public void CreateNodeAndAddLeftAndRightValues()
        {
            var expected = 10;

            _sut = new Node <int>(expected);
            _sut.Add(20);
            _sut.Add(1);
            Assert.Equal(expected, _sut.Value);
            Assert.True(_sut.RightIsPopulated);
            Assert.True(_sut.RightIsPopulated);
        }
Ejemplo n.º 3
0
        public void CreateNodeAndAddTwoLeftsAndRighttShouldBeNull()
        {
            var expected = 10;

            _sut = new Node <int>(expected);
            _sut.Add(5);
            _sut.Add(1);
            Assert.Equal(expected, _sut.Value);
            Assert.True(_sut.LeftIsPopulated);
            Assert.False(_sut.RightIsPopulated);
        }
Ejemplo n.º 4
0
 public void GetLastBlock()
 {
     foreach (var other in others)
     {
         var block = channel.GetLastBlock(other.PublicUrl);
         if (block != null)
         {
             node.Add(block);
             other.LastActivity = DateTimeOffset.UtcNow;
         }
     }
 }
Ejemplo n.º 5
0
        public void AddValuesAndFindhighetValue()
        {
            var seed            = 20;
            var expectedLeft    = 10;
            var expectedRight   = 30;
            var expectedHighest = 300;

            _sut = new Node <int>(seed);
            _sut.Add(expectedLeft);
            _sut.Add(expectedRight);
            _sut.Add(expectedHighest);
            var actualLowest = _sut.GetHighest();

            Assert.Equal(expectedHighest, actualLowest.Value);
        }
Ejemplo n.º 6
0
        public void GetSortedListDescending()
        {
            var         expected = new int[] { 5, 4, 3, 2, 1 };
            IList <int> actual   = new List <int>();

            _sut = new Node <int>(2);
            _sut.Add(5);
            _sut.Add(1);
            _sut.Add(3);
            _sut.Add(4);

            _sut.GetSortedDescending(actual);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 7
0
        public void GetSortedList()
        {
            var         expected = new int[] { 1, 2, 3, 4, 5 };
            IList <int> actual   = new List <int>();

            _sut = new Node <int>(2);
            _sut.Add(5);
            _sut.Add(1);
            _sut.Add(3);
            _sut.Add(4);

            _sut.GetSorted(actual);

            Assert.Equal(expected, actual);
        }
        public ObjectResult Post(Document model)
        {
            logger.LogInformation($"Recibiendo document: {JsonSerializer.Serialize(model)} desde '{Request?.HttpContext?.Connection?.RemoteIpAddress}:{Request?.HttpContext?.Connection?.RemotePort}'");

            node.Add(model);
            return(Accepted(model));
        }
Ejemplo n.º 9
0
        public static INode Add <T>(this INode that) where T : INode
        {
            var ne = Activator.CreateInstance <T>();

            that.Add(ne);
            return(that);
        }
Ejemplo n.º 10
0
 public static void Add(this INode node, NodeType type, Metadata metadata, Action <INode> modify)
 {
     node.Add(new Node(metadata: metadata)
     {
         NodeType = type
     }, modify);
 }
Ejemplo n.º 11
0
        public ObjectResult Post(Block block)
        {
            logger.LogInformation($"Recibiendo block: {JsonSerializer.Serialize(block)} desde '{Request?.HttpContext?.Connection?.RemoteIpAddress}:{Request?.HttpContext?.Connection?.RemotePort}'");

            node.Add(block);
            //var url = Url.Action("Get", new {id = block.Hash});
            return(Accepted(block));
        }
        public ObjectResult Post(Question question)
        {
            logger.LogInformation($"Recibiendo question: {JsonSerializer.Serialize(question)} desde '{Request?.HttpContext?.Connection?.RemoteIpAddress}:{Request?.HttpContext?.Connection?.RemotePort}'");

            node.Add(question);
            //var url = Url.Action("Get", new { communityId = question.CommunityId, questionId = question.Id });
            return(Accepted(question));
        }
Ejemplo n.º 13
0
        public void AddRightAndLeftValueAndFindAll()
        {
            var seed          = 20;
            var expectedLeft  = 10;
            var expectedRight = 30;

            _sut = new Node <int>(seed);
            _sut.Add(expectedLeft);
            _sut.Add(expectedRight);
            var actualSeed  = _sut.Find(seed);
            var actualLeft  = _sut.Find(expectedLeft);
            var actualRight = _sut.Find(expectedRight);

            Assert.Equal(seed, actualSeed.Value);
            Assert.Equal(expectedLeft, actualLeft.Value);
            Assert.Equal(expectedRight, actualRight.Value);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Ands one <see cref="INode"/> as a child of another <see cref="INode"/>.
        /// </summary>
        /// <param name="node">The <see cref="INode"/> to add.</param>
        /// <param name="parent">The <see cref="INode"/> to attach the given child <see cref="INode"/> to.</param>
        /// <remarks>
        /// If the parent <see cref="INode"/> is already in the scene graph, the <see cref="INode"/> being attached will
        /// have itself and its children added to the lookup tables.
        /// </remarks>
        public void AddNode(INode node, INode parent)
        {
            parent.Add(node);

            if (_NodeIdLookup.ContainsKey(parent.Id))
            {
                AddNodeToLookup(node);
            }
        }
Ejemplo n.º 15
0
        public ObjectResult Post(Vote vote)
        {
            logger.LogInformation($"Recibiendo vote {JsonSerializer.Serialize(vote)}");

            node.Add(vote);

            //var url = Url.Action("Get", new {questionId = vote.QuestionId, publicKey = vote.PublicKey});
            return(Accepted(vote));
        }
Ejemplo n.º 16
0
        public ObjectResult Post(Member member)
        {
            logger.LogInformation($"Recibiendo member: {JsonSerializer.Serialize(member)} desde '{Request?.HttpContext?.Connection?.RemoteIpAddress}:{Request?.HttpContext?.Connection?.RemotePort}'");

            node.Add(member);

            //var url = Url.Action("List", new { communityId = member.CommunityId, memberId = member.Id });
            return(Accepted(member));
        }
Ejemplo n.º 17
0
        public ObjectResult Post(Community model)
        {
            logger.LogInformation($"Recibiendo comunidad: {JsonSerializer.Serialize(model)} desde '{Request?.HttpContext?.Connection?.RemoteIpAddress}:{Request?.HttpContext?.Connection?.RemotePort}'");

            node.Add(model);

            //var url = Url.Action("Get", new {id = model.Id});
            return(Accepted(model));
        }
Ejemplo n.º 18
0
 protected AbstractNode(INode parent, string name, string fullName)
 {
     this.parent = parent;
     this.name = name;
     this.fullName = fullName;
     if (parent != null)
     {
         parent.Add(this);
     }
 }
Ejemplo n.º 19
0
 public AbstractNode(INode parent, String name, String fullName)
 {
     this.parent = parent;
     this.name = name;
     this.fullName = fullName;
     if (parent != null)
     {
         parent.Add(this);
     }
 }
Ejemplo n.º 20
0
 protected AbstractNode(INode parent, string name, string fullName)
 {
     this.parent   = parent;
     this.name     = name;
     this.fullName = fullName;
     if (parent != null)
     {
         parent.Add(this);
     }
 }
Ejemplo n.º 21
0
 public AbstractNode(INode parent, String name, String fullName)
 {
     this.parent   = parent;
     this.name     = name;
     this.fullName = fullName;
     if (parent != null)
     {
         parent.Add(this);
     }
 }
        public ObjectResult Post(Recount recount)
        {
            logger.LogInformation("Recount: " + JsonSerializer.Serialize(recount, JsonDefaultSettings.Options));

            node.Add(recount);

            var url = Url.Action("Get", new { urnId = recount.UrnId });

            return(Created(url, recount));
        }
Ejemplo n.º 23
0
        private static void AddChildrenNodesInNode(INode node, int start, int end, IEnumerable <TagZone> list,
                                                   string line)
        {
            var last = start;

            foreach (var el in list)
            {
                if (el.Start - last != 0)
                {
                    node.Add(new TextNode(line.Substring(last, el.Start - last)));
                }
                last = el.End;
                node.Add(el.TagNode);
            }

            if (end - last != 0)
            {
                node.Add(new TextNode(line.Substring(last, end - last)));
            }
        }
Ejemplo n.º 24
0
        public void AddLeftValueAndFindIt()
        {
            var seed     = 20;
            var expected = 10;

            _sut = new Node <int>(seed);
            _sut.Add(expected);
            var actual = _sut.Find(expected);

            Assert.Equal(expected, actual.Value);
        }
Ejemplo n.º 25
0
        public void AddRightValueAndFindBoth()
        {
            var seed     = 10;
            var expected = 20;

            _sut = new Node <int>(seed);
            _sut.Add(expected);
            var actual     = _sut.Find(expected);
            var actualSeed = _sut.Find(seed);

            Assert.Equal(expected, actual.Value);
            Assert.Equal(seed, actualSeed.Value);
        }
Ejemplo n.º 26
0
 public AbstractNode(INode parent, String name, String fullName)
 {
     this.parent = parent;
     this.name = name;
     this.fullName = fullName;
     if (parent != null)
     {
         if (name.Length == 0)
         {
             throw new ArgumentException(
                 "Zero length child name means bad news");
         }
         parent.Add(this);
     }
 }
Ejemplo n.º 27
0
 public AbstractNode(INode parent, String name, String fullName)
 {
     this.parent   = parent;
     this.name     = name;
     this.fullName = fullName;
     if (parent != null)
     {
         if (name.Length == 0)
         {
             throw new ArgumentException(
                       "Zero length child name means bad news");
         }
         parent.Add(this);
     }
 }
Ejemplo n.º 28
0
 public static INode AddBlogPage(this INode that, string id = "")
 {
     that.Add(new Page()
     {
         Id   = id,
         Name = "Blogpost"
     }.Add(new Image()
     {
         Path = "/image.jpg"
     }).Add(new Text()
     {
         Value = "Blog title"
     }).Add(new Text()
     {
         Value = "Blog text, lorem ipsum"
     }));
     return(that);
 }
Ejemplo n.º 29
0
        private INode AddParamsToItem(XElement elem, INode node)
        {
            elem.Elements().ToList().ForEach(i =>
            {
                if (i.Name.LocalName == CFG_PARAMNODE)
                {
                    node.Add(new param
                    {
                        dependon = i.Attribute(ATTRI_DEPEND) != null ? i.Attribute(ATTRI_DEPEND).Value : string.Empty,
                        Name     = i.Attribute(ATTRI_NAME) != null ? i.Attribute(ATTRI_NAME).Value : string.Empty,
                        Type     = i.Attribute(ATTRI_TYPE) != null ? this.GetAssType(i.Attribute(ATTRI_TYPE).Value) : null,
                        value    = i.Attribute(ATTRI_VALUE) != null ? i.Attribute(ATTRI_VALUE).Value : string.Empty
                    });
                }
            });

            return(node);
        }
Ejemplo n.º 30
0
        public ITransient ActionSequence(params Action[] actions)
        {
            INode      seq  = Node();
            IGenerator prev = null;

            foreach (var act in actions)
            {
                var tr = Do(act);
                if (prev != null)
                {
                    tr.ResumeAfter(prev);
                }

                seq.Add(tr);
                prev = tr;
            }

            return(Prepare(seq));
        }
Ejemplo n.º 31
0
            public void Add(char[] word, int start)
            {
                if (word.Length - start <= 0)
                {
                    End = true;
                    return;
                }

                char c = word[start];

                if (NextNode == null)
                {
                    NextChar = c;
                    if (word.Length - start == 1)
                    {
                        NextNode = new TerminalNode();
                    }
                    else if (word.Length - start < 3)
                    {
                        NextNode = new SingleChildNode();
                    }
                    else
                    {
                        NextNode = new PNode(word, start + 1);
                    }
                }
                else if (NextChar != c)
                {
                    throw new MustBeSplitException();
                }

                try
                {
                    NextNode.Add(word, start + 1);
                }
                catch (MustBeSplitException)
                {
                    NextNode = NextNode.Split();
                    Add(word, start);
                }
            }
Ejemplo n.º 32
0
 public static INode Add(this INode that, INode node, IDictionary <string, object> data)
 {
     that.Add(node.Apply(data));
     return(that);
 }
Ejemplo n.º 33
0
        private INode AddParamsToItem(XElement elem, INode node)
        {
            elem.Elements().ToList().ForEach(i =>
            {
                if (i.Name.LocalName == CFG_PARAMNODE)
                    node.Add(new param
                    {
                        dependon = i.Attribute(ATTRI_DEPEND) != null ? i.Attribute(ATTRI_DEPEND).Value : string.Empty,
                        Name = i.Attribute(ATTRI_NAME) != null ? i.Attribute(ATTRI_NAME).Value : string.Empty,
                        Type = i.Attribute(ATTRI_TYPE) != null ? this.GetAssType(i.Attribute(ATTRI_TYPE).Value) : null,
                        value = i.Attribute(ATTRI_VALUE) != null ? i.Attribute(ATTRI_VALUE).Value : string.Empty
                    });
            });

            return node;
        }
Ejemplo n.º 34
0
 public ObjectResult Post(Urn urn)
 {
     node.Add(urn);
     //var url = Url.Action("Get", new { communityId = urn.QuestionId, UrnId = urn.Id });
     return(Accepted(urn));
 }