Ejemplo n.º 1
0
 public static IEnumerable <IDataProvider> LoadLocalDataProviders(DataProvidersConfigurationSection section, Type interfaceType)
 {
     return(GetAvailableDataProviderTypes(section, interfaceType, false)
            .Select(
                t => Reflection.CreateInstance <IDataProvider>(t)
                ));
 }
Ejemplo n.º 2
0
        public static IEnumerable <Type> GetAvailableDataProviderTypes(DataProvidersConfigurationSection section, Type interfaceType, bool isExternal)
        {
            if (interfaceType == null)
            {
                interfaceType = typeof(IDataProvider);
            }

            if (section != null)
            {
                try
                {
                    var typesConfigurationElements = new TypeElement[section.Types.Count];
                    section.Types.CopyTo(typesConfigurationElements, 0);

                    return(typesConfigurationElements
                           .Select(typeConfigElement =>
                    {
                        try
                        {
                            string typeName = typeConfigElement.TypeName;
                            Type t = Type.GetType(typeName);
                            if (interfaceType.IsAssignableFrom(t))
                            {
                                if (t.IsClass && !t.IsAbstract && typeof(IDataProvider).IsAssignableFrom(t))
                                {
                                    if (isExternal && typeof(IExternalDataProvider).IsAssignableFrom(t))
                                    {
                                        return t;
                                    }
                                    else if (!isExternal && !typeof(IExternalDataProvider).IsAssignableFrom(t))
                                    {
                                        return t;
                                    }
                                }
                            }
                        }
                        catch (System.Reflection.ReflectionTypeLoadException ex)
                        {
                            Local.Admin.LogException(ex, ex.LoaderExceptions);
                        }
                        catch (Exception ex)
                        {
                            Local.Admin.LogException(ex);
                        }
                        return null;
                    })
                           .Where(t => t != null));
                }
                catch (Exception ex)
                {
                    Local.Admin.LogException(ex);
                }
            }
            return(new Type[0]);
        }
Ejemplo n.º 3
0
        public IEnumerable <TInterface> CreateDataProviders(SourceUsageOrder sourceUsageOrder)
        {
            DataProvidersConfigurationSection section = DataProvidersConfigurationSection.GetCurrent();

            DataProvider[] dbProviders = DataProviderManager.ReadDatabaseDataProviders();

            var dataProviders = DataProviderManager.GetDataProviderList(section, dbProviders, typeof(TInterface), sourceUsageOrder)
                                .Select(p => p as TInterface);

            return(dataProviders);
        }
Ejemplo n.º 4
0
        public StandardReturType CreateDataProviders(out IEnumerable <ISingleDataProvider <TInputElement, TOutputElement> > dataProviders, SourceUsageOrder sourceUsageOrder)
        {
            DataProvidersConfigurationSection section = DataProvidersConfigurationSection.GetCurrent();

            DataProvider[] dbProviders = DataProviderManager.ReadDatabaseDataProviders();

            dataProviders = DataProviderManager.GetDataProviderList(section, dbProviders, InterfaceType, sourceUsageOrder)
                            .Select(p => p as ISingleDataProvider <TInputElement, TOutputElement>);
            if (dataProviders.FirstOrDefault() == null)
            {
                Local.Admin.AddNewLog(TraceEventType.Warning, BrokerContext.Current.WebMethodMessageName, TextMessages.NoDataProvidersFound, null, null);
                return(StandardReturType.Create(HttpErrorCode.DATASOURCE_UNAVAILABLE));
            }
            return(StandardReturType.OK());
        }
Ejemplo n.º 5
0
        public virtual SubMethodRunState[] CreateSubMethodRunStates(out bool missingDataProvidersExist)
        {
            DataProvidersConfigurationSection section = DataProvidersConfigurationSection.GetCurrent();

            DataProvider[] dbProviders = DataProviderManager.ReadDatabaseDataProviders();

            var subMethodRunStates = this.SubMethodInfos
                                     .Select(mi => new SubMethodRunState()
            {
                SubMethodInfo = mi,
                DataProviders = mi.GetDataProviderList(section, dbProviders)
            })
                                     .ToArray();

            // Now check that each method call info either has at least one clearData provider implementation or can be safely ignored.
            missingDataProvidersExist = subMethodRunStates.Where(mi => mi.SubMethodInfo.FailIfNoDataProvider && mi.DataProviders.FirstOrDefault() == null).FirstOrDefault() != null;

            return(subMethodRunStates);
        }
Ejemplo n.º 6
0
        public static IEnumerable <IDataProvider> GetDataProviderList(DataProvidersConfigurationSection section, DataProvider[] dbProviders, Type interfaceType, SourceUsageOrder localOption)
        {
            switch (localOption)
            {
            case SourceUsageOrder.ExternalOnly:
                return(LoadExternalDataProviders(dbProviders, interfaceType));

            case SourceUsageOrder.LocalOnly:
                return(LoadLocalDataProviders(section, interfaceType));

            case SourceUsageOrder.LocalThenExternal:
                return(LoadLocalDataProviders(section, interfaceType)
                       .Concat(
                           LoadExternalDataProviders(dbProviders, interfaceType)
                           ));

            default:
                return(new IDataProvider[0]);
            }
        }
Ejemplo n.º 7
0
 public abstract IEnumerable <IDataProvider> GetDataProviderList(DataProvidersConfigurationSection section, DataProvider[] dbProviders);
Ejemplo n.º 8
0
 public static IEnumerable <Type> GetAvailableDataProviderTypes(Type interfaceType, bool isExternal)
 {
     return(GetAvailableDataProviderTypes(DataProvidersConfigurationSection.GetCurrent(), interfaceType, isExternal));
 }