Esempio n. 1
0
        /// <summary>
        /// Loads the Configuration Graph
        /// </summary>
        /// <returns></returns>
        internal IGraph LoadConfigurationGraph()
        {
            IGraph g = null;

            try
            {
                if (File.Exists(this._configFile))
                {
                    g = new Graph();
                    FileLoader.Load(g, this._configFile);
                }
                else
                {
                    //Try to get from embedded resource instead
                    Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(this._configFile);
                    if (stream == null)
                    {
                        Console.Error.WriteLine("rdfServer: Error: Configuration File '" + this.ConfigurationFile + "' was not found");
                    }
                    else
                    {
                        IRdfReader reader = MimeTypesHelper.GetParserByFileExtension(MimeTypesHelper.GetTrueFileExtension(this._configFile));
                        g = new Graph();
                        reader.Load(g, new StreamReader(stream));
                    }
                }
            }
            catch (RdfParserSelectionException)
            {
                g = null;
                Console.Error.WriteLine("rdfServer: Error: Configuration File '" + this.ConfigurationFile + "' could not be loaded as a suitable parser was not found");
            }
            catch (RdfParseException)
            {
                g = null;
                Console.Error.WriteLine("rdfServer: Error: Configuration File '" + this.ConfigurationFile + "' was not valid RDF");
            }

            //If got a Graph OK then prep the dotNetRDF Configuration API
            if (g != null)
            {
                ConfigurationLoader.AutoConfigure(g);
            }
            return(g);
        }