João,

So, about your first question, Google Groups or my email doesn't seem to made 
any line bold, but I assume you were talking about the last line?
The doco has a page about it: 
http://docs.castleproject.org/Windsor.Passing-Arguments.ashx which I admit 
could use some improvement and clarification.

basically, depending on whether your IHtmlTitleRetriever is resolved in your 
CompositionRoot or inside another component, you would use the 
container.Resolve(new Arguments(yourStuff)) or a typed factory respectively.
I hope that's clear enough. I'll try to update the doco to make it simpler to 
understand which to use where.

As for the general quality of the documentation, I'm a bit stumped why you 
would want something like the Autofac site you linked to. It doesn't seem to 
give you anything you can't discover with IntelliSense.

I do agree we could use some more examples. I'll add some for the Arguments 
class. Let me know if you have any other feedback.

--  
Krzysztof Kozmic


On Sunday, 23 June 2013 at 5:15 AM, João Carvalho wrote:

> Hi Krzysztof  
>  
> Thanks for your fast response...
> Regarding my App issue I was able to do some progress using that method you 
> mentioned:
> ---
>             IWindsorContainer container = new WindsorContainer();
>  
>             AssemblyFilter filter = new 
> AssemblyFilter(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
>  
>             container.Kernel.Resolver.AddSubResolver(new 
> ArrayResolver(container.Kernel, true));
>  
>             container.Register(
>                 
> Classes.FromAssemblyInDirectory(filter).BasedOn<IOCApp02Interfaces.IFileDownloader>().WithServiceBase(),
>                 
> Classes.FromAssemblyInDirectory(filter).BasedOn<IOCApp02Interfaces.ITitleScraper>().WithServiceBase()
>             );
>             container.Register(
>                 Component.For<HtmlTitleRetriever>()
>                 
> //.DependsOn(Dependency.OnComponentCollection<IOCApp02Interfaces.IFileDownloader[]>(
>                 //        "IOCApp02.HttpFileDownloader",
>                 //        "IOCApp02ExtendedLib.FtpFileDownloader",
>                 //        "IOCApp02ExtendedLib.FileSystemFileDownloader"))
>                 .DependsOn(Dependency.OnValue("files", new Uri[] {
>                     new 
> Uri("http://mi.mirror.garr.it/mirrors/postfix/index.html";),
>                     new 
> Uri("ftp://mi.mirror.garr.it/mirrors/postfixweb/announcements.html";),
>                     new 
> Uri("file:///C:/Users/jcarvalho/Documents/Work/vs2012/CastleWindsorIOCApp/IOCApp02/teste.txt")
>                 }))
>             );
>             HtmlTitleRetriever retriever = 
> container.Resolve<HtmlTitleRetriever>();
> ---
> If I dont use the ArrayResolver I was able to do the thing using the lines in 
> coments;  
> But how can I pass arguments needed for the contructor or inject properties 
> at the resolve moment (bold line) ?
>     
> About my process of looking for information: well ... for example: I would 
> like to see something like this (http://autofac.org/apidoc/) but with 
> realistic examples; for instance: reading this wiki page 
> (http://docs.castleproject.org/Windsor.Arguments.ashx)  I suspect that this 
> is the answer to my question above but I still can not figure how I can pass 
> an IFileDownloader[] to my constructor on resolving time...
>  
> ... well at this time I opted to dig a little more before post my answer and 
> It seems I was able to to do what I wanted: the only problem is that I'm not 
> real sure if this is the right approach...?
>  
> ---version 2:  
>  
>     IWindsorContainer container = new WindsorContainer();
>             
>             IWindsorContainer container = new WindsorContainer();
>  
>             AssemblyFilter filter = new 
> AssemblyFilter(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
>  
>             //container.Kernel.Resolver.AddSubResolver(new 
> ArrayResolver(container.Kernel, true));
>  
>             container.Register(
>                 
> Classes.FromAssemblyInDirectory(filter).BasedOn<IOCApp02Interfaces.IFileDownloader>().WithServiceBase(),
>                 
> Classes.FromAssemblyInDirectory(filter).BasedOn<IOCApp02Interfaces.ITitleScraper>().WithServiceBase()
>             );
>             container.Register(
>                 Component.For<HtmlTitleRetriever>()                 
>             );
>  
>             IFileDownloader[] aDownloaders = 
> (IFileDownloader[])container.ResolveAll(typeof(IFileDownloader));
>             Uri[] thefiles = new Uri[] {
>                     new 
> Uri("http://mi.mirror.garr.it/mirrors/postfix/index.html";),
>                     new 
> Uri("ftp://mi.mirror.garr.it/mirrors/postfixweb/announcements.html";),
>                     new 
> Uri("file:///C:/Users/jcarvalho/Documents/Work/vs2012/CastleWindsorIOCApp/IOCApp02/teste.txt")
>                 };
>  
>             HtmlTitleRetriever retriever = 
> container.Resolve<HtmlTitleRetriever>(new Arguments(new { downloaders = 
> aDownloaders, files = thefiles }));
>  
> ---
> note the comment line: I'm not even using the ArrayResolver method, I suspect 
> this is because we are passing the arguments so the container does  not need 
> to resolve the IFileDownloader[] it just returns an Array that I can cast to 
> IFileDownloader[]
>  
> My problem with the wiki is that the learning curve is really slow, the 
> method turns out to be very much trial and error...  
>  
> Yet another question, regarding the registration: what are the possible or 
> best methods for this situation: I have all my services (interfaces) in an 
> assembly, and the implementations separated for 2 assemblies: the running one 
> (app) and another one that is not referenced by anyone; is using 
> FromAssemblyInDirectory like I did is the best choice?  
>  
> (These must be really windsor-newbie questions...)  
>  
> Thank you again for your answer, it helped a lot...
>  
> João Carvalho
>  
>  
> On Saturday, June 22, 2013 2:58:56 AM UTC+1, Krzysztof Koźmic wrote:
> > Hi João,
> >  
> > Thanks for your feedback. I'd be interested to know more about your process 
> > of looking for information in the documentation wiki. and how we could 
> > improve it to make it easier to work with.
> >  
> > regarding your other issue, as FAQ mentions (in 
> > http://docs.castleproject.org/Windsor.FAQ.ashx#Why_is_Windsor_not_able_to_inject_array_or_list_of_components_10)
> >  you need to add CollectionResolver in other to be able to resolve 
> > collections (including arrays)
> > http://docs.castleproject.org/Windsor.Resolvers.ashx#_CollectionResolver__4
> >  
> >  
> > HTH,
> > Krzysztof
> >  
> >  
> > --  
> > Krzysztof Kozmic
> >  
> >  
> > On Saturday, 22 June 2013 at 3:05 AM, João Carvalho wrote:
> >  
> > > Hi all,
> > >  
> > > I'm a beginner here so I 'm trying to understand and use Castle Windsor.  
> > >  
> > > I found this 2007 old tutorial 
> > > (http://dotnetslackers.com/articles/designpatterns/InversionOfControlAndDependencyInjectionWithCastleWindsorContainerPart1.aspx)
> > >  and some other posts and of course the castle wiki documentation... and 
> > > that tutorial was imo the better one for someone like me trying to use 
> > > windsor step-by-step ; but it looks that it is based in a older version 
> > > of windsor. Although works fine it does not show hot to install and 
> > > register components programmatically. All configuration are made with 
> > > configurations files. I tried to use the fluent api to do the 
> > > registrations but with no success.  
> > >  
> > > That app is just a simple app that downloads some html uri's and lookup 
> > > the contents to extract some string (in the case the Title of the page); 
> > > it uses 2 services, one for the donwload (IFileDownloader) and one for 
> > > the string extraction (ITitleScraper). There are 3 implementations for 
> > > the downloader one with http protocol,other one with ftp and other one 
> > > with file protocol and also 2 implementations of the scrapper, one using 
> > > simple string search and the other using regular expressions. Also, one 
> > > of the implementations is on a different class library, like the 
> > > interfaces are in a diferent one.  
> > > (class diagram attached)
> > >  
> > > There is a component (HtmlTitleRetriever) that uses and depends on those 
> > > services that the app uses to do the job.  
> > >  
> > > With xml configuration one can install all types and components and also 
> > > inject dependencies to the constructor of the component. (xml 
> > > configuration are attached) The tutorial shows very well how to inject 
> > > properties and parameters on the constructor.  
> > >  
> > > My question:  
> > >  
> > > 1. how to do the same thing using the fluent api? install and register 
> > > all types and components involved and inject the exact some properties 
> > > and parameters at runtime and not at compile time and ; is it possible to 
> > > do all this without using xml configuration files?   
> > >  
> > > I tried to do this :
> > >  
> > > IWindsorContainer container = new WindsorContainer();
> > >  
> > > container.Register(
> > >     
> > > Classes.FromAssemblyInThisApplication().BasedOn<IOCApp02Interfaces.IFileDownloader>().WithServiceBase(),
> > >     
> > > Classes.FromAssemblyInThisApplication().BasedOn<IOCApp02Interfaces.ITitleScraper>().WithServiceBase(),
> > >     Component.For<HtmlTitleRetriever>()
> > > );
> > >  
> > > This register my components but I come with a "Potentially misconfigured 
> > > components:" HtmlTitleRetriever
> > >  
> > > Some dependencies of this component could not be statically resolved. 
> > > 'IOCApp02.HtmlTitleRetriever' is waiting for the following dependencies: 
> > > - Service 'IOCApp02Interfaces.IFileDownloader[]' which was not registered.
> > >  
> > > Can someone help? Or direct me for some good documentation/tutorials?  
> > >  
> > > Thanks
> > >  
> > >  
> > > --  
> > > You received this message because you are subscribed to the Google Groups 
> > > "Castle Project Users" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an 
> > > email to [email protected] (javascript:).
> > > To post to this group, send email to [email protected] 
> > > (javascript:).
> > > Visit this group at http://groups.google.com/group/castle-project-users.
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >   
> > >   
> > >  
> > > Attachments:  
> > > - app.config
> > >  
> > > - properties.config
> > >  
> > > - components.config
> > >  
> > >  
> >  
> >  
> --  
> You received this message because you are subscribed to the Google Groups 
> "Castle Project Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> (mailto:[email protected]).
> To post to this group, send email to [email protected] 
> (mailto:[email protected]).
> Visit this group at http://groups.google.com/group/castle-project-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>   
>   

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to