SharpArchContrib.Castle.CastleWindsor.ComponentRegistrar.AddComponentsTo(container);
Also, the Transaction attribute uses castle dynamic proxy, which
requires a method to be virtual or be an implementation of an
interface that the container is returning. (If that Save method is on
a Controller, just change add the virtual keyword to it).
This should get this working properly.
> --
> You received this message because you are subscribed to the Google Groups "S#arp Architecture" group.
> To post to this group, send email to sharp-arc...@googlegroups.com.
> To unsubscribe from this group, send email to sharp-architect...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sharp-architecture?hl=en.
>
protected virtual IWindsorContainer InitializeServiceLocator()
{
IWindsorContainer container = new WindsorContainer();
SharpArchContrib.Castle.CastleWindsor.ComponentRegistrar.AddComponentsTo(container);
ControllerBuilder.Current.SetControllerFactory(new
WindsorControllerFactory(container));
container.RegisterControllers(typeof(HomeController).Assembly);
ComponentRegistrar.AddComponentsTo(container);
ServiceLocator.SetLocatorProvider(() => new
WindsorServiceLocator(container));
return container;
}
and make the Save method virtual
https://github.com/seif/Sharp-Architecture-Contrib/tree/develop
and start from there.
let me know if you run into issues, better yet, a pull request :)
http://help.github.com/fork-a-repo/
sorry for short replies, I am watching an online webinar :)
Do you a github account? do you have git configured on your machine?
have you used any other distributed version control system before?
http://help.github.com/win-set-up-git/
then, on https://github.com/sharparchitecture/Sharp-Architecture-Contrib
click the 'Fork' button, this will create a repository for you based
on the one from sharparchitecture team, which you have permissions to
push changes to.
on your local machine, you want to get the code from your repository:
git clone g...@github.com:YOUR_USER/Sharp-Architecture-Contrib.git
Hopefully this will work, whenit finishes, you will have the code on
the master branch on your repository. But we need to switch to
develop:
git checkout -t origin/develop
Now, you want to get my changes on your local machine.
First you add my github repository as a remote source (giving it the
name 'seif'):
git remote add seif git://github.com/seif/Sharp-Architecture-Contrib.git
git pull seif develop
Maybe I shouldn't have suggested the name seif for the repository, git
pull seif can have a funny meaning, ain't happening! :)
What happened now is that you have merged the changes from my branch
in your repository, if you push:
git push origin develop
your repository on github will have my changes on the develop branch. I think :)
Now, to get start with some work, code code code
git commit -a -m "Commit message here"
git push
And now your changes will be visible for the public, and you can do a
pull request! :)
Permission denied! :S have you setup your public key properly? follow
the instructions in http://help.github.com/win-set-up-git/ for setting
stuff up.
I know it isn't as easy to get up and starting with this stuff, but
once you have it running, it kicks svn/tfs ass, massivly!
So, in the project where you were using SharpArchContrib to start
with, remove all references of SharpArchContrib, clean the solution,
then from the nuget package manager console run:
install-package SharpArchContrib.Castle -pre
the pre is because this is a pre release, and to use this feature you
would need the latest version of nuget (1.6)
install-package SharpArchContrib.Castle -pre
I am surprised you got that Castle version problem, as the templify
project should already have binding redirects for that in the
web.config.
TO fix that, add this to the end of your web.config (before </configuration>):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.7.0" newVersion="4.0.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Castle.Windsor"
publicKeyToken="407dd0808d44fbdc" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
private static void AddGenericRepositoriesTo(IWindsorContainer
container)
{
container.Register(
Component.For(typeof(IEntityDuplicateChecker))
.ImplementedBy(typeof(EntityDuplicateChecker))
.Named("entityDuplicateChecker"));
container.Register(
Component.For(typeof(INHibernateRepository<>))
.ImplementedBy(typeof(NHibernateRepository<>))
.Forward(typeof(IRepository<>))
.Named("nhibernateRepositoryType"));
container.Register(
Component.For(typeof(INHibernateRepositoryWithTypedId<,>))
.ImplementedBy(typeof(NHibernateRepositoryWithTypedId<,>))
.Forward(typeof(IRepositoryWithTypedId<,>))
.Named("nhibernateRepositoryWithTypedId"));
container.Register(
Component.For(typeof(ISessionFactoryKeyProvider))
.ImplementedBy(typeof(DefaultSessionFactoryKeyProvider))
.Named("sessionFactoryKeyProvider"));
container.Register(
Component.For(typeof(SharpArch.Domain.Commands.ICommandProcessor))
.ImplementedBy(typeof(SharpArch.Domain.Commands.CommandProcessor))
.Named("commandProcessor"));
}
If that fails, can you upload the project somewhere so I can look at it?
To make sure it is not a problem with the contrib code, I used the
contrib transaction in a branch on the cookbook:
https://github.com/sharparchitecture/Sharp-Architecture-Cookbook/tree/contrib
Adding/Editing ProductModel works as expected when running the project.
Have you tried changing the component registrar as I suggested and it
didn't work for you??
I just changed the ComponentRegistrar to use your version of the
AddGenericRepositories, and I got a duplicate key exception! If you
have tried using the code I gave you and it doesn't work, you can
contact me via skype, I will be online for another 30 mins.