我想在我的项目中添加WebServices的依赖注入。 在 App_Start> ApiRouteConfig 中,我需要添加依赖项注入解析器吗? 当我在浏览器中打开时,在构造函数中出现错误。
我在控制器中
public class TicketController : ApiController
{
private readonly IInstitutionManager _institution;
public TicketController(ICharacterRepository institution)
{
_institution = institution;
}
}
在界面中:
public interface IInstitutionManager {
InstitutionItem GetInstitutionsById(int id, string guid);
}
在课堂上:
internal class InstitutionsManager : PublicAdministrationsManager
{
internal static InstitutionsManager manager;
private const string DEFAULT_INSTITUTION_IMAGE = "ph";
/// <summary>
/// Get Instance
/// </summary>
/// <returns></returns>
internal static InstitutionsManager GetInstance()
{
if (manager == null)
{
manager = new InstitutionsManager();
LoadImagesForInstitutions();
}
return manager;
}
/// <summary>
/// Get Institution details by institutionID
/// </summary>
/// <param name="guid"></param>
/// <param name="id">institutions ID</param>
/// <returns></returns>
InstitutionItem GetInstitutionsById(int id, string guid)
{
List<InstitutionItem> institutions = GetInstitutions(guid, false);
InstitutionItem item = institutions != null ? institutions.FirstOrDefault(x => x.Id == id.ToString()) : null;
return item;
}
}