I have an existing Structuremap ApplicationRegistry that relies on HttpContext.Current.Server and also HttpContext.Current.Items (via HttpContextScoped). I'd like to use this in my WCF ServiceHostFactory, but HttpContext.Current remains belligerently null.
I am using basicHttpBinding and for the scope of the project I'm working on I'm h...
I am building a ASP.NET MVC 2.0 app on .NET 4.0 and am using Structuremap 2.6.1 for IoC. I recently added a ICookie and Cookie class, the Cookie class takes HttpContextBase as a constructor parameter (See below) and now when I run my app I get this error :No Default Instance defined for PluginFamily System.Web.HttpContextBase.
I have us...
I have an object "TestProperty" which implements "ITestProperty". "TestProperty" takes a string constructor argument. This is configured in StructureMap using something along the lines CtorDependency or WithCtorArg.
I want to inject the an instance of "ITestProperty" (implemented with "TestProperty") into another class as a property. Wh...
Hi, Having a problem with StructureMap IOC. I wish to retrieve different concrete implementations of objects that implement the same interface based on labels or names.
internal static class InstanceHelper
{
internal enum Taxonomy
{
Foo,
Bar
}
static InstanceHelper()
{
// Initialize th...
I'm trying to configure alternate constructor arguments when a requested type is being injected into several classes. In previous StructureMap versions, it would look a lot like the very first DSL example on the document page, but I'm having trouble figuring out how to configure it with the new syntax.
What I've got now is an one inte...
public abstract class ConventionController : Controller
{
public const int PageSize = 5;
public IMappingService MappingService { get; set;}
}
How do I set up StructureMap to get the Instance of IMappingService?
Edit:
With the help of Joshua Flanagan I now have the following code:
EmployeeController
public class EmployeeCon...
I'm adapting some code originally written for Windsor to use StructureMap. In the Windsor example we release the handler. Is it necessary to do this with StructureMap instances that are cached "per request"? The code is:
foreach (var handler in ObjectFactory.GetAllInstances<IHandle<TEvent>>()) {
handler.Handle(@event...
Between various Stack Overflow questions and blog posts there is a pretty reasonable amount of documentation on the topic of open generics and StructureMap. Unfortunately, I must be missing something as my attempts at using scan to perform the configuration along with a class implementation that has a "greedy" constructor have yet work.
...
Hi,
Here is the c# code:
var server = ******* some internal logic to determine server name ****
var username = ******* some internal logic to determine user name ****
var password = ******* some internal logic to determine password ****
ObjectFactory.Initialize(x =>
{
x.For<IService<bool>>(...
Hi folks,
I'm using StructureMap DI/IoC and I've got is a generic InMemory repository. Works great. I was wondering if it's possible to define the initial data which each repository holds, when it's requested?
Now, the first reaction is to do this in the constructor of the class - but I'm using a Generic Repository .. so i don't know w...
I use this approuch http://www.kevinwilliampang.com/2010/04/06/setting-up-asp-net-mvc-with-fluent-nhibernate-and-structuremap/ for setting up fnh with structuremap but after one request I get the following exception
Session is closed!
Object name: 'ISession'.
Description: An unhandled exception occurred during the execution of the curr...
I'm writing a simple photo downloader application using IOC. There is a fairly straightforward list of steps. Get list of photos to download. Check this, Check that, then download. The download can be accomplished via FTP in some cases, and via http in others, and via a web service in others.
What I'm wondering, as I'm new to IOC ...
I have a class:
public class SystemQuery<T> : ISystemQuery<T> where T : class, IUIView {
protected ISession session;
protected ICriteria baseCriteria;
public SystemQuery(SessionContext sessionContext) {
this.session = sessionContext.Session;
this.baseCriteria = session.CreateCriteria<T>();
}
publi...
I'm trying to get Property Injection working on a Custom Action Filter Attribute. It is working as it is supposed to, however, I'd like to use DI on the Property itself. My filter looks like this
[AttributeUsage(AttributeTargets.Class)]
public sealed class HeaderFilterAttribute : ActionFilterAttribute
{
public IMarketService MarketS...
A class has a unique constructor taking IMyInterface as its argument. If I define a concrete type of IMyInterface and registers it to StructureMap then there is no issue and my class can be instanciated with this concrete type.
However, in some cases, no concrete type will be registered. In that case, I would like to receive null for th...
Hello Everyone,
I just started digging into StructureMap and am running into some problems getting my config up-and-running. It seems that when I try to register Plugins in their respective
PluginFamily they aren't being found by StructureMap. I've gone over many examples on the web but can't seem to see where I am going wrong.
Can ...
All our apps have been converted to use strucutre map, and our libraries were converted also.
I'm trying to convert one of our asp.net webservices.
If I understand, correctly, I'll have to bootstrap the structuremap stuff in the constructor of the web service.
But the constructor gets called with each web method called, so Each reque...
I have this code for on ASP.NET MVC website:
x.For<AccountController>().TheDefault.Is.ConstructedBy(() => new AccountController());
This code throws a warning which seems quite self explanatory but for some reason when I use the "Use" method it doesn't seem to work. I know I am doing something wrong and would appreciate some help.
Th...
I have a bit of StructureMap config like so:
x.ForConcreteType<OrderProcessor>().Configure
.Ctor<string>("param1").EqualToAppSetting("setting1")
.Ctor<string>("param2").EqualToAppSetting("setting2")
.Ctor<string>("param3").EqualToAppSetting("setting3");
This works, but it is a bit of a magic-string approach. If I add or re...
I have 2 master pages. One is intended to be shown in a normal standalone website. The other is to be used in external sites as an Iframe.
I want to be able to show the normal page at http://example.com/home/index and the iframed version at http://example.com/framed/home/index
I want to have controls that will postback to one control...