[Mono-list] Compiling egg-chicken libraries

Stuart Ballard sballard@netreach.com
Thu, 26 Feb 2004 14:41:01 -0500


Jaroslaw Kowalski wrote:
> I need (as an option) this for my O/R mapping software because I want to be
> able to use mutliple languages.
> 
> I have:
> 
> 1. "Stubs" assembly - written in C# - that must be able to create objects
> from "Objects" assembly to represent 1-1 relations and 1-N relations.
> 2. "Objects" assembly - written in some other language whose classes inherit
> from the appropriate classes in "Stubs" assembly
> 
> So I have a mutual dependency here. But as I've said this is optional. If
> you stict to C# you have just a single assembly with no interdependencies.

Sounds like what you need is an IObjectCreator interface, defined in 
Stubs and implemented in Objects.

eg, in the Stubs assembly:

public interface IObjectCreator {
   object CreateObject();
}
public class FooStub {
   IObjectCreator ioc;

   void Twiddle() {
     object o = ioc.CreateObject();
     // do something with o
   }
}


in the Objects assembly:

public class Foo : FooStub {
   class FooCreator : IObjectCreator {
     public object CreateObject() {return new Foo();}
   }
   public Foo() {
     ioc = new FooCreator();
   }
}

The only problem is the need to explicitly define FooCreator for each 
class by hand. Depending on your circumstances, that may or may not be a 
killer problem.

Stuart.

-- 
Stuart Ballard, Senior Web Developer
NetReach, Inc.
(215) 283-2300, ext. 126
http://www.netreach.com/