Exemplo n.º 1
0
        // Private Methods
        private ISearchProvider GetProvider(string entityTypeName)
        {
            var entityType   = CoreExtensions.GetEntityType(entityTypeName);
            var types        = entityType.GetInterfaces();
            var providerType = (
                // Get the non-inherited provider types first...
                types
                .Except(entityType.BaseType.GetInterfaces())
                .FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ISearchable <>))
                ??
                // If there are no non-inherited provider types, get the inherited ones...
                types.FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ISearchable <>))
                ).GetGenericArguments()[0];

            return((ISearchProvider)Activator.CreateInstance(providerType));
        }