public object GetService(Type serviceType) { System.Diagnostics.Debug.WriteLine(serviceType.FullName); if (serviceType == typeof(CustomerController)) { var service = new CustomerService(); return new CustomerController(service); } return null; }
public IHttpController Create( HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) { if (controllerType == typeof(CustomerController)) { var customerService = new CustomerService(); // 建立相依物件 request.Properties.Add("Time", DateTime.Now); // 傳遞額外資訊 return new CustomerController(customerService); } return null; }