I have the following interface:
public interface ILogger
{
void Debug(string message, params object[] values);
void Info(string message, params object[] values);
void Warn(string message, params object[] values);
void Error(string message, params object[] values);
void Fatal(string message, params object[] values);
}...
Hi, I'm getting an error:
StructureMap Exception Code: 202
No Default Instance defined for PluginFamily MVCPoco.Services.IService, MVCPoco.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Line 96: {
Line 97: Type controllerType = base.GetControllerType(context, controllerName);
Line 98: r...
In Structure map I have the following line working with domain events:
public void Dispatch<TEvent>(TEvent eventToDispatch) where TEvent : IDomainEvent
{
foreach (var handler in ObjectFactory.GetAllInstances<IDomainEventHandler<TEvent>>())
{
if (handler.IsActive)
handle...
Hello guys, I'm new to IOC and strcturemap but i want to know how I can register different classes that implements from the same interface like IRepository that implements CustomerRepository and CategoryRepository for example.
And, as you can see, if i can use this with generic types.
Like Repository or Repository
x.ForRequestedType<IRe...
Hi, I have a question about how InstanceScope.Singleton works, because I am getting some unexpected results here:
I have a service that is dependent on Dao
public MetaProjectService(IMetaProjectDao metaProjectDao)
{
_metaProjectDao = metaProjectDao;
}
and I have Dao that is dependent on ISession (Nhiberna...
I am constantly facing this error while testing. I cannot even create an instance of IRoleRepository which should return RoleRepository.
Here is the error:
TestCase 'EStudy.Repository.Tests.when_fetching_instance_of_role_repository_using_structuremap.should_fetch_successfully'
failed: StructureMap.StructureMapException : StructureMap...
i am a structure map begginer.
i wanna now whats the best practice of work with real configuration on regular application running, and have the ability to override stuff under test environment.
i tried to work with the inject method on a singletone, and it worked only once.
anyway, i'm not sure i'm working as i should with SM,
so here...
In the C# language, using StructureMap 2.5.4, targeting .NET Framework 3.5 libraries.
I've taken the step to support multiple Profiles in a structure map DI setup, using ServiceLocator model with Bootstrapper activation. First setup was loading default registry, using the scanner.
Now I like to determine runtime what Registry configur...
Lets say i have a traditional statemachine/Factory implemented like
public class StateMachine
{
public void ProcessState(StateEnum CurrentState)
{
switch (CurrentState)
{
case StateEnum.New:
ProcessNewState();
break;
case StateEnum.Waiting:
P...
Hello, I'm using structuremap to register a service in the controller and i need to register repositories in services too. How I'll do that since they are 2 different projects and need the exact same IOC registration. Actually I'm using It on the presentation layer and injecting services in the controller.
I need to know a good pratice w...
Say I have an event defined in an interface.
I then have many classes that implement that interface.
The creation of these classes is managed by StructureMap.
Now say I have one delegate that I want to use as the event handler for ALL of these newly created instances.
Is there a way to tell StructureMap to append an event handler...
We're going to be using a custom role provider with WCF. The overridden method GetRolesForUser will require the use of an already existing RoleRepository.
Now, with a run-of-the-mill class, we'd construct it using StructureMap and the RoleRepository dependency would be injected via the constructor.
However, it's WCF that does the co...
I am trying out the code from this post on Event Driven Architecture (very interesting by the way). His IOC container is Unity though and I would like to do this using Structure map.
His code is:
public class EventSubscriptions : ISubscriptionService
{
public static void Add<T>()
{
var consumerType = typeof(T);
con...
Here are the relevant types and an example of the handler I want linked to IHandle<EventA> and IHandle<EventB>:
// marker interface
public interface IEvent {}
public interface IHandle<TEvent> where TEvent : IEvent {
void Handle(TEvent e);
}
public class SomeHandler : IHandle<EventA>, IHandle<EventB> {
public void Handle(EventA...
2 questions here. I have a page that I already use setter DI to insert a service layer using the following snippet from another post.
var application = (HttpApplication)sender;
var page = application.Context.CurrentHandler as Page;
if (page == null) return;
ObjectFactory.BuildUp(page);
How would I do the same for a user control t...
I'm deploying a new .Net 2.0 Asp.Net app with StructureMap 2.0 to a new environment for the first time.
StructureMap Exception Code: 100
Expected file "StructureMap.config" cannot be opened at {pathremoved}..\StructureMap.config
This is confusing because I explicitly told it not to use a config file in my app, I'm doing it all throug...
Using StructureMap, I'm trying to use setter injection on an open generic type.
I have an abstract generic class:
public abstract class Foo<T1, T2> : IMyInterface<T1,T2>
{
public ISomeDependency Bar { get; set; }
}
I want to use Setter Injection to resolve "Bar" on any inheritors of Foo. I know I can do this using the [SetterDepe...
We are currently using profiles and not find ourselves in a situation where we would like to use a combination of profiles at once, obviously we can't do this. I'll give a code example of what we are trying to do:
public class Root
{
public Root(IAmMoo mooooo)
{
}
}
public interface IAmMoo
{
}
public class SomeMoo : IAmM...
There's a few questions on SO about StructureMap and generics, and I've read a few blog posts about it, but still I'm struggling to figure out the solution to this particular scenario.
Given:
public interface ILookup
{
}
public interface ISupplier : ILookup
{
}
public interface ITenant : ILookup
{
}
public class Supplier : ISupplier...
I am using wcf 4 and trying to use some Ioc container to resolve service dependencies. I was looking at Castle Windsor and StructureMap. I haven't use any of them with wcf.
The scenario is that I have IService1 and Iservice2. Service1 is using service2:
public class Service1 : IService1
{
public Service1(IService2 service2)
{
...