private static IObservable <(Type targetIntefaceType, Type extenderInterface)> AddExtenders(ModelInterfaceExtenders extenders)
        {
            var modelExtenders   = ModelExtenders().SubscribeReplay();
            var mappedContainers = TypeMappingService.Connect()
                                   .SelectMany(unit => modelExtenders
                                               .Select(_ => _.MapToModel()).Switch()
                                               .ModelInterfaces()
                                               .Where(type => typeof(IModelNode).IsAssignableFrom(type)))
                                   .SelectMany(type => type.ModelMapperContainerTypes())
                                   .Distinct().Replay().RefCount();

            return(modelExtenders
                   .SelectMany(_ => mappedContainers.FirstAsync(type => type.Attribute <ModelMapLinkAttribute>().LinkedTypeName == _.TypeToMap.AssemblyQualifiedName).SelectMany(_.CollectExtenders))
                   .Do(_ => extenders.Add(_.targetInterfaceType, _.extenderInterface)));
        }
        public static void Extend(this ApplicationModulesManager modulesManager, IModelMapperConfiguration configuration)
        {
            if (modulesManager.Modules.FindModule <ModelMapperModule>() == null)
            {
                throw new NotSupportedException($"{typeof(ModelMapperModule)} is not registered");
            }
            TypeMappingService.Connect().Wait();
            var installed = ModelMapperConfigurations.FirstOrDefault(_ => _.TypeToMap == configuration.TypeToMap);

            if (installed != null)
            {
                installed.TargetInterfaceTypes.AddRange(configuration.TargetInterfaceTypes);
            }
            else
            {
                ModelMapperConfigurations.Add(configuration);
            }
        }