<commit_before>Safe Dependency Injection with Sitecore
=======================================

This repo contains sample code for using a chained dependency resolver within Sitecore.
The code is discussed in the following blog post:-


Both MVC and WebApi chained resolvers can be found in the Common.Web project, with a Castle Windsor implementation in the other projects.

The TDS.Master project contains:-
 - Sample MVC layouts/views from my [Sample-Default-Sitecore-MVC repo](https://github.com/SaintSkeeta/Sample-Default-Sitecore-MVC)
 - a Sitecore Controller Rendering with the custom controller that gets an ILogger resolved
 - the Home item where the above are stored.

URLs to check it out
--------------------
There are a couple of URLs that could be directly hit to trigger both the MVC and WebApi custom controllers.

 - / (the Home item that has the renderings on it)
 - /api/sitecore/mycustom/myaction (explicit call to the MVC controller directly)
 - /api/Custom/MyCustomWebApi/MyAction (custom route to the WebApi controller)
 - /api/Custom/MyCustomWebApi/MyActionWithFilter (custom route to the WebApi controller, with a custom Action filter on it)
 


A Note about the Chained Resolvers
----------------------------------
The chained resolvers check for null returning from the inner resolver. We found this to be more performant than having the inner resolver throw and exception, and the chained resolver catching it.
If you would prefer for the inner resolver to throw, you can make the chained resolver adjustments accordingly.


<NAME>
http://www.seanholmesby.com/
[@seanholmesby](http://twitter.com/seanholmesby)<commit_msg>Updated README with more info about blog post, Nuget Packages etc.<commit_after>Safe Dependency Injection with Sitecore
=======================================

This repo contains sample code for using a chained dependency resolver within Sitecore.
The code is discussed in detail in the following blog post:-

[Safe Dependency Injection for MVC and WebApi within Sitecore](http://www.seanholmesby.com/safe-dependency-injection-for-mvc-and-webapi-within-sitecore/)


Both MVC and WebApi chained resolvers can be found in the Common.Web project, with a Castle Windsor implementation in the other projects.

The TDS.Master project contains:-

 - Sample MVC layouts/views from my [Sample-Default-Sitecore-MVC repo](https://github.com/SaintSkeeta/Sample-Default-Sitecore-MVC)
 - a Sitecore Controller Rendering with the custom controller that gets an `ILogger` resolved
 - the Home item where the above are stored.

Nuget Packages and Versions
---------------------------
The versions of the Nuget packages in this project correspond to Sitecore 8.0 Update-5 (rev. 150812). For other Sitecore versions, either update the packages to the correct versions, or view other branches on this repository (if available).

The `SitecoreKernel` package is referenced here, but will need to be restored from your own local repository (as we cannot share Sitecore DLLs).
This package was generated with an older, preferred version of the [Sitecore Nuget Package Generator](https://bitbucket.org/sitecoresupport/sitecore-nuget-packages-generator/wiki/Home), which can be found here:-

[https://bitbucket.org/seanholmesby/sitecore-nuget-packages-generator/](https://bitbucket.org/seanholmesby/sitecore-nuget-packages-generator/)

URLs to test with
-----------------
There are a couple of URLs that could be directly hit to trigger both the MVC and WebApi custom controllers.

 - / (the Home item that has the renderings on it)
 - /api/sitecore/mycustom/myaction (explicit call to the MVC controller directly)
 - /api/Custom/MyCustomWebApi/MyAction (custom route to the WebApi controller)
 - /api/Custom/MyCustomWebApi/MyActionWithFilter (custom route to the WebApi controller, with a custom Action filter on it)
 


A Note about the Chained Resolvers
----------------------------------
The chained resolvers check for null returning from the inner resolver. We found this to be more performant than having the inner resolver throw and exception, and the chained resolver catching it.
If you would prefer for the inner resolver to throw, you can make the chained resolver adjustments accordingly.

Thanks to <NAME> and <NAME> for their help with this implementation.

<NAME>
[http://www.seanholmesby.com/](http://www.seanholmesby.com/)
[@seanholmesby](http://twitter.com/seanholmesby)
{'fraction_non_alphanumeric': 0.1073855913004078, 'fraction_numerical': 0.0020389669234254643, 'mean_word_length': 4.022753128555176, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 5, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4165684', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1114, 'n_words': 522}