Hi all,
I don't know much about Castle but I started using it some time ago. The
simple things about dependency resolution are pretty straight-forward and
well-documented. But I have a problem and I cannot find a solution in an
easy way. This is a simple console application project. I have an interface
let's say:
public interface IExternal
{
string GetSomething();
}
Moreover I have an abstract class:
public abstract class AbExternalProvider: IExternal
{
public string SomeString {get;private set;}
public AbExternalProvider(string pSomeString)
{
SomeString = pSomeString;
}
public abstract string GetSomething();
}
Finally I have a concrete class:
public class ExternalConcrete: AbExternalProvider
{
public ExternalConcrete(string pSomeString)
: base(pSomeString)
{
}
public override string GetSomething()
{
return "Something";
}
}
in program.cs
class Program
{
static void Main(string[] args)
{
var container = new Castle.Windsor.WindsorContainer();
container.Register(Component.For<AbExternalProvider>().ImplementedBy<ExternalConcrete>().LifestyleTransient());
AbExternalProvider provider =
container.Resolve<AbExternalProvider>();
Console.ReadLine();
}
}
But how can I resolve, in runtime, the dependency and pass a string
parameter to the Constructor of the concrete class according to an input
for example? I am currently getting an exception:
> 'cannot create component as it has dependencies to be satisfied'
Thanks a lot in advanced!
--
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/d/optout.