Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否可以在不重新编译的情况下向Prism应用程序添加新控件?_C#_Wpf_Prism - Fatal编程技术网

C# 是否可以在不重新编译的情况下向Prism应用程序添加新控件?

C# 是否可以在不重新编译的情况下向Prism应用程序添加新控件?,c#,wpf,prism,C#,Wpf,Prism,我在Prism应用程序中只有一个模块。让此模块具有名称ModuleA,应用程序名称为“CoolAppl”。这个应用程序很酷,并且在生产中运行得很好。一旦有人想在这个应用程序中添加新按钮,例如“Delete Person”,“CoolAppl” 我的问题是,我或其他来自另一个城市的人是否可以添加新按钮“Delete Person”到应用程序“CoolAppl”的模块a,而无需重新编译任何模块,只需添加带有必要按钮的dllDelete Person? 如果可能,请提供我应该挖掘/搜索的方向:) 我正

我在
Prism
应用程序中只有一个模块。让此模块具有名称
ModuleA
,应用程序名称为
“CoolAppl”
。这个应用程序很酷,并且在生产中运行得很好。一旦有人想在这个应用程序中添加新按钮,例如
“Delete Person”
“CoolAppl”

我的问题是,我或其他来自另一个城市的人是否可以添加新按钮
“Delete Person”
到应用程序
“CoolAppl”
模块a
,而无需重新编译任何模块,只需添加带有必要按钮的dll
Delete Person

如果可能,请提供我应该挖掘/搜索的方向:)

我正在使用这样的导航机制

 Uri wholeView = new Uri("ModuleA", UriKind.Relative);                                
 regionManager.RequestNavigate(RegionNames.TheBottomRegion, wholeView);
 var currentView = regionManager.Regions[RegionNames.TheWholeRegion].Views.ElementAt(0);
 regionManager.Regions[RegionNames.TheWholeRegion].Remove(currentView);
用于标识模块的类如下所示:

public class ModuleAModule : ModuleBase, IModule
{
    private readonly IRegionManager _regionManager;
    private readonly IUnityContainer _container;

    public ModuleAModule(IUnityContainer container, IRegionManager regionManager)
        : base(container, regionManager)
    {
        _regionManager = regionManager;
        _container = container;
    }

    protected override void InitializeModule()
    {            
        RegionManager.RegisterViewWithRegion(RegionNames.TheWholeRegion, typeof(LoginControl));
    }

    protected override void RegisterTypes()
    {
        Container.RegisterType<IViewModel, MyViewModel>();
        Container.RegisterTypeForNavigation<MySuperControl>();            
    }
}
公共类模块模块:模块库,IModule
{
私有只读IRegionManager _regionManager;
专用只读IUnityContainer\u容器;
公共模块模块(IUnityContainer容器、IRegionManager区域管理器)
:base(容器、区域管理器)
{
_regionManager=regionManager;
_容器=容器;
}
受保护的重写void InitializeModule()
{            
RegionManager.RegisterViewWithRegion(RegionNames.TheWholeRegion,typeof(LoginControl));
}
受保护的覆盖无效注册表类型()
{
Container.RegisterType();
Container.RegisterTypeForNavigation();
}
}
如果不重新编译意味着“不重新编译所有内容”,那么您可以重新编译ModuleA。如果它的意思是“完全不重新编译”,那么你就不走运了。 如果new按钮不需要位于ModuleA中,则可以创建新的ModuleB,而无需重新编译CoolAppl或ModuleA(但需要编译ModuleB)


您可能已经安装了一个插件系统,从插件加载按钮,然后您可以为新按钮添加另一个插件。

您的问题没有一般性的答案。我们甚至不知道如何实现导航、视图发现等。更具体一点,描述你的应用程序,提供相关代码。@dymanoid我添加了新代码。谢谢你的建议,我是否应该重新编译我的
CoolAppl
,在
bootstrapper
ModuleA
和另一个人新添加的
控件中拥有一个
unityContainer
?我不知道你的意思。unity容器由引导程序创建,对于所有模块也是如此。根据您的模块目录,您必须重新编译应用程序、编辑配置文件或将新模块放在正确的位置(即文件夹)。如果我将新控件(
ModuleByBill
)放在正确的位置,然后就可以在
CoolAppl
中现有的
ModuleA
和新添加的
ModuleByBill
之间进行通信,而无需重新编译
ModuleA
Bootstrapper
?当然,这就是EventAggregator的工作方式-您可以在共享程序集中定义事件(即类),某个模块中的某个方法可以发布事件,另一个模块中的另一个方法可以订阅事件。这些模块不需要相互了解任何信息。当然,如果需要新事件,则需要更新共享程序集或添加新的程序集。然后,如果希望现有模块订阅或发布新事件,则必须更改其代码并重新编译。但只要您对现有事件处理得很好,就不需要更改任何现有模块。如果ModuleA托管了ModuleBy将注册视图的区域,当然,这会起作用。举个例子,我将在上面的答案中编辑一个,但今晚可能不会。。。