/// <summary> /// Creates the DataPortalProxy to use for DataPortal call on the objectType. /// </summary> /// <param name="objectType">Root business object type</param> /// <returns></returns> public IDataPortalProxy Create(Type objectType) { if (DataPortalTypeProxyDescriptors != null) { if (DataPortalTypeProxyDescriptors.TryGetValue(GetTypeKey(objectType), out DataPortalProxyDescriptor descriptor)) { var type = Type.GetType(descriptor.ProxyTypeName); return((IDataPortalProxy)Activator.CreateInstance(type, descriptor.DataPortalUrl)); } } if (_proxyType == null) { string proxyTypeName = ApplicationContext.DataPortalProxy; if (proxyTypeName == "Local") { _proxyType = typeof(LocalProxy); } else { _proxyType = Type.GetType(proxyTypeName, true, true); } } return((IDataPortalProxy)MethodCaller.CreateInstance(_proxyType)); }
/// <summary> /// Creates the DataPortalProxy to use for DataPortal call on the objectType. /// </summary> /// <param name="objectType">Root business object type</param> /// <returns></returns> public IDataPortalProxy Create(Type objectType) { if (DataPortalTypeProxyDescriptors != null) { if (DataPortalTypeProxyDescriptors.TryGetValue(GetTypeKey(objectType), out DataPortalProxyDescriptor descriptor)) { var type = Type.GetType(descriptor.ProxyTypeName); #if !NET40 && !NET45 if (ApplicationContext.ScopedServiceProvider != null) { var httpClient = ApplicationContext.ScopedServiceProvider.GetService(typeof(System.Net.Http.HttpClient)); if (httpClient == null) { return((IDataPortalProxy)MethodCaller.CreateInstance(type, descriptor.DataPortalUrl)); } else { return((IDataPortalProxy)MethodCaller.CreateInstance(_proxyType, httpClient, descriptor.DataPortalUrl)); } } else { return((IDataPortalProxy)MethodCaller.CreateInstance(type, descriptor.DataPortalUrl)); } #else return((IDataPortalProxy)Activator.CreateInstance(type, descriptor.DataPortalUrl)); #endif } } if (_proxyType == null) { string proxyTypeName = ApplicationContext.DataPortalProxy; if (proxyTypeName == "Local") { _proxyType = typeof(LocalProxy); } else { _proxyType = Type.GetType(proxyTypeName, true, true); } } #if !NET40 && !NET45 var provider = ApplicationContext.ScopedServiceProvider; if (provider == null) { return((IDataPortalProxy)MethodCaller.CreateInstance(_proxyType)); } else { return((IDataPortalProxy)Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(provider, _proxyType)); } #else return((IDataPortalProxy)MethodCaller.CreateInstance(_proxyType)); #endif }
/// <summary> /// Creates the DataPortalProxy to use for DataPortal call on the objectType. /// </summary> /// <param name="objectType">Root business object type</param> /// <returns></returns> public IDataPortalProxy Create(Type objectType) { if (DataPortalTypeProxyDescriptors != null) { if (DataPortalTypeProxyDescriptors.TryGetValue(GetTypeKey(objectType), out DataPortalProxyDescriptor descriptor)) { var type = Type.GetType(descriptor.ProxyTypeName); if (ApplicationContext.CurrentServiceProvider != null) { var httpClient = ApplicationContext.CurrentServiceProvider.GetService(typeof(System.Net.Http.HttpClient)); if (httpClient == null) { return((IDataPortalProxy)ApplicationContext.CreateInstance(type, descriptor.DataPortalUrl)); } else { return((IDataPortalProxy)ApplicationContext.CreateInstance(_proxyType, httpClient, descriptor.DataPortalUrl)); } } else { return((IDataPortalProxy)ApplicationContext.CreateInstance(type, descriptor.DataPortalUrl)); } } } if (_proxyType == null) { string proxyTypeName = ApplicationContext.DataPortalProxy; if (proxyTypeName == "Local") { _proxyType = typeof(LocalProxy); } else { _proxyType = Type.GetType(proxyTypeName, true, true); } } return((IDataPortalProxy)ApplicationContext.CreateInstance(_proxyType)); }