有没有办法缓存每个应用程序启动(WPF)的MEF组件图,就像MAF一样,以避免在每次应用程序启动时发现目录并构建组件图.为了加快我的应用程序启动速度.MAF使用AddinsStore存储所有插件,当新插件发现存储重建并再次保存时.使用MEF设计的模块化应用程序可以做到这一点吗?
编辑:
在我的项目架构中我有扩展,模块和托管服务所以我有不同的导出像(IExtension,IModule,IManagedService),我处理所有组件的开始依赖项,我想要的正是ex(扩展目录)包含许多dll并且可能并非所有dll都包含(exports/Imports),因为某些dll只引用了一些Extensions.所以MEF的默认发现行为是在Extension Directory中的所有程序集中搜索exports/Imports,但我想通过查看所有dll并捕获类型及其名称和dll以在其中使用它们来修改此行为下一个启动时间.从catch直接加载组件(Exports),以便MEF知道可用的组件及其位置,而无需加载和搜索dll.它看起来像是一个Exports及其Places和依赖项的字典,可以直接从它的地方(dll)获取实例.
一般来说,我想使用亚马逊的avs sdk为Alexa解析音频文件而不仅仅是麦克风录音.
使用OSX 10.11.6.
首先我Alexa Voice Service Sample App从https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/docs/java-client-sample下载
然后我配置并执行了companionService(nodejs),然后是java客户端,它工作正常..我说麦克风上的东西,Alexa响应.现在我想添加一个加载声音的功能,并从计算机而不仅仅是麦克风播放它.
所以首先我创建了一个向UI添加按钮的功能.所以我编辑了samples/javaclient/src/main/java/com/amazon/alexa/avs/AVSApp.java.我复制了添加"开始侦听"按钮并修改它的功能:
private void addBrowseField() {
final RecordingRMSListener rmsListener = this;
browseButton = new JButton(BROWSE_LABEL);
browseButton.setEnabled(true);
browseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
controller.onUserActivity();
if (browseButton.getText().equals(BROWSE_LABEL)) { // if in idle mode
browseButton.setText(BROWSE_STOP_LABEL);
RequestListener requestListener = new RequestListener() {
@Override
public void onRequestSuccess() {
finishProcessing();
}
@Override
public void onRequestError(Throwable e) {
log.error("An error occured creating speech request", e);
JOptionPane.showMessageDialog(getContentPane(), e.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE); …Run Code Online (Sandbox Code Playgroud) 正在开发 WPF MVVM 项目。
我有一个绑定到模型实体属性的 TextBlock:
<TextBox Text="{Binding MyEntity.Name}"/>
Run Code Online (Sandbox Code Playgroud)
我希望当此 MyEntity.Name 实体更改时更新一个标志。我怎样才能做到这一点 ?
我显然可以设置一个专用的属性名称:
public string Name
{
get
{
return MyEntity.Name;
}
set
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
但我相信你们会提出更优雅的方式。
我做了一些 DataGrid 自定义看起来像一个卡片视图,我知道有一些不同的方法可以做到这一点,但对于其他一些依赖项,我需要一个数据网格,我自定义了如下行样式:
<Style x:Key="CardStyle" TargetType="{x:Type DataGridRow}">
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Margin" Value="2.5" />
<Setter Property="Background" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border x:Name="DGR_Border"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True">
<SelectiveScrollingGrid>
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</SelectiveScrollingGrid.ColumnDefinitions>
<SelectiveScrollingGrid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</SelectiveScrollingGrid.RowDefinitions>
<!-- Replacment of DataGridCellsPresenter -->
<ContentControl
Grid.Column="1"
Content="{Binding}"
ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource AncestorType=DataGrid}}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
</ContentControl>
<DataGridDetailsPresenter Grid.Column="1"
Grid.Row="1"
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type …Run Code Online (Sandbox Code Playgroud) 我创建了一个 Listobj 对象类型的列表。并向对象添加了一组值。
如何以越来越大的方式从 newlist 打印 Listobj 对象。
class Listobj
{
int age;
string name;
public int Age
{
get { return age; }
set { age = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
static List<Listobj> newlist = new List<Listobj>();
static void Main(string[] args)
{
/*newlist.Add(10);
newlist.Add(2);
newlist.Add(6);
newlist.Sort();
newlist.ForEach(Console.WriteLine);
Console.ReadLine();*/
Listobj obj = new Listobj();
int tempage = 23;
string tempname = "deepak";
obj.Age = tempage; …Run Code Online (Sandbox Code Playgroud)