Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            Options opts = ProcessOptions(args);
            IEnumerable<OntologyClass> classes = null;

            if (!string.IsNullOrEmpty(opts.endpoint))
            {
                var mr = new MetadataRetriever(opts);
                classes = new List<OntologyClass>(mr.GetClasses());
            }

            if (!string.IsNullOrEmpty(opts.metadataLocation) && classes != null)
            {
                var mw = new ModelWriter();
                mw.Write(opts.metadataLocation, classes);
            }

            if (classes == null && !string.IsNullOrEmpty(opts.metadataLocation))
            {
                var mw = new ModelWriter();
                classes = mw.Read(opts.metadataLocation);
            }

            if (!string.IsNullOrEmpty(opts.sourceLocation) && classes != null)
            {
                var cg = new CodeGenerator();
                string code = cg.Generate(classes, opts);
                WriteSource(opts.sourceLocation, code);
            }
            Console.WriteLine("done.");
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            Options options = ProcessOptions(args);

            options.endpoint = @"http://localhost/DanceQuery.yada"; // @"http://localhost/SparqlQuery.yada";
            options.ignoreBlankNodes = false; // -i
            options.ontologyNamespace = @"http://www.dancingsociety.com/ontologies/dance.owl#"; // @"http://aabs.purl.org/ontologies/2007/04/music#";
            options.sourceLocation = @"C:\classes\dance.cs"; // -o "$(ProjectDir)music.cs"
            options.dotnetNamespace = @"DanceModel"; // -N:RdfMetal.Music
            options.ontologyPrefix = @"dance"; // -h music

            // Usage: RdfMetal [options] is used with the following options
            // Options:
            // -e -endpoint:PARAM The SPARQL endpoint to query.
            // -h -handle:PARAM The ontology name to be used in LinqToRdf for prefixing URIs and disambiguating class names and properties.
            // -? -help Show this help list
            // -help2 Show an additional help list
            // -i -ignorebnodes Ignore BNodes. Use this if you only want to generate code for named classes.
            // -m -metadata:PARAM Where to place/get the collected metadata.
            // -n -namespace:PARAM The XML Namespace to extract classes from.
            // -N -netnamespace:PARAM The .NET namespace to place the generated source in.
            // -o -output:PARAM Where to place the generated code.
            // -r -references:PARAM A comma separated list of namespaces to reference in the generated source.
            // -usage Show usage syntax and exit
            // -V -version Display version and licensing information

            IEnumerable<OntologyClass> classes = null;

            if (!string.IsNullOrEmpty(options.endpoint))
            {
                var mr = new MetadataRetriever(options);
                classes = new List<OntologyClass>(mr.GetClasses());
            }

            if (!string.IsNullOrEmpty(options.metadataLocation) && classes != null)
            {
                var mw = new ModelWriter();
                mw.Write(options.metadataLocation, classes);
            }

            if (classes == null && !string.IsNullOrEmpty(options.metadataLocation))
            {
                var mw = new ModelWriter();
                classes = mw.Read(options.metadataLocation);
            }

            if (!string.IsNullOrEmpty(options.sourceLocation) && classes != null)
            {
                var cg = new CodeGenerator();
                string code = cg.Generate(classes, options);
                WriteSource(options.sourceLocation, code);
            }

            Console.WriteLine("done.");
            Console.ReadLine();
        }
Exemplo n.º 3
0
 public void TestCodeGeneratorAccessesTemplates()
 {
     var cg = new CodeGenerator();
     var actualCode = cg.Generate(GetTestData().ToArray(), GetTestOpts());
     Assert.IsTrue(!string.IsNullOrEmpty(actualCode));
     Assert.IsTrue(actualCode.Contains("MyOntologyDataContext "));
     Assert.IsTrue(actualCode.Contains("RelativeUriReference=\"Class1\")]"));
     Assert.IsTrue(actualCode.Contains("\"Prop0\")]"));
     Assert.IsTrue(actualCode.Contains("_Prop0.HasLoadedOrAssignedValue"));
     Assert.IsTrue(actualCode.Contains("_Prop1.HasLoadedOrAssignedValue"));
 }