protected IExceptionTargetEvaluation this[string key] { get { if (InterfaceInstanceList.ContainsKey(key)) { return(InterfaceInstanceList[key]); } else { List <InterfaceInstance> interfaces = InterfaceInstanceOperator.Instance.LoadListByName("IExceptionTargetEvaluation"); InterfaceInstance newInstance = interfaces.Find(I => I.InterfaceInstanceName == key); if (newInstance != null) { IExceptionTargetEvaluation _interface = ExceptionTargetEvaluationBuilder.Instance.DoBuild(newInstance.Reference); if (_interface != null) { AddHandle(newInstance.InterfaceInstanceName, _interface); return(_interface); } } } return(DefaultHandle); } }
protected void AddHandle(string InstanceName, IExceptionTargetEvaluation interfaceInstance) { if (!InterfaceInstanceList.ContainsKey(InstanceName)) { InterfaceInstanceList.Add(InstanceName, interfaceInstance); } else { InterfaceInstanceList[InstanceName] = interfaceInstance; } }
public ExceptionTargetEvaluationEngine() { //注册 AddHandle("*", new DefaultExceptionTargetEvaluation()); List <InterfaceInstance> interfaces = InterfaceInstanceOperator.Instance.LoadListByName("IExceptionTargetEvaluation"); //注册扩展服务 foreach (InterfaceInstance info in interfaces) { //根据InterfaceInstanceName,实现不同的处理方法 IExceptionTargetEvaluation _interface = ExceptionTargetEvaluationBuilder.Instance.DoBuild(info.Reference); if (_interface != null) { AddHandle(info.InterfaceInstanceName, _interface); } } }