GConfCompile

about

GConfCompile creates a .cs (csharp) file from a GConf schema.

example

There are some GConf keys:

First, you have to create the .cs file:

$ gconfcompile.exe /usr/share/gconf/schemas/gataxx.schemas Gataxx > GataxConfig.cs
		

- this creates the class `GataxxConfigGConf' and the interface `IGataxxConfig' (and the class `GataxxConfigXmlFile', but this is not important at the moment).

In your Application you create the configuration class,...

IGataxxConfig cfg = new GataxxConfigGConf();
		

...access the configuration options...

cfg.Quickmoves = true;
Console.WriteLine( cfg.Tileset );
cfg.Whitelevel = cfg.Blacklevel;
		

...and don't care about GConf.

using XML files

There is a more suffisticated way to create the config class:

#if GCONF
IGataxxConfig cfg = new GataxxConfigGConf();
#elif XML_FILE
IGataxxConfig cfg = GataxxConfigXmlFile.Load( "/home/user/.gataxx.xml" );
#else
#error define `GCONF' or `XML_FILE' eg. `-define:GCONF'
#endif
		

Now it is possible to choose the configuration backend at compile time. The generated sourcefile (`GataxConfig.cs') uses the same define options and you compile just the class you need.

mapping keys to properties

The GConf keys and the C# properties differ:

  1. just the part behind the last `/' is used (`/apps/gataxx/whitelevel' -> `whitelevel')
  2. Words are capitalized (`whitelevel' -> `Whitelevel')
  3. `_' is a word seperator and will be remved (`white_level' -> `WhiteLevel')

Why? I wanted the properties to feel lile C#, not like C

bugs and missing features

license

this software is released under the terms of the Lesser Gnu Public License. YOU USE THIS SOFTWARE ON YOUR OWN RISK.

download

gconfcompile.cs

Valid XHTML 1.0! Valid CSS! Get Firefox!