I use this code to create my controller:
public override IController CreateController(RequestContext requestContext, string controllerName) {
try {
Type controllerType = null;
var baseControllerType = typeof(DashboardController<>);
var item = _repository.GetByUrlSegment(requestContext.Rou...
In my registry I have
Scan(scanner =>
{
scanner.AssemblyContainingType<EmailValidation>();
scanner.ConnectImplementationsToTypesClosing(typeof(IValidation<>));
});
What am I supposed to do to define these all as Singletons?
Also as an aside to this question, is there any reason to not defin...
I'm not sure how to ask this, but I want to create a new object in a linq statement, and initialize it's values. Since I have to use StructureMap's GetInstance method to get an instance of the object, I don't think this is possible. Am I wrong? And before we get off-topic, I realize I could probably create a constructor that takes the...
I just followed this example to bootstrap WCF with StructureMap. At the same time I've been using StructureMap in my ASP.NET application (IIS6), which is initialized in Global.asax.Application_Start().
The two configurations have different requirements. Unfortunately, StructureMap is configured statically, and contrary to my expecta...
I want to intercept the creation of an instance in SM and I'm trying the following but it's not calling the InstanceInterceptor implementation, does anyone know why?
ForRequestedType<IPublishResources>()
.TheDefault
.Is
.OfConcreteType<PublisherService>()
.InterceptWith(new PublisherServiceInterceptor());
The test code uses the Ob...
I'm working with StructureMap for my IoC needs.
To make things pleasantly testable, I'm passing IContainer instances around wherever possible, usually as constructor parameters. As a convenience, I'd like to be able to fall back to using ObjectFactory for a parameterless constructor.
The simplest way (I thought) to do this would be to ...
OK, I'm trying to set a property on a type I'm registering with SM.
Here's the code from the registry in one of my components. This
registry is being added during the configuration from a console app.
When I try to access the EndorsementSpecs property of the instance
AutoMandatoryEndorsementAggregator object, I get the 202. What's
int...
Hi - Im new to IOC and StructureMap and have an n-level application and am looking at how to setup the wirings (ForRequestedType ...) and just want to check with people with more experience that this is the best way of doing it!
I dont want my UI application object to reference my persistence layer directly so am not able to wire everyt...
I'm working on an application where we are using StructureMap 2.5.4 to scan a directory like below.
ObjectFactory.Configure(scanner => scanner.Scan(x =>
{
x.AssembliesFromPath(settings.Directory);
x.AddAllTypesOf(typeof(IScannerConvention)).NameBy(n => n.Name);
}));
For some reason the types implementing IScannerConvention are...
I have just updated to the latest structuremap dll and now my site no longer works at runtime due to deprecated methods in structuremap so I am trying to update my bootstrapper code.
In my bootstrapper class I have rewritten it to:
public class Bootstrapper
{
public static void ConfigureStructureMap()
{
ObjectFactory.In...
previously I had :
public class PresentationModelConventionScanner : ITypeScanner
{
public void Process(Type type, PluginGraph graph)
{
Type interfaceType = type.FindInterfaceThatCloses(typeof(IPresentationModel<>));
if (interfaceType != null)
{
graph.AddType(interfaceType, type);
}
...
which of the following syntax is considered best practice?
For<IMyInterface>().LifecycleIs(new HybridLifecycle()).Use<MyImplementation>();
For<IMyInterface>().LifecycleIs(Lifecycles.GetLifecycle(InstanceScope.Hybrid)).Use<MyImplementation>();
if the first one is correct, can I create one object HybridLifecycle, and use it for multipl...
This is the equivalent of what I'm trying to create with StructureMap:
new ChangePasswordWithNotificationAndLoggingService(
new ChangePasswordService(
new ActiveDirectoryRepository(new ActiveDirectoryCredentials()),
new TokenRepository("")),
new EmailNotificationService(new PasswordChangedNotification(new UserAccount())),
ne...
I am going to use it in a project with less-experienced developers so a complex framework such as Spring.NET is not an option. I was thinking about:
Ninject
Castle Windsor
StructureMap
Which would present a moderate learning curve without losing flexibility?
and another question - where is the correct place to put the configuration?...
I was previously using SM 2.5.3. I had some code that stored a named instance of an object that looked like this:
ObjectFactory.Configure(x =>
x.ForRequestedType<T>()
.TheDefault.IsThis(item)
.WithName(itemName));
Then to request one of the items from the container, I would do:
return ObjectFactory.GetName...
I hawe a webproject where i use StructureMap for DI IOC, it works perfect, but i dont hawe a clue how to write unit testing with StructureMap should i do this in AssemblyInitialize start Configuration of structuremap like in global.asax exept to for datacontext not to use Live LinqToSqlDataContext but some memory data like this:
[Assem...
In a follow up to Krzysztof’s statement that Windsor does a lot more than other IoC’s, I wanted to understand how these IoC’s stack up against each other and the benefits/additional facilities that castle Windsor provides.
Are there any comparisons? Can someone help me understand the additional features that Castle Windsor provides ov...
i have a generic interface
public interface IDomainDataRepository<T>
{
T[] GetAll();
}
with a generic implementation
public class DomainDataRepository<T> : IDomainDataRepository<T>
{
public virtual T[] GetAll()
{
return GetSession().Linq<T>().ToArray();
}
}
how do I register it in StructureMap so that if I r...
I'm using StructureMap at the moment, generally with convention-based (Scan()) auto-configuration, and I'm looking to add decorator-based caching into the pipeline.
If I configure it manually that is fine, but Scan() is just so convenient when you get lots of dependencies... I'm toying with noting cache suggestions on the interface(s), ...
I am trying to keep the IoC registration off to the side just like it is done in CodeCampServer via the DependencyResolution project, so that only one project in my solution holds a reference to StructureMap.
I have implementations of interfaces in my Client/UI project which I want registered, meaning that this DependencyResolution Proj...