Esempio n. 1
0
        public AppDashPlugin GetPluginInstance(PluginTileComponent pluginTileComponent)
        {
            var tileTypes = pluginTileComponent.GetType().Assembly.GetTypes()
                            .Where(type => typeof(ITile).IsAssignableFrom(type)).ToList();

            if (!tileTypes.Any())
            {
                return(null);
            }

            var pluginType = tileTypes.FirstOrDefault(tileType => tileType.BaseType?.GenericTypeArguments[1] == pluginTileComponent.GetType())
                             ?.BaseType?.GenericTypeArguments.FirstOrDefault();

            if (pluginType == null)
            {
                return(null);
            }

            return(_pluginResolver.GetPluginInstance(pluginType));
        }