/// <exclude /> public bool Equals(DataSourceId dataSourceId) { if (dataSourceId == null) { return(false); } return(dataSourceId.ToString() == ToString()); }
public T GetDataFromDataSourceId <T>(DataSourceId dataSourceId, bool useCaching) where T : class, IData { if (null == dataSourceId) { throw new ArgumentNullException("dataSourceId"); } useCaching = useCaching && DataCachingFacade.IsTypeCacheable(typeof(T)); using (new DataScope(dataSourceId.DataScopeIdentifier, dataSourceId.LocaleScope)) { T resultData = null; string cacheKey = string.Empty; if (useCaching) { cacheKey = dataSourceId.ToString(); resultData = (T)_dataBySourceIdCache.Get(cacheKey); } if (resultData == null) { resultData = DataProviderPluginFacade.GetData <T>(dataSourceId.ProviderName, dataSourceId.DataId); if (useCaching && resultData != null && _dataBySourceIdCache.Enabled) { _dataBySourceIdCache.Add(cacheKey, resultData); } } if (useCaching && resultData != null) { resultData = DataWrappingFacade.Wrap(resultData); } DataInterceptor dataInterceptor; this.DataInterceptors.TryGetValue(typeof(T), out dataInterceptor); if (dataInterceptor != null) { try { resultData = dataInterceptor.InterceptGetDataFromDataSourceId <T>(resultData); } catch (Exception ex) { Log.LogError(LogTitle, "Calling data interceptor failed with the following exception"); Log.LogError(LogTitle, ex); } } return(resultData); } }
public T GetDataFromDataSourceId <T>(DataSourceId dataSourceId, bool useCaching) where T : class, IData { Verify.ArgumentNotNull(dataSourceId, nameof(dataSourceId)); useCaching = useCaching && DataCachingFacade.IsTypeCacheable(typeof(T)); using (new DataScope(dataSourceId.DataScopeIdentifier, dataSourceId.LocaleScope)) { T resultData = null; string cacheKey = string.Empty; if (useCaching) { cacheKey = dataSourceId.ToString(); resultData = (T)_dataBySourceIdCache.Get(cacheKey); } if (resultData == null) { resultData = DataProviderPluginFacade.GetData <T>(dataSourceId.ProviderName, dataSourceId.DataId); if (useCaching && resultData != null && _dataBySourceIdCache.Enabled) { _dataBySourceIdCache.Add(cacheKey, resultData); } } if (useCaching && resultData != null) { resultData = DataWrappingFacade.Wrap(resultData); } foreach (var dataInterceptor in GetDataInterceptors(typeof(T))) { try { resultData = dataInterceptor.InterceptGetDataFromDataSourceId <T>(resultData); } catch (Exception ex) { Log.LogError(LogTitle, ex); } } return(resultData); } }
/// <exclude /> public bool Equals(DataSourceId dataSourceId) { return(dataSourceId != null && dataSourceId.ToString() == ToString()); }
/// <exclude /> public bool Equals(DataSourceId dataSourceId) { if (dataSourceId == null) return false; return dataSourceId.ToString() == ToString(); }