public void InstanceUriTest() { OwlInstanceSupertype target = new OwlInstanceSupertype(); string val = "http://tempuri.net/uri"; // TODO: Assign to an appropriate value for the property target.InstanceUri = val; Assert.AreEqual(val, target.InstanceUri, "LinqToRdf.OwlInstanceSupertype.InstanceUri was not set correctly."); }
public static void Add(this MemoryStore ms, OwlInstanceSupertype oc) { using (var ls = new LoggingScope("MemoryStoreExtensions.Add")) { Type t = oc.GetType(); Console.WriteLine(oc.InstanceUri); PropertyInfo[] pia = t.GetProperties(); ms.Add(new Statement((Entity)oc.InstanceUri, OntologyHelper.rdfType, (Entity)OwlClassSupertype.GetOwlClassUri(t))); foreach (PropertyInfo pi in pia) { if (pi.IsOntologyResource()) { AddPropertyToStore(oc, pi, ms); } } } }
private static void AddPropertyToStore(OwlInstanceSupertype track, PropertyInfo pi, MemoryStore ms) { if (track == null) throw new ArgumentNullException("track"); if (pi == null) throw new ArgumentNullException("pi"); if (ms == null) throw new ArgumentNullException("ms"); if (pi.GetValue(track, null) != null) { Add(track.InstanceUri, pi.GetOwlResourceUri(), pi.GetValue(track, null).ToString(), ms); #region Tracing #line hidden if (Logger.IsDebugEnabled) { Logger.Debug("Added property {0} to store.", pi.Name); } #line default #endregion } }
/// <summary> /// Returns true if the result is unique among the results so far received. /// </summary> /// <param name="obj">The object that is potentially to be added to the results collection.</param> /// <returns>true if there is no object among the <see cref="IncomingResults"/> with the same <see cref="OwlInstanceSupertype.InstanceUri"/>.</returns> private bool ObjectIsUniqueSoFar(OwlInstanceSupertype obj) { if (obj == null) { return true; } return IncomingResults .Cast<OwlInstanceSupertype>() .Where(o => o.InstanceUri == obj.InstanceUri) .Count() == 0; }
/// <summary> /// Assigns the instance URI from the SPARQL result bindings. /// </summary> /// <param name="obj">The object to assign the URI to.</param> /// <param name="queryAlias">The query alias that was used in LINQ and SPARQL.</param> /// <param name="semwebResult">The semweb result to take the value from.</param> private void AssignInstanceUri(OwlInstanceSupertype obj, string queryAlias, VariableBindings semwebResult) { // if there is no alias, then there's no way to work out what contains the instance URI if (string.IsNullOrEmpty(queryAlias)) { return; } // if there is a binding with the same name as the alias if (semwebResult.Variables.Map(v => v.LocalName).Contains(queryAlias)) { // get string representation of the instance URI string uri = semwebResult[queryAlias].ToString(); // is it enclosed in angle brackets? then strip them. if (uri.StartsWith("<") && uri.EndsWith(">")) { uri = uri.Substring(1, uri.Length - 2); } // can this be parsed as a URI? if so then assign to instance URI property of obj if (Uri.IsWellFormedUriString(uri, UriKind.RelativeOrAbsolute)) { obj.InstanceUri = uri; } } }
/// <summary> /// Assigns the <see cref="RdfDataContext"/> to the instance. /// </summary> /// <remarks> /// this is used in case it needs it to lazily load references later on. /// </remarks> /// <param name="obj">the object that has just been deserialised.</param> /// <param name="dataContext">The <see cref="RdfDataContext"/> through which the query was run that led to the instance being deserialised.</param> private void AssignDataContext(OwlInstanceSupertype obj, RdfDataContext dataContext) { if (obj != null) { obj.DataContext = DataContext; } // TODO: assign event handlers for NotifyPropertyChanged }