How To Get Automatic Registration With Castle Windsor - inversion-of-control

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.

Related

Disable WADL generation Jersey 2.25.1 [duplicate]

I want to accomplish the same thing as this question: Disable automatic Wadl Generation for OPTIONS request, but we don't have a web.xml file. We also make use of ResourceConfig, where the getProperties method is final, so I cannot override that as suggested in other questions. I've tried calling property("com.sun.jersey.config.feature.DisableWADL", "true"); in our class that extends ResourceConfig, but that didn't work.
How can I disable WADL?
We're using Jersey 2.25.1. I tried reading the Jersey docs on WADL, but was unable to read the page because of a popup error message saying something about syntaxhighlightingerror/xml brush.
You're using the wrong property. Anything you see with com.sun.jersey is going to be for Jersey 1.x. The one you want is jersey.config.server.wadl.disableWadl, or better yet just use the constant.
ServerProperties.WADL_FEATURE_DISABLE

TYPO3 Hook not found

I am currently trying to write a Hook to add extra fields to a Flexform. Therefore I followed this tutorial: https://docs.typo3.org/typo3cms/extensions/news/DeveloperManual/ExtendNews/ExtendFlexforms/Index.html?fref=gc&dti=250938618364487#extend-flexforms-with-custom-fields
But when I go to a page in the backend that contains an options from a Flexform I get the following Error:
Class 'ID\SearchBarAdditional\Hooks\FlexFormHook' not found.
I register the Hook in the ext_localconf like this:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class]['flexParsing'][] = \ID\SearchBarAdditional\Hooks\FlexFormHook::class;
and my Hook-file is here: typo3conf/ext/search_bar_additional/Classes/Hooks
and is initialized that way:
namespace ID\SearchBarAdditional\Hooks;
class FlexFormHook { /* ... */
So in my opinion everything is in the right place and should work, but I do still get the error that TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("ID\SearchBarAdditional\Hooks\FlexFormHook") fails.
Do you guys have any ideas, what could be wrong? Do I have to register the Hook in \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( or something similar (as the posted code is really the only thing I've done)?
This is a typical class loading error. Check that you added your PHP namespaces to composer autoloading and/or ext_emconf.php and make sure your filenames are correctly named according to PSR-4. If in doubt you can inspect the class loading map files generated by composer in vendor/composer (if you use composer for class loading, which you definitely should do).
I found the mistake: My Hook does indeed not get loaded. I tried to 'include' it in the ext_localconf.php and it is working now.
But as this is of course an extremely ugly solution I posted a second question, how to load a hook here: Typo3 8.X - autoload Hook
Thank you for your help!!!

ZF2 Album tutorial using stored procedures

Please also suggest which namespace to use. I am new to zend and MVC.
module.php
public function getServiceConfig()
{
// what code here?
}
**Album\Model\Album.php**
{
//what code here?
}
**Album\Model\AlbumTable.php**
{
//what code here?
//do we have to use this class or a different class?
}
I can understand the sudden confusion when starting out with ZF2. However, the manual has really done a good job at helping those who are just starting out. You can find the most up-to-date information here : http://zf2.readthedocs.org/en/latest/user-guide/overview.html
Once you've got the Skeleton Application working I believe some of your confusion will be relieved. If not, come back and ask more specific questions OR you could even join the FreeNode IRC channel at #zftalk.
But to also help answer some of what you've asked here:
getServiceConfig() is where you will interact with the ServiceManager. Try to stay away from closures and work with Factories.
Album.php is sort of like the Hydrator. You don't have to use a Hydrator but for example purposes it was put here. It can make like easier in the long run.
AlbumTable.php is the Database Table you will be interacting with.
The namespace which is used in the tutorial is called Album. The Skeleton application comes packaged with a namespace called Application to start with.
You can manually download ZF2 here: https://packages.zendframework.com/
The latest skeleton application can be found here: https://github.com/zendframework/ZendSkeletonApplication
You may also choose to use Composer to install your entire application which tends to make the installation process much easier for those just starting out, so in your situation I'm going to recommend you use that. You can find instructions on how to use Composer here: http://zf2.readthedocs.org/en/latest/user-guide/skeleton-application.html

Autofac using DynamicProxy2 Interception with WcfIntegration

I'm struggling to wire up a service interface using WcfIntegration with an IInterceptor.
There are examples for each in the autofac documentation but nothing that combines the two.
Here is the documentation for the WcfIntegration and look here for the DynamicProxy2
documentation.
Has anyone successfully wired up an interceptor with WcfIntegration using Autofac?
Example code I'd have expected to work:
builder.Register(c => new CacheInterceptor())
.Named<IInterceptor>("cache-calls");
builder
.RegisterType<ChannelFactory<IEnquiryService>>()
.AsSelf()
.WithParameter(new NamedParameter("endpointConfigurationName", "EnquiryService"))
.SingleInstance();
builder
.Register(c => c.Resolve<ChannelFactory<IEnquiryService>>().CreateChannel())
.As<IEnquiryService>()
.EnableInterfaceInterceptors()
.InterceptedBy("cache-calls");
EDIT:
Seems like a bug has been logged on autofac site. Any work arounds for this?
As this has been raised as a bug on autofac bugtracker, If no one can see a workaround, I'll mark this as the answer. They have uploaded a console app reproducing the exact scenario.
http://code.google.com/p/autofac/issues/detail?id=361&q=dynamicproxy2
EDIT: This has now been fixed in the latest version

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.