void RegisterViewType(Type viewType, MvcViewAttribute attrib) { // View to controller mapping var pairName = _pairRule.GetNameByView(attrib.Name); ViewControllerPair pair; if (_ctrlName2Pairs.TryGetValue(pairName, out pair)) { if (pair.ViewConcreteType != null) { throw new Exception("Register duplicatedly!"); } } else { pair = new ViewControllerPair(); _ctrlName2Pairs.Add(pairName, pair); } pair.ViewConcreteType = viewType; }
void RegisterControllerType(Type controllerType, MvcControllerAttribute attrib) { var pairName = _pairRule.GetNameByController(attrib.Name); ViewControllerPair pair; if (_ctrlName2Pairs.TryGetValue(pairName, out pair)) { if (pair.ControllerType != null || pair.PairName != null || pair.ViewContractType != null) { throw new Exception("Register duplicatedly!"); } } else { pair = new ViewControllerPair(); _ctrlName2Pairs.Add(pairName, pair); } pair.ViewContractType = GetViewContractType(controllerType); pair.ControllerType = controllerType; pair.PairName = pairName; }
public bool TryGetViewControllerPair(string pairName, out ViewControllerPair viewControllerPair) { return(_ctrlName2Pairs.TryGetValue(pairName, out viewControllerPair)); }