Exemplo n.º 1
0
        /// <summary>
        /// Quads that are uri's
        /// </summary>
        public static IEnumerable <Quad> IsValueUri(
            this IEnumerable <Quad> self,
            IBasicNodeFactory f, IEnumerable <string> uris)
        {
            var nodes = uris.Select(x => f.Uri(x));

            return(self.Where(x => nodes.Contains(x.Object)));
        }
Exemplo n.º 2
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)));
        }
Exemplo n.º 3
0
        /// <summary>Quads With a Predicate</summary>
        public static IEnumerable <Quad> With(
            this IEnumerable <Quad> self,
            IBasicNodeFactory f,
            IEnumerable <string> uriValues)
        {
            var nodes = uriValues.Select(x => f.Uri(x));

            return(self.Where(x => nodes.Contains(x.Predicate)));
        }
Exemplo n.º 4
0
        /// <summary>Quads For a URI Subject(s) </summary>
        public static IEnumerable <Quad> For(
            this IEnumerable <Quad> self,
            IBasicNodeFactory f,
            params string[] uriSubjects)
        {
            var nodes = uriSubjects.Select(x => f.Uri(x));

            return(self.Where(x => nodes.Contains(x.Subject)));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Quads where <see cref="Quad.Object"/> is
        /// <see cref="Text"/> with specified language.
        /// </summary>
        public static IEnumerable <Quad> IsTypeTextLang(
            this IEnumerable <Quad> self,
            IBasicNodeFactory f,
            params string[] language)
        {
            var nodes = language.Select(x => f.Text("", x));

            return(self.Where(x =>
                              x.Object is Node <Text> txt &&
                              nodes.Any(v => v.Value.Language == txt.Value.Language)));
        }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
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);
Exemplo n.º 8
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)));
Exemplo n.º 9
0
 public static Node <string> Literal(this IBasicNodeFactory self, ReadOnlySpan <char> value)
 => (Node <string>)self.New(value, XMLSchema.String);
Exemplo n.º 10
0
 /// <summary>
 /// Create new <see cref="UriNode"/> from <see cref="Uri"/>.
 /// </summary>
 public static UriNode Uri(this IBasicNodeFactory self, Uri uri)
 => self.Uri(uri.ToString());