Comments (7)
Yes, I did.
from contosouniversity.
here's my mediator module: https://gist.github.com/AlonAmsalem/b76efecb436fbb1a67add18de1f85a69
from contosouniversity.
@AlonAmsalem Thanks for this, very useful. Have you managed to convert other classes in the project?
And this one MvcTransactionFilter.cs
from contosouniversity.
Here's how I implemented the transaction-filter
public class TransactionFilter : IAutofacActionFilter
{
public void OnActionExecuting(HttpActionContext actionContext)
{
var requestScope = actionContext.Request.GetDependencyScope();
var context = requestScope.GetService(typeof(CloudinatorContext)) as CloudinatorContext;
context?.BeginTransaction();
}
public void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
var requestScope = actionExecutedContext.Request.GetDependencyScope();
var context = requestScope.GetService(typeof(CloudinatorContext)) as CloudinatorContext;
context?.CloseTransaction(actionExecutedContext.Exception);
}
}
from contosouniversity.
I don't use the Html-Helper-Extensions because my client-side is a standalone AngularJS
from contosouniversity.
Here's my Global.asax, you'll need it for the transaction-filter
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
var container = IoC.Initialize();
GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configure(WebApiConfig.Register);
AutoMapperBootstrapper.Initialize(container);
AreaRegistration.RegisterAllAreas();
}
}
from contosouniversity.
private static IElementGenerator<T> GetGenerator<T>(T model) where T : class
{
var library =
StructuremapMvc.ParentScope.CurrentNestedContainer.GetInstance<HtmlConventionLibrary>();
return ElementGenerator<T>.For(library, t => StructuremapMvc.ParentScope.CurrentNestedContainer.GetInstance(t), model);
}
I'm still having problems converting this to Autofac. I tried this but it doesn't work.
private static IElementGenerator<T> GetGenerator<T>(T model) where T : class
{
var library = AutofacDependencyResolver.Current.RequestLifetimeScope.Resolve<HtmlConventionLibrary>();
return ElementGenerator<T>.For(library, t => AutofacDependencyResolver.Current.RequestLifetimeScope.Resolve(t), model);
}
from contosouniversity.
Related Issues (20)
- How would you implement authorization business logic? HOT 1
- Areas HOT 3
- Use of Attribute Routing possible? HOT 4
- Autofac? HOT 4
- FormBlocks HOT 1
- Dispatching messages from command handler after committing DB transaction HOT 1
- HtmlTags v4 support HOT 3
- Unable to create instructor HOT 2
- RedirectToActionJson HOT 1
- Add .vs folder to gitignore
- using roundhouse; error after yesterday update
- Basic DropDownList HOT 4
- Why is MvcTransactionFilter related to SchoolContext ? HOT 5
- Unable to add a new department
- ASP.NET Core HOT 1
- Should features own the domain model as well? HOT 1
- Generic Notifications HOT 3
- Question: indexer on foreach HOT 1
- FxCop CA1034 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contosouniversity.