BlackLinks.BlackApplication.ActivateActionCore C# (CSharp) Method

ActivateActionCore() public method

public ActivateActionCore ( Type controllerType, string actionName ) : BlackAction
controllerType System.Type
actionName string
return BlackAction
        public BlackAction ActivateActionCore(Type controllerType, string actionName)
        {
            if (controllerType == null)
                throw new ArgumentNullException ("controllerType");
            if (actionName == null)
                throw new ArgumentNullException ("actionName");
            var controllerInstance = (Controller)Activator.CreateInstance (controllerType);

            var actionType = (from nt in controllerType.GetNestedTypes ()
                where nt.Name == actionName
                select nt).FirstOrDefault ();
            if (actionType == null)
                throw new BlackException (string.Format ("No type for action '{0}' was found in controller '{1}'", actionName, controllerType.AssemblyQualifiedName), null);

            var actionInstance = (BlackAction)Activator.CreateInstance (actionType);
            controllerInstance.own (actionInstance);
            actionInstance.loadFilters ();
            return actionInstance;
        }