Exemplo n.º 1
0
        public Dictionary(IEnumerable <TKey> keys, IEnumerable <TElement> elements, int?size = null)
        {
            if (size == null)
            {
                size_ = keys.Count();
                if (size_ != elements.Count())
                {
                    throw new ArgumentException("Arguments have different size");
                }
            }
            else
            {
                size_ = size.Value;
            }
            data_ = new DateNode[size_];
            IEnumerator <TKey>     keysEnumerator     = keys.GetEnumerator();
            IEnumerator <TElement> elementsEnumerator = elements.GetEnumerator();

            for (int i = 0; i < size_; i++)
            {
                elementsEnumerator.MoveNext();
                keysEnumerator.MoveNext();
                Add(keysEnumerator.Current, elementsEnumerator.Current);
            }
        }
Exemplo n.º 2
0
        public DomainId <IAstNode> CreateDate(string dateText)
        {
            var dateNode = new DateNode(
                m_ids.Next,
                dateText);

            return(DomainItemRegistration <IDateNode>(dateNode));
        }
Exemplo n.º 3
0
        public void Deserialize_String_Test()
        {
            DateTime source = DateTime.MaxValue;
            var      node   = new DateNode(source);
            var      res    = _deserializer.Deserialize <DateTime>(node);

            Assert.That(res, Is.TypeOf <DateTime>());
            Assert.AreEqual(source, res);
        }
Exemplo n.º 4
0
 public Dictionary(int capacity)
 {
     if (capacity <= 0)
     {
         throw new InvalidOperationException("Capacity must be positive");
     }
     size_ = capacity;
     data_ = new DateNode[size_];
 }
Exemplo n.º 5
0
        public static TreeNode GetAllTypeNode()
        {
            TypeDateNode nodeType = new TypeDateNode();

            nodeType.Text = nodeType.KNXMainNumber + "." + nodeType.KNXSubNumber + " " + nodeType.Name;

            nodeType.Nodes.Add(DateNode.GetTypeNode());

            return(nodeType);
        }
Exemplo n.º 6
0
        public TElement Get(TKey key)
        {
            DateNode lastNode = data_[Hash(key)];

            while (lastNode != null)
            {
                if (lastNode.Key.Equals(key))
                {
                    return(lastNode.Element);
                }
                lastNode = lastNode.Next;
            }

            throw new IndexOutOfRangeException("Not Found");
        }
Exemplo n.º 7
0
        public void DateNodeTest()
        {
            StreamLocation expectedLocation = new StreamLocation(3, 2, 1);
            DateTime testDate = new DateTime(2013, 10, 3);

            DateNode sut = new DateNode(testDate.Year.ToString(), testDate.Month.ToString(), testDate.Day.ToString(), expectedLocation);

            Assert.AreEqual(TNode.DATE, sut.NodeType);
            Assert.AreEqual(expectedLocation, sut.Location);
            Assert.IsTrue(sut.Description.Contains("DATE"));
            Assert.AreEqual(FieldValueType.DATE, sut.ValueType);

            Assert.AreEqual(ExpressionType.Constant, sut.SubExpression.NodeType);
            Assert.IsInstanceOfType(sut.SubExpression, typeof(ConstantExpression));
            Assert.AreEqual(typeof(DateTime?), ((ConstantExpression)sut.SubExpression).Type);
            Assert.AreEqual(testDate, ((ConstantExpression)sut.SubExpression).Value);
        }
Exemplo n.º 8
0
        public void Remove(TKey key)
        {
            DateNode lastNode = data_[Hash(key)];

            while (lastNode != null)
            {
                if (lastNode.Next.Key.Equals(key))
                {
                    lastNode.Next = lastNode.Next.Next;
                    return;
                }
                else
                {
                    lastNode = lastNode.Next;
                }
            }

            throw new InvalidOperationException("Element Not Found");
        }
Exemplo n.º 9
0
        public void Add(TKey key, TElement element)
        {
            int      hKey    = Hash(key);
            DateNode newNode = new DateNode(key, element);

            if (data_[hKey] == null)
            {
                data_[hKey] = newNode;
            }
            else
            {
                DateNode lastNode = data_[hKey];
                while (lastNode.Next != null)
                {
                    lastNode = lastNode.Next;
                }
                lastNode.Next = newNode;
            }
        }
Exemplo n.º 10
0
        public void RateDateEdge()
        {
            var jan1 = new DateNode(new Date(2016, 1, 1));
            var jan2 = new DateNode(new Date(2016, 1, 2));
            var jan3 = new DateNode(new Date(2016, 1, 3));

            var dbl = new RateNode("DBL");
            var sgl = new RateNode("SGL");

            new RateForDateEdge(dbl, jan1);
            new RateForDateEdge(dbl, jan2);
            new RateForDateEdge(sgl, jan2);
            new RateForDateEdge(sgl, jan3);

            CollectionAssert.AreEquivalent(dbl.Dates.Select(e => e.Date), new[] { jan1, jan2 });
            CollectionAssert.AreEquivalent(sgl.Dates.Select(e => e.Date), new[] { jan2, jan3 });
            CollectionAssert.AreEquivalent(jan1.Rates.Select(e => e.Rate), new[] { dbl });
            CollectionAssert.AreEquivalent(jan2.Rates.Select(e => e.Rate), new[] { sgl, dbl });
            CollectionAssert.AreEquivalent(jan3.Rates.Select(e => e.Rate), new[] { sgl });
        }
Exemplo n.º 11
0
 private Expression Build(DateNode node)
 {
     return(Expression.Constant(node.Value));
 }
Exemplo n.º 12
0
 private Expression Build(DateNode node) => Constant(node.Value);