/// <summary>Adds another built in ontology into this provider instance.</summary> /// <param name="ontologies">Ontologiesto be included in this instance.</param> /// <returns>This instance of the default ontologies provider.</returns> public DefaultOntologiesProvider Include(BuiltInOntologies ontologies) { foreach (BuiltInOntologies ontology in Enum.GetValues(typeof(BuiltInOntologies))) { if (((ontologies & ontology) == ontology) && (!_includedOntologies.Contains(ontology))) { string resourceName = System.String.Format("{0}.{1}.", typeof(DefaultOntologiesProvider).Namespace, ontology.ToString()); resourceName = (from manifestResourceName in GetType().GetTypeInfo().Assembly.GetManifestResourceNames() where manifestResourceName.StartsWith(resourceName) select manifestResourceName).FirstOrDefault(); if (System.String.IsNullOrEmpty(resourceName)) { throw new System.IO.FileNotFoundException(System.String.Format("No embedded ontology stream found for '{0}'.", ontology.ToString())); } IOntology ontologyInstance = _ontologyFactory.Create( GetType().GetTypeInfo().Assembly.GetManifestResourceStream(resourceName), "application/" + (resourceName.EndsWith(".owl") ? "owl" : "rdf") + "+xml"); if (ontologyInstance != null) { _includedOntologies.Add(ontology); _ontologies.Add(ontologyInstance); } } } return(this); }
/// <summary>Creates a default ontology provider with given built in ontologies initialized.</summary> /// <param name="ontologies">Ontologies to be included int this instance.</param> public DefaultOntologiesProvider(BuiltInOntologies ontologies) : this() { Include(ontologies); }
/// <summary>Creates a default ontology provider with given built in ontologies initialized.</summary> /// <param name="ontologyProvider">Ontology provider to be wrapped by this instance.</param> /// <param name="ontologies">Ontologies to be included int this instance.</param> public DefaultOntologiesProvider(IOntologyProvider ontologyProvider, BuiltInOntologies ontologies) : base() { _ontologies = ontologyProvider.Ontologies.ToList(); _includedOntologies = new List<BuiltInOntologies>(); Include(ontologies); }
/// <summary>Adds another built in ontology into this provider instance.</summary> /// <param name="ontologies">Ontologiesto be included in this instance.</param> /// <returns>This instance of the default ontologies provider.</returns> public DefaultOntologiesProvider Include(BuiltInOntologies ontologies) { foreach (BuiltInOntologies ontology in Enum.GetValues(typeof(BuiltInOntologies))) { if (((ontologies & ontology) == ontology) && (!_includedOntologies.Contains(ontology))) { string resourceName = System.String.Format("{0}.{1}.", typeof(DefaultOntologiesProvider).Namespace, ontology.ToString()); resourceName = (from manifestResourceName in Assembly.GetExecutingAssembly().GetManifestResourceNames() where manifestResourceName.StartsWith(resourceName) select manifestResourceName).FirstOrDefault(); if (System.String.IsNullOrEmpty(resourceName)) { throw new System.IO.FileNotFoundException(System.String.Format("No embedded ontology stream found for '{0}'.", ontology.ToString())); } Ontology ontologyInstance = OntologyFactory.Create( Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName), "application/" + (resourceName.EndsWith(".owl") ? "owl" : "rdf") + "+xml"); if (ontologyInstance != null) { _includedOntologies.Add(ontology); _ontologies.Add(ontologyInstance); } } } return this; }