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

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

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

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

            if (!string.IsNullOrEmpty(opts.GeneratedSourceLocation) && classes != null)
            {
                var cg = new CodeGenerator();
                string code = cg.Generate(classes, opts);
                WriteSource(opts.GeneratedSourceLocation, code);
            }
	         Console.WriteLine("done.");
             Console.Read();
        }
Exemplo n.º 2
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"));
		}