示例#1
0
        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;
                        }
                    }
                }
            }
        }
示例#2
0
        public static object GetControllerFor <TContract>()
        {
            var viewType = typeof(TContract);
            var result   = Controllers.GetControllerFor(viewType);

            return(result);
        }