/// <summary> /// 获取服务实例 /// </summary> /// <typeparam name="TService">服务类型</typeparam> /// <param name="request">request</param> /// <returns>服务实例</returns> public static TService GetService <TService>(this HttpRequestMessage request) { System.Web.Http.Dependencies.IDependencyScope dependencyScope = request.GetDependencyScope(); TService service = (TService)dependencyScope.GetService(typeof(TService)); return(service); }
/// <summary> /// Constructor to create the Model inputs and set all the properties /// (Done as constructor with private setters so that when a new property /// is added we don't miss places that need to populate it) /// </summary> /// <param name="user"></param> /// <param name="clientCertificate"></param> /// <param name="httpMethod"></param> /// <param name="requestUri"></param> /// <param name="baseUri">The Base URI is the actual FHIR url used for this request, will end with /fhir/</param> public ModelBaseInputs( IPrincipal user, X509Certificate2 clientCertificate, string httpMethod, Uri requestUri, Uri baseUri, System.Web.Http.Dependencies.IDependencyScope dependencyScope) { this.User = user; this.ClientCertificate = clientCertificate; this.HttpMethod = httpMethod; this.RequestUri = requestUri; this.BaseUri = baseUri; this.DependencyScope = dependencyScope; }
/// <summary> /// Constructor to create the Model inputs and set all the properties /// (Done as constructor with private setters so that when a new property /// is added we don't miss places that need to populate it) /// </summary> /// <param name="baseUri">The Base URI is the actual FHIR url used for this request, will end with /fhir/</param> public SystemModelBaseInputs( Uri baseUri, System.Web.Http.Dependencies.IDependencyScope dependencyScope) : base(GetSystemPrincipal(), null, null, null, baseUri, dependencyScope) { }
public static T GetService <T>(this System.Web.Http.Dependencies.IDependencyScope scope) { return((T)scope.GetService(typeof(T))); }