Hi,
I have problem to setup sharprepository + structuremap. have you checked with last versions?:
I am using new container as objectfactory is deprecated and it doesnt recognize:
x.ForRepositoriesUseSharpRepository
it also doesnt recognize context.BuildStack.
These are errors I get:
Error 29 'StructureMap.IContext' does not contain a definition for 'BuildStack' and no extension method 'BuildStack' accepting a first argument of type 'StructureMap.IContext' could be found (are you missing a using directive or an assembly reference?)
Error 26 Cannot convert lambda expression to type 'StructureMap.Configuration.DSL.Registry' because it is not a delegate type
Error 28 Cannot convert lambda expression to type 'StructureMap.Pipeline.Instance' because it is not a delegate type
Could you advice what is wrong?
Programs.cs: Main()
var container = new Container(x =>
{
x.Scan(scan =>
{
scan.Assembly(“Services");
});
x.For<JobsService>().Use<JobsService>();
x.For<IJobsRepository>().Use<JobsRepository>();
x.For(typeof(IRepository<>))
.Use(context =>
{
var genericArgs = context.BuildStack.Current.RequestedType.GetGenericArguments();
return RepositoryFactory.GetInstance(genericArgs[0], repositoryName);
}
);
x.For(typeof(IRepository<,>))
.Use(context =>
{
var genericArgs = context.BuildStack.Current.RequestedType.GetGenericArguments();
return RepositoryFactory.GetInstance(genericArgs[0], genericArgs[1], repositoryName);
}
);
x.ForRepositoriesUseSharpRepository();
});
container.AssertConfigurationIsValid();
Application service:
public class JobsService
{
private readonly IRepository<Jobs, int> _jobsRepository;
public JobsService(IRepository<Jobs, int> repository )
{
_jobsRepository = repository;
}
public List<Jobs> GetAll()
{
var rp = new Jobs {Name = "Job1"};
_jobsRepository.Add(rp);
var a = _jobsRepository.GetAll().ToList();
return a.ToList();
}
}
Do you have simple sample project that you can send or upload that shows a working solution of structuremap + sharprepository for application services and EF and InMemoery repository?
Thanks
That package has not been updated to work with StructureMap 3. I will work on getting some working code and post it back here for you to use. Then we will work on getting the NuGet package updated, or a separate one for version 3 depending on the need.
Thanks,
Jeff
--
You received this message because you are subscribed to the Google Groups "SharpRepository" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
sharpreposito...@googlegroups.com.
To post to this group, send email to
sharpre...@googlegroups.com.
Visit this group at http://groups.google.com/group/sharprepository.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sharprepository/01db01cfda9f%244343b640%24c9cb22c0%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.