Got extension methods working for DynamicDocument. Exposes some new APIs publicly because they need to work with type finding and med trust, plus we need to expose these for MVC

This commit is contained in:
Shannon Deminick
2012-08-22 08:33:19 +06:00
parent 22c0350a4a
commit d7f8214d24
6 changed files with 83 additions and 42 deletions

View File

@@ -11,13 +11,21 @@ namespace Umbraco.Core.Dynamics
{
internal static class ExtensionMethodFinder
{
//TODO: This should be highly optimized!!! Calls to BuildManager.GetReferencedAssemblies() are really expensive!
private static List<MethodInfo> GetAllExtensionMethods(Type thisType, string name, int argumentCount, bool argsContainsThis)
{
//only scan assemblies we know to contain extension methods (user assemblies)
//var assembliesToScan = TypeFinder.GetAssembliesWithKnownExclusions();
var assembliesToScan = new List<Assembly>()
{
Assembly.Load("Umbraco.Tests")
};
//get extension methods from runtime
var candidates = (
from assembly in BuildManager.GetReferencedAssemblies().Cast<Assembly>()
from assembly in assembliesToScan
where assembly.IsDefined(typeof(ExtensionAttribute), false)
from type in assembly.GetTypes()
where (type.IsDefined(typeof(ExtensionAttribute), false)