You can use fluent interface with Depends on or Parameters stuff.
In xml you can pass them in parameters node IIRC

Tuna Toksöz
http://tunatoksoz.com
http://turkiyealt.net
http://twitter.com/tehlike

Typos included to enhance the readers attention!



On Wed, Mar 4, 2009 at 9:00 PM, Hardy <[email protected]> wrote:

>
> Hi all,
>
> I don't quite understand how does Unity handle different
> implementation with different constructors. For example I have an
> interface ILog to handle logging functions, there are different
> implementations, such as XmlLog, DatabaseLog and so on. In C# code I
> may have something like:
>
> interface ILog {
>    void LogMessage(string message);
> }
>
> class XmlLog : ILog {
>    private string XmlFile;
>    public XmlLog(string XmlFile) {
>        this.XmlFile = XmlFile;
>    }
>
>    public void LogMessage(string message) {
>        // build Xml Document an save to XmlFile
>    }
> }
>
> class DatabaseLog : ILog {
>    private Database dbInstance;
>    public DatabaseLog(Database dbInstance) {
>        this.dbInstance = dbInstance;
>    }
>
>    public void LogMessage(string message) {
>        // save to dbInstance database
>    }
> }
>
> I understand I can register to container like:
> IWindsorContainer container = new WindsorContainer();
> container.AddComponent("DBLog", typeof(ILog), typeof(DatabaseLog));
> container.AddComponent("XmlLog", typeof(ILog), typeof(XmlLog));
>
> In my code, I need to resolve one instance bases on some criteria, for
> example:
> // how does Castle Windsor handle my constructor here?
> ILog myLog = container.Resolve<ILog>("XmlLog");
>
> Now, my real questions in this situation how can I really pass
> constructor parameter to my instance?
>
> Thanks
> Hardy
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to