/// <summary> /// Tries to load a SQL IO Manager based on information from the Configuration Graph /// </summary> /// <param name="g">Configuration Graph</param> /// <param name="objNode">Object Node</param> /// <param name="targetType">Target Type</param> /// <param name="obj">Output Object</param> /// <returns></returns> public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out Object obj) { ISqlIOManager manager = null; String server, port, db, user, pwd; //Create the URI Nodes we're going to use to search for things INode propServer = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServer), propDb = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDatabase); //Get Server and Database details server = ConfigurationLoader.GetConfigurationString(g, objNode, propServer); if (server == null) { server = "localhost"; } db = ConfigurationLoader.GetConfigurationString(g, objNode, propDb); if (db == null) { obj = null; return(false); } //Get user credentials ConfigurationLoader.GetUsernameAndPassword(g, objNode, true, out user, out pwd); //Based on this information create a Manager if possible switch (targetType.FullName) { case MicrosoftSqlManager: if (user == null || pwd == null) { manager = new MicrosoftSqlStoreManager(server, db); } else { manager = new MicrosoftSqlStoreManager(server, db, user, pwd); } break; case MySqlManager: if (user != null && pwd != null) { manager = new MySqlStoreManager(server, db, user, pwd); } break; } obj = manager; return(manager != null); }
public dotNetRDFEngine(AdapterSettings settings, Mapping mapping) { _settings = settings; // load uri maps config _uriMaps = new Properties(); string uriMapsFilePath = _settings["AppDataPath"] + "UriMaps.conf"; if (File.Exists(uriMapsFilePath)) { try { _uriMaps.Load(uriMapsFilePath); } catch (Exception e) { _logger.Info("Error loading [UriMaps.config]: " + e); } } _tripleStore = new MicrosoftSqlStoreManager( _settings["dotNetRDFServer"], _settings["dotNetRDFCatalog"], _settings["dotNetRDFUser"], _settings["dotNetRDFPassword"] ); _mapping = mapping; _graph = new Graph(); string baseUri = _settings["GraphBaseUri"]; string project = _settings["ProjectName"]; string app = _settings["ApplicationName"]; _graphNs = Utility.FormEndpointBaseURI(_uriMaps, baseUri, project, app); _dataObjectNs = String.Format("{0}.proj_{1}", DATALAYER_NS, _settings["Scope"]); _dataObjectsAssemblyName = _settings["ExecutingAssemblyName"]; }