Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
InMemorySemanticModel.cs
1using System;
4using System.Numerics;
13
15{
20 {
25
26 #region Constructors
27
32 {
33 this.triples = new ChunkedList<ISemanticTriple>();
34 }
35
40 public InMemorySemanticModel(IEnumerable<ISemanticTriple> Triples)
41 {
42 this.triples = Triples as ChunkedList<ISemanticTriple>;
43
44 if (this.triples is null)
45 {
46 this.triples = new ChunkedList<ISemanticTriple>();
47
48 foreach (ISemanticTriple Triple in Triples)
49 this.triples.Add(Triple);
50 }
51 }
52
53 #endregion
54
55 #region Enumerators
56
61 public IEnumerator<ISemanticTriple> GetEnumerator()
62 {
63 return this.triples.GetEnumerator();
64 }
65
70 IEnumerator IEnumerable.GetEnumerator()
71 {
72 return this.triples.GetEnumerator();
73 }
74
75 #endregion
76
77 #region Adding triples
78
85 public void Add(ISemanticElement Subject, Uri Predicate, Uri Object)
86 {
87 this.Add(Subject, new UriNode(Predicate), new UriNode(Object));
88 }
89
96 public void Add(ISemanticElement Subject, Uri Predicate, ISemanticElement Object)
97 {
98 this.Add(Subject, new UriNode(Predicate), Object);
99 }
100
107 public void Add(ISemanticElement Subject, Uri Predicate, object Object)
108 {
109 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
111 }
112
119 public void Add(ISemanticElement Subject, Uri Predicate, string Object)
120 {
121 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
122 new StringLiteral(Object)));
123 }
124
132 public void Add(ISemanticElement Subject, Uri Predicate, string Object, string Language)
133 {
134 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
135 new StringLiteral(Object, Language)));
136 }
137
145 public void Add(ISemanticElement Subject, Uri Predicate, string Object, Uri Type)
146 {
147 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
148 new CustomLiteral(Object, Type)));
149 }
150
159 public void Add(ISemanticElement Subject, Uri Predicate, string Object, Uri Type,
160 string Language)
161 {
162 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
163 new CustomLiteral(Object, Type, Language)));
164 }
165
172 public void Add(ISemanticElement Subject, Uri Predicate, DateTime Object)
173 {
174 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
175 new DateTimeLiteral(Object)));
176 }
177
184 public void Add(ISemanticElement Subject, Uri Predicate, bool Object)
185 {
186 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
187 new BooleanLiteral(Object)));
188 }
189
196 public void Add(ISemanticElement Subject, Uri Predicate, byte[] Object)
197 {
198 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
199 new Base64Literal(Object)));
200 }
201
208 public void Add(ISemanticElement Subject, Uri Predicate, decimal Object)
209 {
210 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
211 new DecimalLiteral(Object)));
212 }
213
220 public void Add(ISemanticElement Subject, Uri Predicate, double Object)
221 {
222 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
223 new DoubleLiteral(Object)));
224 }
225
232 public void Add(ISemanticElement Subject, Uri Predicate, float Object)
233 {
234 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
235 new SingleLiteral(Object)));
236 }
237
244 public void Add(ISemanticElement Subject, Uri Predicate, Duration Object)
245 {
246 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
247 new DurationLiteral(Object)));
248 }
249
256 public void Add(ISemanticElement Subject, Uri Predicate, sbyte Object)
257 {
258 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
259 new Int8Literal(Object)));
260 }
261
268 public void Add(ISemanticElement Subject, Uri Predicate, short Object)
269 {
270 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
271 new Int16Literal(Object)));
272 }
273
280 public void Add(ISemanticElement Subject, Uri Predicate, int Object)
281 {
282 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
283 new Int32Literal(Object)));
284 }
285
292 public void Add(ISemanticElement Subject, Uri Predicate, long Object)
293 {
294 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
295 new Int64Literal(Object)));
296 }
297
304 public void Add(ISemanticElement Subject, Uri Predicate, byte Object)
305 {
306 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
307 new UInt8Literal(Object)));
308 }
309
316 public void Add(ISemanticElement Subject, Uri Predicate, ushort Object)
317 {
318 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
319 new UInt16Literal(Object)));
320 }
321
328 public void Add(ISemanticElement Subject, Uri Predicate, uint Object)
329 {
330 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
331 new UInt32Literal(Object)));
332 }
333
340 public void Add(ISemanticElement Subject, Uri Predicate, ulong Object)
341 {
342 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
343 new UInt64Literal(Object)));
344 }
345
352 public void Add(ISemanticElement Subject, Uri Predicate, BigInteger Object)
353 {
354 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
355 new IntegerLiteral(Object)));
356 }
357
364 public void Add(ISemanticElement Subject, Uri Predicate, TimeSpan Object)
365 {
366 this.triples.Add(new SemanticTriple(Subject, new UriNode(Predicate),
367 new TimeLiteral(Object)));
368 }
369
376 public void Add(ISemanticElement Subject, ISemanticElement Predicate, ISemanticElement Object)
377 {
378 this.triples.Add(new SemanticTriple(Subject, Predicate, Object));
379 }
380
387 public void Add(ISemanticElement Subject, ISemanticElement Predicate, object Object)
388 {
389 this.triples.Add(new SemanticTriple(Subject, Predicate,
391 }
392
399 public void Add(ISemanticElement Subject, ISemanticElement Predicate, string Object)
400 {
401 this.triples.Add(new SemanticTriple(Subject, Predicate,
402 new StringLiteral(Object)));
403 }
404
412 public void Add(ISemanticElement Subject, ISemanticElement Predicate, string Object,
413 string Language)
414 {
415 this.triples.Add(new SemanticTriple(Subject, Predicate,
416 new StringLiteral(Object, Language)));
417 }
418
426 public void Add(ISemanticElement Subject, ISemanticElement Predicate, string Object,
427 Uri Type)
428 {
429 this.triples.Add(new SemanticTriple(Subject, Predicate,
430 new CustomLiteral(Object, Type)));
431 }
432
441 public void Add(ISemanticElement Subject, ISemanticElement Predicate, string Object,
442 Uri Type, string Language)
443 {
444 this.triples.Add(new SemanticTriple(Subject, Predicate,
445 new CustomLiteral(Object, Type, Language)));
446 }
447
452 public virtual void Add(ISemanticTriple Triple)
453 {
454 this.triples.Add(Triple);
455 }
456
457 #endregion
458
459 #region Adding Linked Lists
460
467 public void AddLinkedList(ISemanticElement Subject, Uri Predicate,
468 params object[] Items)
469 {
470 this.AddLinkedList(Subject, new UriNode(Predicate), Items);
471 }
472
479 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
480 params object[] Items)
481 {
482 int i, c = Items.Length;
483 ISemanticElement[] Literals = new ISemanticElement[c];
484
485 for (i = 0; i < c; i++)
486 Literals[i] = SemanticElements.EncapsulateLiteral(Items[i]);
487
488 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
489 }
490
497 public void AddLinkedList(ISemanticElement Subject, Uri Predicate,
498 params string[] Items)
499 {
500 this.AddLinkedList(Subject, new UriNode(Predicate), Items);
501 }
502
509 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
510 params string[] Items)
511 {
512 int i, c = Items.Length;
513 ISemanticElement[] Literals = new ISemanticElement[c];
514
515 for (i = 0; i < c; i++)
516 Literals[i] = new StringLiteral(Items[i]);
517
518 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
519 }
520
527 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
528 params bool[] Items)
529 {
530 int i, c = Items.Length;
531 ISemanticElement[] Literals = new ISemanticElement[c];
532
533 for (i = 0; i < c; i++)
534 Literals[i] = new BooleanLiteral(Items[i]);
535
536 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
537 }
538
545 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
546 params byte[][] Items)
547 {
548 int i, c = Items.Length;
549 ISemanticElement[] Literals = new ISemanticElement[c];
550
551 for (i = 0; i < c; i++)
552 Literals[i] = new Base64Literal(Items[i]);
553
554 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
555 }
556
563 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
564 params decimal[] Items)
565 {
566 int i, c = Items.Length;
567 ISemanticElement[] Literals = new ISemanticElement[c];
568
569 for (i = 0; i < c; i++)
570 Literals[i] = new DecimalLiteral(Items[i]);
571
572 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
573 }
574
581 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
582 params double[] Items)
583 {
584 int i, c = Items.Length;
585 ISemanticElement[] Literals = new ISemanticElement[c];
586
587 for (i = 0; i < c; i++)
588 Literals[i] = new DoubleLiteral(Items[i]);
589
590 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
591 }
592
599 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
600 params float[] Items)
601 {
602 int i, c = Items.Length;
603 ISemanticElement[] Literals = new ISemanticElement[c];
604
605 for (i = 0; i < c; i++)
606 Literals[i] = new SingleLiteral(Items[i]);
607
608 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
609 }
610
617 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
618 params Duration[] Items)
619 {
620 int i, c = Items.Length;
621 ISemanticElement[] Literals = new ISemanticElement[c];
622
623 for (i = 0; i < c; i++)
624 Literals[i] = new DurationLiteral(Items[i]);
625
626 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
627 }
628
635 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
636 params sbyte[] Items)
637 {
638 int i, c = Items.Length;
639 ISemanticElement[] Literals = new ISemanticElement[c];
640
641 for (i = 0; i < c; i++)
642 Literals[i] = new Int8Literal(Items[i]);
643
644 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
645 }
646
653 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
654 params short[] Items)
655 {
656 int i, c = Items.Length;
657 ISemanticElement[] Literals = new ISemanticElement[c];
658
659 for (i = 0; i < c; i++)
660 Literals[i] = new Int16Literal(Items[i]);
661
662 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
663 }
664
671 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
672 params int[] Items)
673 {
674 int i, c = Items.Length;
675 ISemanticElement[] Literals = new ISemanticElement[c];
676
677 for (i = 0; i < c; i++)
678 Literals[i] = new Int32Literal(Items[i]);
679
680 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
681 }
682
689 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
690 params long[] Items)
691 {
692 int i, c = Items.Length;
693 ISemanticElement[] Literals = new ISemanticElement[c];
694
695 for (i = 0; i < c; i++)
696 Literals[i] = new Int64Literal(Items[i]);
697
698 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
699 }
700
707 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
708 params byte[] Items)
709 {
710 int i, c = Items.Length;
711 ISemanticElement[] Literals = new ISemanticElement[c];
712
713 for (i = 0; i < c; i++)
714 Literals[i] = new UInt8Literal(Items[i]);
715
716 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
717 }
718
725 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
726 params ushort[] Items)
727 {
728 int i, c = Items.Length;
729 ISemanticElement[] Literals = new ISemanticElement[c];
730
731 for (i = 0; i < c; i++)
732 Literals[i] = new UInt16Literal(Items[i]);
733
734 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
735 }
736
743 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
744 params uint[] Items)
745 {
746 int i, c = Items.Length;
747 ISemanticElement[] Literals = new ISemanticElement[c];
748
749 for (i = 0; i < c; i++)
750 Literals[i] = new UInt32Literal(Items[i]);
751
752 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
753 }
754
761 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
762 params ulong[] Items)
763 {
764 int i, c = Items.Length;
765 ISemanticElement[] Literals = new ISemanticElement[c];
766
767 for (i = 0; i < c; i++)
768 Literals[i] = new UInt64Literal(Items[i]);
769
770 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
771 }
772
779 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
780 params BigInteger[] Items)
781 {
782 int i, c = Items.Length;
783 ISemanticElement[] Literals = new ISemanticElement[c];
784
785 for (i = 0; i < c; i++)
786 Literals[i] = new IntegerLiteral(Items[i]);
787
788 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
789 }
790
797 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
798 params TimeSpan[] Items)
799 {
800 int i, c = Items.Length;
801 ISemanticElement[] Literals = new ISemanticElement[c];
802
803 for (i = 0; i < c; i++)
804 Literals[i] = new TimeLiteral(Items[i]);
805
806 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Literals);
807 }
808
815 public void AddLinkedList(ISemanticElement Subject, Uri Predicate,
816 IEnumerable Items)
817 {
818 this.AddLinkedList(Subject, new UriNode(Predicate), Items);
819 }
820
827 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
828 IEnumerable Items)
829 {
831
832 foreach (object Item in Items)
833 Literals.Add(SemanticElements.EncapsulateLiteral(Item));
834
835 this.AddLinkedList(Subject, Predicate, Literals);
836 }
837
844 public void AddLinkedList(ISemanticElement Subject, Uri Predicate,
845 params ISemanticElement[] Items)
846 {
847 this.AddLinkedList(Subject, new UriNode(Predicate), Items);
848 }
849
856 public void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
857 params ISemanticElement[] Items)
858 {
859 this.AddLinkedList(Subject, Predicate, (IEnumerable<ISemanticElement>)Items);
860 }
861
868 public void AddLinkedList(ISemanticElement Subject, Uri Predicate,
869 IEnumerable<ISemanticElement> Items)
870 {
871 this.AddLinkedList(Subject, new UriNode(Predicate), Items);
872 }
873
880 public virtual void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate,
881 IEnumerable<ISemanticElement> Items)
882 {
883 BlankNode Container = new BlankNode("n" + Guid.NewGuid().ToString());
884 ISemanticElement Loop = null;
885
886 this.Add(Subject, Predicate, Container);
887 this.Add(Container, Rdf.type, Rdf.List);
888
889 foreach (ISemanticElement Item in Items)
890 {
891 if (Loop is null)
892 {
893 this.Add(Container, Rdf.first, Item);
894 Loop = Container;
895 }
896 else
897 {
898 BlankNode Node = new BlankNode("n" + Guid.NewGuid().ToString());
899 this.Add(Container, Rdf.rest, Node);
900 this.Add(Node, Rdf.first, Item);
901 Loop = Node;
902 }
903 }
904
905 this.Add(Loop ?? Container, Rdf.rest, Rdf.nil);
906 }
907
908 #endregion
909
910 #region Adding Containers
911
919 public void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate,
920 params object[] Items)
921 {
922 this.AddContainer(Subject, Type, new UriNode(Predicate), Items);
923 }
924
932 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
933 params object[] Items)
934 {
935 int i, c = Items.Length;
936 ISemanticElement[] Literals = new ISemanticElement[c];
937
938 for (i = 0; i < c; i++)
939 Literals[i] = SemanticElements.EncapsulateLiteral(Items[i]);
940
941 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
942 }
943
951 public void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate,
952 params string[] Items)
953 {
954 this.AddContainer(Subject, Type, new UriNode(Predicate), Items);
955 }
956
964 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
965 params string[] Items)
966 {
967 int i, c = Items.Length;
968 ISemanticElement[] Literals = new ISemanticElement[c];
969
970 for (i = 0; i < c; i++)
971 Literals[i] = new StringLiteral(Items[i]);
972
973 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
974 }
975
983 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
984 params bool[] Items)
985 {
986 int i, c = Items.Length;
987 ISemanticElement[] Literals = new ISemanticElement[c];
988
989 for (i = 0; i < c; i++)
990 Literals[i] = new BooleanLiteral(Items[i]);
991
992 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
993 }
994
1002 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1003 params byte[][] Items)
1004 {
1005 int i, c = Items.Length;
1006 ISemanticElement[] Literals = new ISemanticElement[c];
1007
1008 for (i = 0; i < c; i++)
1009 Literals[i] = new Base64Literal(Items[i]);
1010
1011 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1012 }
1013
1021 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1022 params decimal[] Items)
1023 {
1024 int i, c = Items.Length;
1025 ISemanticElement[] Literals = new ISemanticElement[c];
1026
1027 for (i = 0; i < c; i++)
1028 Literals[i] = new DecimalLiteral(Items[i]);
1029
1030 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1031 }
1032
1040 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1041 params double[] Items)
1042 {
1043 int i, c = Items.Length;
1044 ISemanticElement[] Literals = new ISemanticElement[c];
1045
1046 for (i = 0; i < c; i++)
1047 Literals[i] = new DoubleLiteral(Items[i]);
1048
1049 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1050 }
1051
1059 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1060 params float[] Items)
1061 {
1062 int i, c = Items.Length;
1063 ISemanticElement[] Literals = new ISemanticElement[c];
1064
1065 for (i = 0; i < c; i++)
1066 Literals[i] = new SingleLiteral(Items[i]);
1067
1068 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1069 }
1070
1078 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1079 params Duration[] Items)
1080 {
1081 int i, c = Items.Length;
1082 ISemanticElement[] Literals = new ISemanticElement[c];
1083
1084 for (i = 0; i < c; i++)
1085 Literals[i] = new DurationLiteral(Items[i]);
1086
1087 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1088 }
1089
1097 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1098 params sbyte[] Items)
1099 {
1100 int i, c = Items.Length;
1101 ISemanticElement[] Literals = new ISemanticElement[c];
1102
1103 for (i = 0; i < c; i++)
1104 Literals[i] = new Int8Literal(Items[i]);
1105
1106 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1107 }
1108
1116 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1117 params short[] Items)
1118 {
1119 int i, c = Items.Length;
1120 ISemanticElement[] Literals = new ISemanticElement[c];
1121
1122 for (i = 0; i < c; i++)
1123 Literals[i] = new Int16Literal(Items[i]);
1124
1125 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1126 }
1127
1135 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1136 params int[] Items)
1137 {
1138 int i, c = Items.Length;
1139 ISemanticElement[] Literals = new ISemanticElement[c];
1140
1141 for (i = 0; i < c; i++)
1142 Literals[i] = new Int32Literal(Items[i]);
1143
1144 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1145 }
1146
1154 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1155 params long[] Items)
1156 {
1157 int i, c = Items.Length;
1158 ISemanticElement[] Literals = new ISemanticElement[c];
1159
1160 for (i = 0; i < c; i++)
1161 Literals[i] = new Int64Literal(Items[i]);
1162
1163 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1164 }
1165
1173 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1174 params byte[] Items)
1175 {
1176 int i, c = Items.Length;
1177 ISemanticElement[] Literals = new ISemanticElement[c];
1178
1179 for (i = 0; i < c; i++)
1180 Literals[i] = new UInt8Literal(Items[i]);
1181
1182 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1183 }
1184
1192 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1193 params ushort[] Items)
1194 {
1195 int i, c = Items.Length;
1196 ISemanticElement[] Literals = new ISemanticElement[c];
1197
1198 for (i = 0; i < c; i++)
1199 Literals[i] = new UInt16Literal(Items[i]);
1200
1201 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1202 }
1203
1211 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1212 params uint[] Items)
1213 {
1214 int i, c = Items.Length;
1215 ISemanticElement[] Literals = new ISemanticElement[c];
1216
1217 for (i = 0; i < c; i++)
1218 Literals[i] = new UInt32Literal(Items[i]);
1219
1220 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1221 }
1222
1230 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1231 params ulong[] Items)
1232 {
1233 int i, c = Items.Length;
1234 ISemanticElement[] Literals = new ISemanticElement[c];
1235
1236 for (i = 0; i < c; i++)
1237 Literals[i] = new UInt64Literal(Items[i]);
1238
1239 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1240 }
1241
1249 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1250 params BigInteger[] Items)
1251 {
1252 int i, c = Items.Length;
1253 ISemanticElement[] Literals = new ISemanticElement[c];
1254
1255 for (i = 0; i < c; i++)
1256 Literals[i] = new IntegerLiteral(Items[i]);
1257
1258 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1259 }
1260
1268 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1269 params TimeSpan[] Items)
1270 {
1271 int i, c = Items.Length;
1272 ISemanticElement[] Literals = new ISemanticElement[c];
1273
1274 for (i = 0; i < c; i++)
1275 Literals[i] = new TimeLiteral(Items[i]);
1276
1277 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Literals);
1278 }
1279
1287 public void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate,
1288 IEnumerable Items)
1289 {
1290 this.AddContainer(Subject, Type, new UriNode(Predicate), Items);
1291 }
1292
1300 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1301 IEnumerable Items)
1302 {
1304
1305 foreach (object Item in Items)
1306 Literals.Add(SemanticElements.EncapsulateLiteral(Item));
1307
1308 this.AddContainer(Subject, Type, Predicate, Literals);
1309 }
1310
1318 public void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate,
1319 params ISemanticElement[] Items)
1320 {
1321 this.AddContainer(Subject, Type, new UriNode(Predicate), Items);
1322 }
1323
1331 public void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1332 params ISemanticElement[] Items)
1333 {
1334 this.AddContainer(Subject, Type, Predicate, (IEnumerable<ISemanticElement>)Items);
1335 }
1336
1344 public void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate,
1345 IEnumerable<ISemanticElement> Items)
1346 {
1347 this.AddContainer(Subject, Type, new UriNode(Predicate), Items);
1348 }
1349
1357 public virtual void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate,
1358 IEnumerable<ISemanticElement> Items)
1359 {
1360 BlankNode Container = new BlankNode("n" + Guid.NewGuid().ToString());
1361 int i = 0;
1362
1363 this.Add(Subject, Predicate, Container);
1364 this.Add(Container, Rdf.type, Type);
1365
1366 foreach (ISemanticElement Item in Items)
1367 this.Add(Container, Rdf.ListItem(++i), Item);
1368 }
1369
1370 #endregion
1371
1372 #region Type Conversions
1373
1379 {
1381 int Rows = 0;
1382
1383 foreach (ISemanticTriple T in this.triples)
1384 {
1385 Elements.Add(T.Subject);
1386 Elements.Add(T.Predicate);
1387 Elements.Add(T.Object);
1388 Rows++;
1389 }
1390
1391 return new ObjectMatrix(Rows, 3, Elements)
1392 {
1393 ColumnNames = new string[] { "Subject", "Predicate", "Object" }
1394 };
1395 }
1396
1402 {
1403 return VectorDefinition.Encapsulate(this.triples, false, null);
1404 }
1405
1406 #endregion
1407 }
1408}
void Add(ISemanticElement Subject, Uri Predicate, float Object)
Adds a triple to the model.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params long[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, ISemanticElement Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params byte[][] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, ushort Object)
Adds a triple to the model.
void Add(ISemanticElement Subject, Uri Predicate, short Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, IEnumerable Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params uint[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, Uri Predicate, params ISemanticElement[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, string Object, Uri Type, string Language)
Adds a triple to the model.
void Add(ISemanticElement Subject, Uri Predicate, decimal Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params sbyte[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, Uri Predicate, params object[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, string Object, string Language)
Adds a triple to the model.
IEnumerator< ISemanticTriple > GetEnumerator()
Gets an enumerator of available triples.
void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate, IEnumerable Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, ISemanticElement Predicate, string Object, string Language)
Adds a triple to the model.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params uint[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, Uri Predicate, IEnumerable Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, ISemanticElement Predicate, object Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate, params string[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate, IEnumerable< ISemanticElement > Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params TimeSpan[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params sbyte[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, uint Object)
Adds a triple to the model.
ChunkedList< ISemanticTriple > triples
Triples in model.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params ulong[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, Uri Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params ulong[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params int[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, byte[] Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params string[] Items)
Adds a linked list of items to the graph.
IElement ToVector()
Converts the object to a vector.
void Add(ISemanticElement Subject, Uri Predicate, string Object)
Adds a triple to the model.
void Add(ISemanticElement Subject, ISemanticElement Predicate, string Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate, params ISemanticElement[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, Uri Predicate, IEnumerable< ISemanticElement > Items)
Adds a linked list of items to the graph.
virtual void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, IEnumerable< ISemanticElement > Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, string Object, Uri Type)
Adds a triple to the model.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params ushort[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, ulong Object)
Adds a triple to the model.
void Add(ISemanticElement Subject, Uri Predicate, int Object)
Adds a triple to the model.
void Add(ISemanticElement Subject, ISemanticElement Predicate, string Object, Uri Type, string Language)
Adds a triple to the model.
void Add(ISemanticElement Subject, Uri Predicate, long Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate, params object[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, ISemanticElement Predicate, string Object, Uri Type)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params short[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params BigInteger[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, object Object)
Adds a triple to the model.
void Add(ISemanticElement Subject, ISemanticElement Predicate, ISemanticElement Object)
Adds a triple to the model.
void Add(ISemanticElement Subject, Uri Predicate, bool Object)
Adds a triple to the model.
virtual void Add(ISemanticTriple Triple)
Adds a triple to the model.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params short[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, DateTime Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params Duration[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params byte[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params decimal[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, byte Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params long[] Items)
Adds a linked list of items to the graph.
virtual void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, IEnumerable< ISemanticElement > Items)
Adds a linked list of items to the graph.
InMemorySemanticModel(IEnumerable< ISemanticTriple > Triples)
In-memory semantic model.
void Add(ISemanticElement Subject, Uri Predicate, BigInteger Object)
Adds a triple to the model.
void AddLinkedList(ISemanticElement Subject, Uri Predicate, params string[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, sbyte Object)
Adds a triple to the model.
IMatrix ToMatrix()
Converts the object to a matrix.
void Add(ISemanticElement Subject, Uri Predicate, TimeSpan Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params ushort[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params Duration[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params decimal[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params string[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params float[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params byte[][] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params double[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params object[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params TimeSpan[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params bool[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params int[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params float[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params double[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, Duration Object)
Adds a triple to the model.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params bool[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params BigInteger[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params byte[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params ISemanticElement[] Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, IEnumerable Items)
Adds a linked list of items to the graph.
void AddLinkedList(ISemanticElement Subject, ISemanticElement Predicate, params object[] Items)
Adds a linked list of items to the graph.
void AddContainer(ISemanticElement Subject, Uri Type, ISemanticElement Predicate, params ISemanticElement[] Items)
Adds a linked list of items to the graph.
void Add(ISemanticElement Subject, Uri Predicate, double Object)
Adds a triple to the model.
Represents a blank node
Definition: BlankNode.cs:7
Represents a 16-bit integer literal.
Definition: Int16Literal.cs:11
Represents a 32-bit integer literal.
Definition: Int32Literal.cs:11
Represents a 64-bit integer literal.
Definition: Int64Literal.cs:11
Represents a 8-bit integer literal.
Definition: Int8Literal.cs:11
Represents an integer literal of undefined size.
Represents a 16-bit unsigned integer literal.
Represents a 32-bit unsigned integer literal.
Represents a 64-bit unsigned integer literal.
Represents a 8-bit unsigned integer literal.
Definition: UInt8Literal.cs:11
static ISemanticLiteral EncapsulateLiteral(object Value)
Encapsulates an object as a semantic literal.
static readonly Uri nil
URI representing rdf:nil
Definition: Rdf.cs:66
static readonly Uri type
URI representing rdf:type
Definition: Rdf.cs:51
static readonly Uri first
URI representing rdf:first
Definition: Rdf.cs:56
static readonly Uri rest
URI representing rdf:rest
Definition: Rdf.cs:61
static Uri ListItem(int Index)
URI representing an item in a list.
static readonly Uri List
URI representing rdf:List
Definition: Rdf.cs:107
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
IEnumerator< T > GetEnumerator()
Returns an enumerator for the collection.
Definition: ChunkedList.cs:418
void Add(T Item)
Adds an item to the collection.
Definition: ChunkedList.cs:272
static IElement Encapsulate(Array Elements, bool CanEncapsulateAsMatrix, ScriptNode Node)
Encapsulates the elements of a vector.
Interface for semantic nodes.
Interface for semantic models.
Interface for semantic triples.
ISemanticElement Object
Object element
ISemanticElement Predicate
Predicate element
ISemanticElement Subject
Subject element
Basic interface for all types of elements.
Definition: IElement.cs:21
Basic interface for matrices.
Definition: IMatrix.cs:7
Interface for objects that can be converted into matrices.
Definition: IToMatrix.cs:9
Interface for objects that can be converted into matrices.
Definition: IToVector.cs:9
Represents a duration value, as defined by the xsd:duration data type: http://www....
Definition: Duration.cs:14