コード例 #1
0
        /// <summary>Debug print a <see cref="Node"/>.</summary>
        /// <remarks>
        /// Use a short hand syntax for well known dataTypes
        /// https://www.w3.org/TR/n-quads/
        /// </remarks>
        public static string Print(Node?node, bool includeId = true)
        {
            if (node is null)
            {
                return("null");
            }

            var txt = string.Empty;

            if (node is UriNode)
            {
                txt = $"<{node.ValueString}>";
            }

            if (node is BlankNode blank)
            {
                txt = $"_:{blank.Label} [blank]";
            }

            if (node is Node <Text> text)
            {
                txt = $"{text.Value.Value}@{text.Value.Language} [text]";
            }

            if (node is Node <bool> )
            {
                txt = $"{node.ValueString} [bool]";
            }

            if (node is Node <byte[]> )
            {
                txt = " ... [binary]";
            }

            if (node is Node <DateTime> )
            {
                txt = $"{node.ValueString} [datetime]";
            }

            if (node is Node <double> )
            {
                txt = $"{node.ValueString} [double]";
            }

            if (node is Node <int> intNode)
            {
                txt = $"{intNode.Value} [int]";
            }

            if (node.ValueType.DataType == XMLSchema.String)
            {
                txt = $"{node.ValueString} [literal]";
            }

            if (ObjectNodeMap.IsObjectType(node.ValueType.DataType))
            {
                txt = $"{node.ValueType.Native.Name} [object]";
            }

            if (txt == string.Empty)
            {
                txt = $"{node.ValueString}^^<{node.ValueType.DataType}>";
            }

            return(includeId ? txt + Id(node) : txt);
        }
コード例 #2
0
 private bool IsPrintableValue(Node node)
 {
     return(!(node.ValueString is null) &&
            !ObjectNodeMap.IsObjectType(node.ValueType.DataType));
 }