Exemple #1
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]);
        }
 public void Add(TypeElement typeElement)
 {
     BaseAdd(typeElement);
 }
 public int IndexOf(TypeElement typeName)
 {
     return(BaseIndexOf(typeName));
 }