本文整理汇总了C#中Triple类的典型用法代码示例。如果您正苦于以下问题:C# Triple类的具体用法?C# Triple怎么用?C# Triple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Triple类属于命名空间,在下文中一共展示了Triple类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleTripleInternal
protected override bool HandleTripleInternal(Triple t)
{
if (t.Subject.NodeType == NodeType.Uri)
{
if (t.Predicate.Equals(this._rdfType))
{
if (t.Object.Equals(this._rdfsClass) || t.Object.Equals(this._rdfsDatatype) || t.Object.Equals(this._rdfProperty))
{
if (!this._terms.Contains(t.Subject))
{
this._terms.Add(t.Subject);
}
}
}
else if (t.Predicate.Equals(this._rdfsLabel) && t.Object.NodeType == NodeType.Literal)
{
if (!this._termLabels.ContainsKey(t.Subject))
{
this._termLabels.Add(t.Subject, ((ILiteralNode)t.Object).Value);
}
}
else if (t.Predicate.Equals(this._rdfsComment) && t.Object.NodeType == NodeType.Literal)
{
if (!this._termComments.ContainsKey(t.Subject))
{
this._termLabels.Add(t.Subject, ((ILiteralNode)t.Object).Value);
}
}
}
return true;
}
示例2: MakeBrighstarTriple
private static Model.Triple MakeBrighstarTriple(Triple t, string uniqueImportId)
{
var ret = new Model.Triple
{
Subject = Stringify(t.Subject, uniqueImportId),
Predicate = Stringify(t.Predicate, uniqueImportId)
};
if (t.Object is UriNode)
{
ret.Object = t.Object.ToString();
}
else if (t.Object is LiteralNode)
{
var ln = (LiteralNode)t.Object;
ret.DataType = ln.DataType == null ? Constants.DefaultDatatypeUri : ln.DataType.ToString();
ret.IsLiteral = true;
ret.Object = ln.Value;
ret.LangCode = ln.Language;
}
else if (t.Object is BlankNode)
{
ret.Object = String.Format("{0}/{1}/{2}", Constants.GeneratedUriPrefix, uniqueImportId,
((BlankNode) t.Object).InternalID);
}
if (t.GraphUri != null)
{
ret.Graph = t.GraphUri.ToString();
}
return ret;
}
示例3: AddLoaderException
private void AddLoaderException(Triple<Assembly, Type, Exception> loaderException)
{
lock (this)
{
this.loaderExceptions.Add(loaderException);
}
}
示例4: AddTripleLiteral
/// <summary>
/// Adds the literal triple to a graph.
/// </summary>
/// <param name="graph">The graph.</param>
/// <param name="subject">The subject.</param>
/// <param name="predicate">The predicate.</param>
/// <param name="obj">The object (resource).</param>
/// <remarks></remarks>
public static void AddTripleLiteral(Graph graph, string subject, string predicate, string obj, string datatype)
{
string xmlSchemaDatatype;
switch (datatype)
{
case "Url":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeAnyUri;
break;
case "Date":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeDateTime;
break;
case "Integer":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeInteger;
break;
case "Ntext":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeString;
break;
case "Nvarchar":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeString;
break;
default:
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeString;
break;
}
Triple triple = null;
if (subject.StartsWith("http") && predicate.StartsWith("http"))
{
triple = new Triple(
graph.CreateUriNode(new Uri(subject)),
graph.CreateUriNode(new Uri(predicate)),
graph.CreateLiteralNode(obj, new Uri(xmlSchemaDatatype))
);
}
else if (!subject.StartsWith("http") && predicate.StartsWith("http"))
{
triple = new Triple(
graph.CreateUriNode(subject),
graph.CreateUriNode(new Uri(predicate)),
graph.CreateLiteralNode(obj, new Uri(xmlSchemaDatatype))
);
}
else if (subject.StartsWith("http") && !predicate.StartsWith("http"))
{
triple = new Triple(
graph.CreateUriNode(new Uri(subject)),
graph.CreateUriNode(predicate),
graph.CreateLiteralNode(obj, new Uri(xmlSchemaDatatype))
);
}
else if (!subject.StartsWith("http") && !predicate.StartsWith("http"))
{
triple = new Triple(
graph.CreateUriNode(subject),
graph.CreateUriNode(predicate),
graph.CreateLiteralNode(obj, new Uri(xmlSchemaDatatype))
);
}
graph.Assert(triple);
}
示例5: GambatteColor
// the version of gambatte in bizhawk
public static Triple GambatteColor(Triple c)
{
Triple ret;
ret.r = (c.r * 13 + c.g * 2 + c.b) >> 1;
ret.g = (c.g * 3 + c.b) << 1;
ret.b = (c.r * 3 + c.g * 2 + c.b * 11) >> 1;
return ret;
}
示例6: Multiply
/// <summary> Multiplies a 3x3 matrix by a 1x3 pythagorean triple. </summary>
static Triple Multiply(int[,] matrix, Triple triple)
{
Triple result;
result.a = matrix[0,0]*triple.a + matrix[1,0]*triple.b + matrix[2,0]*triple.c;
result.b = matrix[0,1]*triple.a + matrix[1,1]*triple.b + matrix[2,1]*triple.c;
result.c = matrix[0,2]*triple.a + matrix[1,2]*triple.b + matrix[2,2]*triple.c;
return result;
}
示例7: Format
/// <summary>
/// Formats a Triple as a String
/// </summary>
/// <param name="t">Triple</param>
/// <returns></returns>
public override string Format(Triple t)
{
if (t.GraphUri == null)
{
return base.Format(t);
}
else
{
return this.Format(t.Subject, TripleSegment.Subject) + " " + this.Format(t.Predicate, TripleSegment.Predicate) + " " + this.Format(t.Object, TripleSegment.Object) + " <" + this.FormatUri(t.GraphUri) + "> .";
}
}
示例8: insertLearningObject
/// <summary>
///
/// </summary>
/// <param name="g"></param>
/// <param name="LO"></param>
public void insertLearningObject(ref Graph g, LearningObjectContextModel LO)
{
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + LO.LearningObject_ID);
INode rdfType = g.CreateUriNode("rdf:type");
INode objeto = g.CreateUriNode("onto:LearningObject");
Triple triple = new Triple(sujeito, rdfType, objeto);
g.Assert(triple);
}
示例9: ToJena
public static Statement ToJena(Triple t, JenaMapping mapping)
{
Resource s;
Property p;
RDFNode o;
s = ToJenaResource(t.Subject, mapping);
p = ToJenaProperty(t.Predicate, mapping);
o = ToJenaNode(t.Object, mapping);
return mapping.Model.createStatement(s, p, o);
}
示例10: Contains
/// <summary>
/// Checks whether the Triple exists in the Collection
/// </summary>
/// <param name="t">Triple to check for</param>
/// <returns></returns>
/// <exception cref="RdfStorageException">Thrown if the underlying StatementSource is not a SelectableSource</exception>
public override bool Contains(Triple t)
{
if (this._source is SelectableSource)
{
Statement stmt = SemWebConverter.ToSemWeb(t, this._mapping);
return ((SelectableSource)this._source).Contains(stmt);
}
else
{
throw new RdfStorageException("The underlying StatementSource does not support the Contains() operation");
}
}
示例11: insertComunidadeMoodle
/// <summary>
///
/// </summary>
/// <param name="g"></param>
public void insertComunidadeMoodle(ref Graph g)
{
g = new Graph();
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + student.Matricula);
INode rdfType = g.CreateUriNode("onto:ComunidadeMoodle");
ILiteralNode literal = g.CreateLiteralNode(student.ComunidadeMoodle);
Triple triple = new Triple(sujeito, rdfType, literal);
g.Assert(triple);
}
示例12: insertDeviceMediaPreference
/// <summary>
///
/// </summary>
/// <param name="g"></param>
/// <param name="strLearningStyle"></param>
public void insertDeviceMediaPreference(ref Graph g)
{
g = new Graph();
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + Device.model_name);
INode rdfType = g.CreateUriNode("onto:hasDeviceMediaPreference");
IUriNode objeto = g.CreateUriNode(new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#" + Device.MediaPreference));
Triple triple = new Triple(sujeito, rdfType, objeto);
g.Assert(triple);
}
示例13: Assert
/// <summary>
/// Asserts a Triple in the Graph
/// </summary>
/// <param name="t">The Triple to add to the Graph</param>
public override void Assert(Triple t)
{
try
{
this._lockManager.EnterWriteLock();
base.Assert(t);
}
finally
{
this._lockManager.ExitWriteLock();
}
}
示例14: insertLearningObjectComunidade
/// <summary>
/// Insere LO a comunidade
/// </summary>
/// <param name="g"></param>
/// <param name="LO"></param>
public void insertLearningObjectComunidade(ref Graph g, LearningObjectContextModel LO)
{
g = new Graph();
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + LO.LearningObject_ID);
INode rdfType = g.CreateUriNode("onto:LO_MoodleCommunity");
ILiteralNode objeto = g.CreateLiteralNode(LO.MoodleCommunity);
Triple triple = new Triple(sujeito, rdfType, objeto);
g.Assert(triple);
}
示例15: InsertDeviceBrand
/// <summary>
///
/// </summary>
/// <param name="g"></param>
public void InsertDeviceBrand(ref Graph g)
{
g = new Graph();
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + Device.model_name);
INode rdfType = g.CreateUriNode("onto:Brand");
ILiteralNode literal = g.CreateLiteralNode(Device.Brand_Name);
Triple triple = new Triple(sujeito, rdfType, literal);
g.Assert(triple);
}