Skip to content

Instantly share code, notes, and snippets.

@aruss
Last active August 29, 2015 13:56
Show Gist options
  • Save aruss/9343919 to your computer and use it in GitHub Desktop.
Save aruss/9343919 to your computer and use it in GitHub Desktop.
Dependency Resolver Action
public class DependencyController : Controller
{
public ActionResult Index(string repositoryName, string assembyName, string typeFullName)
{
if (!String.IsNullOrWhiteSpace(assembyName) &&
!String.IsNullOrWhiteSpace(typeFullName))
{
var assembly = Assembly.Load(assembyName);
if (assembly != null)
{
var serviceType = assembly.GetTypes().FirstOrDefault(c =>
c.FullName.Equals(typeFullName, StringComparison.InvariantCultureIgnoreCase));
if (serviceType != null)
{
var data = EngineContext.Current.ResolveAll(serviceType)
.Select(s => s.GetType())
.OrderBy(x => x.Name)
.ToDictionary(
c => String.Format("{0}, {1}", c.Assembly.GetName().Name, c.FullName),
c => String.Format("{0}, {1}", c.Assembly.GetName().Name, c.FullName)
);
return this.Json(data, JsonRequestBehavior.AllowGet);
}
}
}
return this.Json(new Dictionary<string, string>(), JsonRequestBehavior.AllowGet);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment