RegisterType not in Autofac 2.3.2? - autofac

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);

Related

How to create SDK with framework that using cocoa-pods

I have a framework that using with some cocoa pods.
now I'm trying to create SDK from the framework, but don't show all the classes, how do I do it?
Make sure that the public keyword is in front of your class declaration - they changed the scope default from public by default to private.

Autofac property injection is not working

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().

Zend Application not fully bootstraped when testing with PHPUnit

Zend Framework 1.11.2
PHPUnit 3.5.10
PHP 5.3.1
NetBeans 6.9.1
http://pastebin.com/L5bi9AgY
I followed Lebensold's tutorial.
Testing works, even with things like
$this->dispatch('/');
$this->assertResponseCode(200);
, but as soon as I require a controller class (pastebin, #33) to instantiate it in the setUp() method, I get an error saying that PHPUnit didn't find the parent class (Zend_Controller_Action). So my guess is that I've somehow missed something in bootstrap, because I don't get all the classes loaded (?).
Also, when using the "#covers Class::method" annotation, I get the same type of error.
Any suggestions are welcomed. Thanks.
Try requiring the controller class from within your setup, e.g.
class SearchControllerTest extends ControllerTestCase {
public function setUp() {
parent::setUp();
require_once(APPLICATION_PATH . '/controllers/SearchController.php');
}
}
I remember having similar problem and it worked this way.

RegisterType<> Not visible on Silverlight

I was following an example found here on StackOverflow, and everything went well until I need to register my types.
My web application is running on Silverlight 4, with Prism and MVVM.
The example is using "Microsoft.Practices.Unity" (it's a windows form application)
Bootstrapper.cs
protected override void ConfigureContainer()
{
base.ConfigureContainer();
Container.RegisterType<IApplicationMenuRegistry, MenuRegistry>();
Container.RegisterType<IApplicationCommands, ApplicationCommands>();
Container.RegisterType<ShellViewModel, ShellViewModel>(new Microsoft.Practices.Unity.ContainerControlledLifetimeManager());
}
Mine is using: Microsoft.Practices.Unity.Silverlight (web) and throws the following error:
The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.RegisterType(...) cannot be used with type arguments.
And the RegisterType<> constructor is not visible for me. Which alternatives do I have to register my types?
I am using Unity for Silverlight and have not had this issue.
According to this post, http://unity.codeplex.com/workitem/8205, you need to add "using Microsoft.Practices.Unity;" to the file. The generic versions of Resolve are extension methods and you need to pull in the namespace to use them.
Apparently ReSharper may think the using statement is not needed and may remove it.
Hope that helps.

How To Get Automatic Registration With Castle Windsor

I recently read Ayende's blog post on automatic registration working with XML Configuration. I would like to do exactly what he does, but his code snippet doesn't work for me. The Register method doesn't exist on my container object.
Here's his code:
var container = new WindsorContainer(new XmlInterpreter());
container.Register(
AllTypes.Of(typeof (ConsumerOf<>))
.FromAssembly(typeof(Program).Assembly)
);
Is there a DLL reference I'm missing? Is Register() an extension method and I don't have the right namespace referenced? I've looked at the Castle Docs but can't seem to find a solution.
Bah! Nevermind. I'm using RC-3, and the Register() method is only in the trunk.