Last active
August 29, 2015 13:56
-
-
Save aruss/9343919 to your computer and use it in GitHub Desktop.
Dependency Resolver Action
This file contains 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 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