Example #1
0
        public void UsingPreBuiltTypes()
        {
            var f = new NodeFactory(TypedNodesHelpers.AllNodeMappings());

            //create bool from .net type
            var boolNode = f.New(true);

            Assert.AreEqual(XMLSchema.Boolean, boolNode.ValueType.DataType);

            //create from string data
            var intNode = (Node <int>)f.New("001", XMLSchema.Integer);

            Assert.AreEqual(1, intNode.Value);

            //same int from .net type
            var intNode2 = f.New(1);

            Assert.IsTrue(ReferenceEquals(intNode, intNode2));
        }
Example #2
0
 private static NodeMap[] MergeMappings(NodeMap[] customMappings)
 => customMappings.Union(
     TypedNodesHelpers.AllNodeMappings()
     .Where(x => customMappings.All(c => c.DataType != x.DataType))
     ).ToArray();
Example #3
0
 /// <summary>
 /// Create default factory; using all typed nodes.
 /// </summary>
 public NodeFactory()
     : this(TypedNodesHelpers.AllNodeMappings())
 {
 }