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); } }
public DomainId <IAstNode> CreateDate(string dateText) { var dateNode = new DateNode( m_ids.Next, dateText); return(DomainItemRegistration <IDateNode>(dateNode)); }
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); }
public Dictionary(int capacity) { if (capacity <= 0) { throw new InvalidOperationException("Capacity must be positive"); } size_ = capacity; data_ = new DateNode[size_]; }
public static TreeNode GetAllTypeNode() { TypeDateNode nodeType = new TypeDateNode(); nodeType.Text = nodeType.KNXMainNumber + "." + nodeType.KNXSubNumber + " " + nodeType.Name; nodeType.Nodes.Add(DateNode.GetTypeNode()); return(nodeType); }
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"); }
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); }
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"); }
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; } }
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 }); }
private Expression Build(DateNode node) { return(Expression.Constant(node.Value)); }
private Expression Build(DateNode node) => Constant(node.Value);