private void InjectControllers() { var properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty); foreach (var property in properties) { var propertyType = property.PropertyType; var attributes = propertyType.GetCustomAttributes <ApplicationControllerAttribute>(true); if (attributes != null) { foreach (var attribute in attributes) { if (attribute != null) { var controller = Controllers.GetControllerFor(propertyType); if (controller != null) { property.SetValue(this, controller); Controllers.RaiseInjected(this, controller); } break; } } } } }
public static object GetControllerFor <TContract>() { var viewType = typeof(TContract); var result = Controllers.GetControllerFor(viewType); return(result); }