Yesterday I was about to log into Facebook and I noticed it was taking too long to load the page... I opened Firebug and saw this:
Wow. Nice stairs, but it really hurts performance.
Squashing bugs all day long
Yesterday I was about to log into Facebook and I noticed it was taking too long to load the page... I opened Firebug and saw this:
Wow. Nice stairs, but it really hurts performance.
Some months ago I wrote SolrNet, an interface to Solr, mainly because I thought SolrSharp (the standard Solr interface for .net) was too verbose and IoC-unfriendly. I still think that way, but I always wondered what it would take to integrate it to Windsor (or any other IoC container, for that matter).
And the answer is... 241 lines of code (as per "wc -l *.cs"). That's it. That's all it took to write some interfaces and adapters and then wrap them in a Castle facility. That should teach me to try a bit harder next time! :-)
SolrNet was designed with IoC in mind, so integration is just a matter of registering a component:
<component id="solr" service="SolrNet.ISolrOperations`1, SolrNet" type="SolrNet.SolrServer`1, SolrNet">
<parameters>
<serverURL>http://localhost:8983/solr</serverURL>
</parameters>
</component>
Code is here. Note that it's just a proof of concept, I barely tested it!
public delegate Func<A, R> Recursive<A, R>(Recursive<A, R> r)
public static Func<A, R> Y<A, R>(Func<Func<A, R>, Func<A, R>> f) {
Recursive<A, R> rec = r => a => f(r(r))(a);
return rec(rec);
}
var RecGetFiles = Y<string, IEnumerable<string>>(f => d => Directory.GetFiles(d).Concat(Directory.GetDirectories(d).SelectMany(f)))Nice, isn't it? Sample usage:
foreach (var f in RecGetFiles(Directory.GetCurrentDirectory()))
Console.WriteLine(f);
It's probably not a good idea, though, to use this in production code, as it's not really necessary (just use regular recursion) and it harms readability.
public class HomeController : SmartDispatcherControllerNow you can write the redirect like this:
{
public void Index()
{
}
public void SaveInformation(String name, int age, DateTime dob)
{
// work work work
// Send the user back to the index
RedirectToAction("index");
}
}
this.RedirectToAction(c => c.Index());
public void Index(int a) {}
this.RedirectToAction(c => Index(1));
public class Properties {
public int SomeValue { get; set; }
}
public class SmartTest2Controller : SmartDispatcherController {
public void DataBinding([DataBind("prefi")] Properties prop) {}
public void Index() {
this.RedirectToAction(c => c.DataBinding(new Properties {SomeValue = 22}));
}
}
public class ARController : ARSmartDispatcherController {
public void Index() {
this.RedirectToAction(c => c.ARFetchAction(new Entity { PK = 5, Name = "Robert Duvall" }));
this.RedirectToAction(c => c.ARAction(new Entity { PK = 4, Name = "John Q" }));
}
public void ARAction([ARDataBind("pre")] Entity e) {}
public void ARFetchAction([ARFetch("pre")] Entity e) { }
}
Setup.ForAll(new DefaultExtensionsProvider {ExtUtils = new ARUtils()});This instructs the extension methods to use the ActiveRecord helpers.