structuremap

How do I configure StructureMap to use a generic repository?

I have an interface IGenericRepository<TEntity> where TEntity : IEntity and an implementation GenericRepository<TEntity> where TEntity : Entity. I'm trying to inject a specific IGenericRepository<Section> into a class using StructureMap: ObjectFactory.Initialize(x => { x.For(typeof(IGenericRepository<>)).Use(typ...

StructureMap: Wiring (generic) implementations to an implementation of another type

If I have an interface: public interface IRepository<T> And an abstract class: public abstract class LinqToSqlRepository<T, TContext> : IRepository<T> where T : class where TContext : DataContext And a whole bunch of implementations of IRepository / LinqToSqlRepository (e.g. AccountRepository, ContactRepository, etc...

NHibernate does not update entity when repository is passed by constructor

Hi everybody, I am developing with NHibernate for the first time in conjunction with ASP.NET MVC and StructureMap. The CodeCampServer serves as a great example for me. I really like the different concepts which were implemented there and I can learn a lot from it. In my controllers I use Constructur Dependency Injection to get an insta...

NHibernate with StructureMap for a Non-Web Application

Hi, What is best pratices for inject and manage Session/Transaction for NHibernate using StructureMap for a Non Web Application like an Windows Service ? In a web context, we use PerRequest Session management lifecycle using the Hybrid Lifecycle of StructureMap but for a Windows Service, i can't handle IDisposable UnitOfWork ... Thank...

Using Factory to get Injected objects

Is it good practice to have a Factory method to retrieve injected objects or is it OK to just use the factory method from the DI framework? I'm using structure map, should I just use ObjectFactory.GetInstance();, or should I create factory class and inside this class call ObjectFactory.GetInstance();? because if I call ObjectFactory.Get...

Google Map : Update XML data based on the current viewable map area

Please direct me to a right source. I have a google map. I want to read data from XML file and display markers. But I also want to update this XML file, based on the "current viewable map". So if a user moves the map, then we update the XML file and display the appropriate markers on the map. What would be the best way to do this? ...

New To StructureMap - Getting No Default Instance Error 202

Hi. I am very new to StructureMap and am getting the following error: StructureMap Exception Code: 202 No Default Instance defined for PluginFamily Company.ProjectCore.Core.IUserSession, Company.ProjectCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null It seems to be hitting the first interface instance on compi...

StructureMap for Silverlight

Hey fellow coders, Has anyone tried to port the current StructureMap source to work with Silverlight? I know there are other IOC containers for Silverlight like Unity, Ninject, and a few others, but I particularly like the ease of use with StrutureMap. Anyways, I'm on a quest at the moment to get it working with SL. Let me know your ...

StructureMap Exception Code: 202 No Default Instance defined for PluginFamily

Hi. I am new to StructureMap. I have downloaded and am using version 2.6.1.0. I keep getting the below error: StructureMap Exception Code: 202 No Default Instance defined for PluginFamily Company.ProjectCore.Core.IConfiguration, Company.ProjectCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null My Global.asax...

How can I implement NHibernate session per request without a dependency on NHibernate?

I've raised this question before but am still struggling to find an example that I can get my head around (please don't just tell me to look at the S#arp Architecture project without at least some directions). So far I have achieved near persistance ignorance in my web project. My repository classes (in my data project) take an ISession...

Picking Up Repositories With Structuremap

I am not sure how to use StructureMap to scan for all repositories in a particular namespace. Most repositories take the form: namespace CPOP.Infrastructure.Repositories { public class PatientRepository : LinqRepository<Patient>, IPatientRepository { } } namespace CPOP.Infrastructure.Repositories { public class LinqRepo...

StructureMap - Injecting a dependency into a base class?

In my domain I have a handful of "processor" classes which hold the bulk of the business logic. Using StructureMap with default conventions, I inject repositories into those classes for their various IO (databases, file system, etc.). For example: public interface IHelloWorldProcessor { string HelloWorld(); } public class HelloWor...

StructureMap Issue in Initializing the Dependencies

I am performing some unit tests and want my MembershipProvider to initialize the dependencies. I run the following code before any test is executed [TestFixtureSetup]. public static void StructureMapConfiguration() { ObjectFactory.Initialize(InitializeUsingScanning); } private static void Initiali...

Can StructureMap be configured so that one can use different .config settings based on whether the project was built in debug or release mode?

I know that in StructureMap I can read from my *.config files (or files referenced by them), when I want to pass specific arguments to an object's constructor. ForRequestedType<IConfiguration>() .TheDefault.Is.OfConcreteType<SqlServerConfiguration>() .WithCtorArg("db_server_address") .Equa...

Inject generic parameters with structuremap 2.6

I need to inject generic repositories (IRepository) into my classes' constructors but I dont know how to do it with the new DSL in structuremap 2.6, does anyone know how? ...

How to get the NHibernate ISession that is HttpContextScoped by StructureMap.

Hi all I'm somewhat new to the MVC framework and in accordance with the following post: NHibernate with StructureMap I am not sure how to actually get the HttpContextScoped ISession in my controller? I'm sure there is a simple way to do this but I am unsure. Also, it's a small project and I don't want to go overboard with Enterprise D...

How do I pass null as the default instance of an Interface using StructureMap?

I'd like to pass null as the default instance of my IFarmManager class using StructureMap. I've currently got the following in my Global.asax: ObjectFactory.Initialize(x => { x.ForRequestedType<IFarmManager>().TheDefault.Is.Object(null); }; However, an ArgumentNullException is thrown at runtime: Value cannot be null. Parameter n...

Using StructureMap, how do you explicitly trigger the reinstantiation of a object with InstanceScope.Singleton?

I have an integration test harness where I want to teardown and then re-instantiate some of the singleton-scoped objects I've registered with StructureMap, after and before each test. This way I can simulate the actual run time environment, but not have the singleton's state being passed from one test to another. Maybe this isn't a g...

IoC: advantages of using a child container in web based app

I'm interested in knowing if there are any advantages to creating a child container for each request in a web based application? The tech stack I'm using includes StructureMap & ASP.NET MVC, which is not particularly relevant but included as background info. ...

Single website multiple connection strings using asp mvc 2 and nhibernate

Hi In my website i use ASP MVC 2 + Fluent NHibernate as orm, StructureMap for IoC container. There are several databases with identical metadata(and so entities and mappings are the same). On LogOn page user fiils in login, password, rememberme and chooses his server from dropdownlist (in fact he chooses database). Web.config contains...