Beispiel #1
0
        /// <summary>Quads where Object is one of the literal values</summary>
        public static IEnumerable <Quad> IsValue(
            this IEnumerable <Quad> self,
            IBasicNodeFactory f,
            params string[] literals)
        {
            var nodes = literals.Select(x => f.New(x));

            return(self.Where(x => nodes.Contains(x.Object)));
        }
Beispiel #2
0
        /// <summary>
        /// Create Literal or Text or Typed-literal.
        /// </summary>
        public static Node NewNode(this IBasicNodeFactory self,
                                   ReadOnlySpan <char> valueString,
                                   ReadOnlySpan <char> dataType,
                                   ReadOnlySpan <char> language)
        {
            if (!dataType.IsEmpty && !language.IsEmpty)
            {
                throw new Exception("Cannot have both data type and language");
            }

            if (!language.IsEmpty)
            {
                return(self.New(new Text(
                                    new string(valueString),
                                    new string(language))));
            }

            if (!dataType.IsEmpty)
            {
                return(self.New(valueString, dataType));
            }

            return(self.New(valueString, XMLSchema.String));
        }
Beispiel #3
0
 /// <summary>
 /// Creates either a text node or literal node.
 /// </summary>
 public static Node TextOrLiteral(this IBasicNodeFactory self,
                                  ReadOnlySpan <char> value, ReadOnlySpan <char> language)
 => language.IsEmpty ? (Node)self.New(new string(value))
         : self.Text(value, language);
Beispiel #4
0
 /// <summary>
 /// Create a text node: a string literal with language.
 /// </summary>
 public static Node <Text> Text(this IBasicNodeFactory self,
                                ReadOnlySpan <char> text, ReadOnlySpan <char> language)
 => self.New(new Text(new string(text), new string(language)));
Beispiel #5
0
 public static Node <string> Literal(this IBasicNodeFactory self, ReadOnlySpan <char> value)
 => (Node <string>)self.New(value, XMLSchema.String);