Click here to Skip to main content
15,896,606 members
Articles / Programming Languages / C#

Simple Ontology Support for C#

Rate me:
Please Sign up or sign in to vote.
4.17/5 (11 votes)
11 Jul 20073 min read 67.9K   1.7K   47  
Extending the class hierarchy with semantic information
// Ontology Library Example
// (C)Copyright 2007 by martin.faust@e56.de
//
//  This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
using System;
using E56.Ontology;

namespace example {
	class Element : SemanticObject { }
	class Node : Element { }
	class SE : Node { }
	class SF : Node { }

	class MainClass {
		public static void Main(string[] args) {
			Console.WriteLine("Simple Ontology Support for C# Classes");
			
			Console.WriteLine("Parsing 'by-port' schema..."); SemanticObject.Parse("by-port.xml");
			Console.WriteLine("Parsing 'by-type' schema..."); SemanticObject.Parse("by-type.xml");
			
			Console.WriteLine("Testing a SF node");
			Node sf = new SF();
			SemanticType root = sf.SemanticType;
			SemanticType st1 = sf.IsA("by-port"); Console.WriteLine("Schema 'by-port': {0} is a {1}", root, st1);
			SemanticType st2 = sf.IsA("by-type"); Console.WriteLine("Schema 'by-type': {0} is a {1}", root, st2);
			
			Console.WriteLine("Hit <RETURN>..."); Console.ReadLine();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
Germany Germany
Utilizing my experience of industry-scale real-time graphics programming, design, development of software, as well as European research projects I want to bring in new ideas for creative projects.
Companies:
- 2009-now BTC AG: software for the renewable energy sector.
- 2007-2009 Digital Media: Audio, Graphics and GIS Web Services(http://maps.bremen.de)
- 2001-2007 artecLab://art/work/technology: Mixed Reality, Computer Games and eLearning
- 1998-2001 STN ATLAS Elektronik: real-time graphics for ground warfare simulation

For a complete resume see http://e56.de/download/resume.pdf

Comments and Discussions