Created
December 27, 2010 17:54
-
-
Save rauhryan/756357 to your computer and use it in GitHub Desktop.
use of func hash in fubu...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override string CreateTemplate(object input, Func<object, object>[] hash) | |
{ | |
string url = Pattern; | |
_routeInputs.Where(x => x.CanTemplate(input)) | |
.Each(r => url = r.Substitute((T)input, url)); | |
if (hash != null) | |
hash.Each(func => | |
{ | |
var name = func.Method.GetParameters()[0].Name; | |
var rawValue = func(null); | |
url = url.Replace("{" + name + "}", rawValue.ToString().UrlEncoded()); | |
}); | |
url = fillQueryInputs(url, input); | |
return url.Replace("{", "${").ToAbsoluteUrl(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment