Autofac property injection is not working - autofac

i am trying to use autofac for prism. Used bootstraper project link is bellow. autofac is passes depened object when i used as contructor parameter. but it's not passes when i use as property with a import attribute.
https://bitbucket.org/stmu/prism.aufofacextension/src
it's not a prism question. autofac is not inject properties. what is my mistake? how to solve this? thanks.

On your RegisterType calls, you most likely need to add .PropertiesAutowired().

Related

How to access SAPUI5 component from utility functions?

I would like to access my SAPUI5 app component using this.getOwnerComponent() from a utility function, for example formatter or a class function, this works from controllers but in a utility or formatter function placed in another folder doesn't work. I do not want to use sap.ui.getCore(), is there any other way to do it?
I ended up with below two choices:
1. Create the utility functiona as a singleton class and pass the component one time with a setComponent method.
2. Use event bus to fire events and get things done by component that can be done only within the component like accessing oData resources
You could pass the controller instance to your utility class in the constructor, and then access its owner component. You could also try injecting the component directly. Unfortunately, I am not sure if any of these is the preferred way in UI5 development.
That would couple the utility function to the component logic though, which I do not think is a good idea, you probably should pass only what is required for the utility function to do its' job.

MVC4 Scaffolding, DBContext in different assembly

I've been trying to scaffold out a DBContext class (Code first), which resides in a different assembly with the reference added to the current MVC project.
VS2012 is giving me a message that says that the DBContext is in a different assembly and that, it is not able to modify the class. I understand that it won't be able to modify the class as it is in a different assembly, but the class already has the required DBSets as fields.
The solution that comes to my mind is to create proxy DBContext in my MVC project, use it to scaffold it out and link it to the original DBcontext inside the controller.
Are there any correct/better/easier way around this? Am I missing something really obvious here?
Thank you.

IoC, MVC4 Web API & HttpParameterBinding/ParameterBindingAttribute

I'm using ASP.Net MVC 4 RTM Web API. I have a controller action with a parameter that I'd like to populate via custom model binding. To achieve this, I created a class that derives from System.Web.Http.Controllers.HttpParameterBinding that sets the value of this parameter. I then created an attribute class that derives from System.Web.Http.ParameterBindingAttribute which I use to decorate the parameter on my controller action.
This is all working great, my HttpParameterBinding class is populating the action parameter correctly. The problem I have is that my custom parameter binding class has a dependency that I'd like resolved via my IoC container (Unity). Is there a way to override how Web API creates HttpParameterBinding instances so that I can build up my custom binding class dependency from Unity? I was able to do something similar for a filter attribute by creating a custom filter provider that uses Unity's BuildUp method to populate dependencies, however I'm not seeing anything similar for Web API's HttpParameterBindings.
In general: to use IoC / Unity in the Web API you need to set it up seperately.
Try downloading the nuget package Unity.WebApi and see if that helps!
Take a look at this article: Parameter Binding in WebAPI
It walks through a couple different options from Converters to Binders to BinderProviders. It sounds like you may be able to write a custom ModelBinderProvider which knows how to provide your dependency. If that isn't high enough in the chain you can look at replacing the default IActionValueBinder service. It's a DefaultActionValueBinder instance, which you can extend or simply re-implement.
I also highly recommend downloading the WebAPI source code, as it's been an incredible help for these issues as I've run into them. Here's the WebAPI source code. I recommend downloading it so you can open it in VS for easy navigation.
Feel free to check out FlitBit too (It's very modular, don't let the number of packages scare you off)! I'm working on a WebAPI package for supporting FlitBit, specifically FlitBit.IoC and FlitBit.Dto. I'll add an update if I work out my IoC issue, since it's very similar to yours.

Wicket 1.4 EJB Support

I tried implementing the JavaEE Inject jar from Wicket Stuff. (glassfish v3, wicket 1.4)
- however, the code given in the tutorial doesn't work
method
addComponentInstantiationListener in
class org.apache.wicket.Application
cannot be applied to given types
required:
org.apache.wicket.application.IComponentInstantiationListener
found:
org.wicketstuff.javaee.injection.JavaEEComponentInjector
looks to me like the API has changed. The JIRA link inside
http://wicketstuff.org/confluence/display/STUFFWIKI/JavaEE+Inject
and the Repository link are both broken. Is it still maintained?
Another short question: Is it possible to populate ListView directly with entity beans? I'd like to avoid too many proxy classes.
Thanks in advance
Yes, you can inject a ListView with entity beans. You should do so by creating an implementation of IDataProvider (or one of it's sub-interfaces) for the iterator and have it wrap the entities with LoadableDetachableModel so they can be reloaded instead of serialized as a part of the session.
Figured it out: I didn't expect there to be a difference between 1.4.13 and 1.4.14 but apparently the API changed there significantly.

RegisterType not in Autofac 2.3.2?

Using AutoFac 2.3.2, I am trying to do the following:
var builder = new Autofac.ContainerBuilder();
builder.RegisterType<SomeDependency>().As<IDependency>();
RegisterType is not there. Not seeing it with intellisense, compiler doesn't know it's there. Looking in the help shows that the RegisterType method is an extension method. Is there something I'm missing? Why is this extension method not showing up?
I'm using VS2010, attempting the above code in a test project and a web application project.
You need to use use Autofac or use the static method directly.
use Autofac;
namespace X
{
builder.RegisterType<MyType>();
}
or
Autofac.RegistrationExtensions.RegisterType<MyType>(builder);