spring.net

Spring .Net Configuration Fluently

最后都变了- 提交于 2019-12-01 07:38:09
问题 I have the need to use Spring .Net in a project and am exploring configuration options. All I can find about config for Spring .Net is config file stuff. Does Spring support configuration in code? I have used Castle and Ninject, and both seem to offer this natively. I have found projects that claim to add support, but I dont want some knock off project that will die in 6 months. I have found references in blogs that seem to indicate Spring supports this but I cant find any documentation!!

How to configure RetryAdvice and ExceptionTranslation for Deadlocks using NHibernate and Spring

时光总嘲笑我的痴心妄想 提交于 2019-11-30 21:22:22
i am using Spring.net 1.2 with NHibernate 2.0.1. Within my project i'am facing some Deadlock issues and besides the database tweaks to minimize the occurence i would like to implement Springs RetryAdvice to handle this. I can't find any working example how to configure a this. The reference seems to be clear about how to use it but somehow i can't get it working. <!--Used to translate NHibernate exception to Spring.DataAccessExceptions--> <object type="Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor, Spring.Data"/> <!--ExceptionHandler performing Retry on Deadlocks-->

feeding dependencies to a factory class via IoC?

时光怂恿深爱的人放手 提交于 2019-11-30 15:41:58
I have a factory class that decides which of four available subclasses it should instantiate and return. As you would expect, all subclasses implement the same interface: public static class FooFactory{ public IFoo CreateFoo(FooEnum enum){ switch (enum) { case Foo1: return new Foo1(); case Foo2: return new Foo2(); case Foo3: return new Foo3(IBar);//has a constructor dependency on IBar case Foo4: return new Foo4(); default: throw new Exception("invalid foo!"); } } } As you can see, one of the subclasses has a dependency defined in its constructor. Some points of interest: We're using Spring.NET

Dependency injection / IoC in Workflow Foundation 4

别说谁变了你拦得住时间么 提交于 2019-11-30 13:50:56
问题 Is it possible to use DI in your workflow activities? and if yes, how? For example if you have an activity like public sealed class MyActivity : CodeActivity { public MyClass Dependency { get; set; } protected override void Execute(CodeActivityContext context) { Dependency.DoSomething(); } } how can i set Dependency ? (I'm using Spring.Net) 回答1: Workflow doesn't use an IOC container. It uses the ServiceLocator pattern where you add dependencies to the workflow runtime as extensions and

Dependency injection / IoC in Workflow Foundation 4

和自甴很熟 提交于 2019-11-30 08:37:38
Is it possible to use DI in your workflow activities? and if yes, how? For example if you have an activity like public sealed class MyActivity : CodeActivity { public MyClass Dependency { get; set; } protected override void Execute(CodeActivityContext context) { Dependency.DoSomething(); } } how can i set Dependency ? (I'm using Spring.Net) Workflow doesn't use an IOC container. It uses the ServiceLocator pattern where you add dependencies to the workflow runtime as extensions and workflow activities and retrieve these services from the workflow extensions through the context. A ServiceLocator

IoC, AOP and more

做~自己de王妃 提交于 2019-11-30 05:03:59
What is an IoC container? What is an IoC/DI framework? Why do we need a framework for IoC/DI? Is there any relationship between IoC/DI and AOP? What is Spring.net/ninject with respect to IoC and AOP? JMSA, James Kovacs wrote a fantastic article which covers many of your questions I would recommend reading it Here Spring.Net, Ninject, Unity, Castle Windsor, Autofac are all IOC containers which are configurable in different ways, many of them do also support AOP. Frameworks for IOC/DI are useful because they provide standard mechanisms, for example if you are hiring a new developer it is much

feeding dependencies to a factory class via IoC?

点点圈 提交于 2019-11-29 22:08:53
问题 I have a factory class that decides which of four available subclasses it should instantiate and return. As you would expect, all subclasses implement the same interface: public static class FooFactory{ public IFoo CreateFoo(FooEnum enum){ switch (enum) { case Foo1: return new Foo1(); case Foo2: return new Foo2(); case Foo3: return new Foo3(IBar);//has a constructor dependency on IBar case Foo4: return new Foo4(); default: throw new Exception("invalid foo!"); } } } As you can see, one of the

Spring.Net without configuring it in app.config

两盒软妹~` 提交于 2019-11-29 18:37:40
Is there way to configure the objects from inside the code rather than configuring it in xml or app.config file. On the spring.net homepage , you'll find an announcement for the CodeConfig project. CodeConfig allows you to create spring configuration from code, like for instance: [Configuration] public class MovieFinderConfiguration { [Definition] public virtual MovieLister MyMovieLister() { MovieLister movieLister = new MovieLister(); movieLister.MovieFinder = FileBasedMovieFinder(); return movieLister; } [Definition] public virtual IMovieFinder FileBasedMovieFinder() { return new

Configure an Envers RevisionListener via DI

空扰寡人 提交于 2019-11-29 11:09:22
To add an audit trail to our application we decided to use NHibernate.Envers. To allow app specific tracking of revisions, the DefaultRevisionEntity was extended with user specific data. public virtual void NewRevision( object revisionEntity ) { var revisionData = revisionEntity as Revision; if( revisionData != null ) { // Set additional audit data. var identity = UserAccessor.CurrentIdentity; revisionData.UserId = identity.UserId; revisionData.EmployeeId = identity.EmployeeId; revisionData.UserName = identity.Name; } } Envers decides wich RevisionListener to use depending on the

Reflection says that interface method are virtual in the implemented type, when they aren't?

吃可爱长大的小学妹 提交于 2019-11-29 09:26:09
I have the following code in an unit test public bool TestMethodsOf<T, I>() { var impl = typeof(T); var valid = true; foreach (var iface in impl.GetInterfaces().Where(i => typeof(I).IsAssignableFrom(i))) { var members = iface.GetMethods(); foreach (var member in members) { Trace.Write("Checking if method " + iface.Name + "." + member.Name + " is virtual..."); var implMember = impl.GetMethod(member.Name, member.GetParameters().Select(c => c.ParameterType).ToArray()); if (!implMember.IsVirtual) { Trace.WriteLine(string.Format("FAILED")); valid = false; continue; } Trace.WriteLine(string.Format(