/// <summary> /// Creates a <typeparamref name="TDomainService"/> proxy instance that implements /// <typeparamref name="TDomainServiceContract"/>. /// </summary> /// <typeparam name="TDomainServiceContract">The <see cref="DomainService"/> contract interface.</typeparam> /// <typeparam name="TDomainService">The <see cref="DomainService"/> type that implements <typeparamref name="TDomainServiceContract"/>.</typeparam> /// <returns>Returns a <typeparamref name="TDomainService"/> proxy instance that implements /// <typeparamref name="TDomainServiceContract"/>.</returns> public static TDomainServiceContract Create <TDomainServiceContract, TDomainService>() where TDomainServiceContract : IDisposable where TDomainService : DomainService { // Create a HttpContextWrapper and use that as our context. HttpContextWrapper context = new HttpContextWrapper(HttpContext.Current); return(DomainServiceProxy.Create <TDomainServiceContract, TDomainService>(context)); }
/// <summary> /// Creates a <typeparamref name="TDomainService"/> proxy instance that implements /// <typeparamref name="TDomainServiceContract"/>. /// </summary> /// <typeparam name="TDomainServiceContract">The <see cref="DomainService"/> contract interface.</typeparam> /// <typeparam name="TDomainService">The <see cref="DomainService"/> type that implements <typeparamref name="TDomainServiceContract"/>.</typeparam> /// <param name="httpContext">The <see cref="HttpContextBase"/> instance that should be provided to <typeparamref name="TDomainService"/> /// proxy instances.</param> /// <returns>Returns a <typeparamref name="TDomainService"/> proxy instance that implements /// <typeparamref name="TDomainServiceContract"/>.</returns> public static TDomainServiceContract Create <TDomainServiceContract, TDomainService>(HttpContextBase httpContext) where TDomainServiceContract : IDisposable where TDomainService : DomainService { // Create a DomainServiceContext (with access to the provided HttpContextBase) and use that as our context HttpContextBaseServiceProvider serviceProvider = new HttpContextBaseServiceProvider(httpContext); DomainServiceContext context = new DomainServiceContext(serviceProvider, DomainOperationType.Query); return(DomainServiceProxy.Create <TDomainServiceContract, TDomainService>(context)); }