小编Már*_*ton的帖子

如何在运行时删除MEF插件?

我有一个基于MEF的应用程序,可以使用插件进行自定义.这个应用程序有几个导入的部分,我想在用户决定摆脱该插件时在运行时删除其中一些(以便能够删除包含它们的.dll).

CompositionBatch会做我需要的,但它需要ComposablePart实例作为RemovePart()方法的输入参数,我只有实现ISomething接口的普通对象,或者ComposablePartDefinition实例中的实例AggregateCatalog.所以我的问题是:

  • 如何找到表示我想要删除的导入对象的ComposablePart实例?
  • 或者:如何获取属于某个.dll的ComposablePart对象列表?

我会用以下内容:

var parts = Container.Catalog.Parts
           .Where(p => iDontNeed(p))
           .Select(p => howDoIConvertComposablePartDefinition2ComposablePart(p));
var batch = new CompositionBatch();
parts.ToList().ForEach(part => batch.RemovePart(part));
Run Code Online (Sandbox Code Playgroud)

谢谢

.net c# mef

17
推荐指数
1
解决办法
7384
查看次数

使用CentOS UserLand在Raspberry Pi3上运行dotnet核心应用程序

我正在尝试在运行CentOS arm版本(CentOS-Userland-7-armv7hl-Minimal-1708-RaspberryPi3)的Raspberry Pi3 Model B上运行我的AspNetCore 2应用程序.我安装了libunwind和libicu-devel yum install,但是在尝试运行我的应用程序时,我总是收到以下错误:

[root@centos-rpi3 ~]# /opt/dotnet/dotnet my.dll

FailFast: Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.

   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
   at System.Globalization.GlobalizationMode..cctor()
   at System.Globalization.CultureData.CreateCultureWithInvariantData()
   at System.Globalization.CultureData.get_Invariant()
   at System.Globalization.CultureData.GetCultureData(System.String, Boolean)
   at System.Globalization.CultureInfo.InitializeFromName(System.String, Boolean)
   at System.Globalization.CultureInfo.Init()
   at System.Globalization.CultureInfo..cctor()
   at System.Globalization.CultureInfo.get_InvariantCulture()
   at System.StringComparer..cctor()
   at System.AppDomainSetup.SetCompatibilitySwitches(System.Collections.Generic.IEnumerable`1<System.String>)
   at System.AppDomain.PrepareDataForSetup(System.String, System.AppDomainSetup, System.Security.Policy.Evidence, System.Security.Policy.Evidence, IntPtr, System.String, System.String[], System.String[])
Aborted
Run Code Online (Sandbox Code Playgroud)

对于dotnet核心安装,我按照此处描述的指南(任务:在Raspberry Pi上安装.NET Core Runtime): …

centos .net-core raspberry-pi3

7
推荐指数
3
解决办法
3198
查看次数

如何将List <Integer>值绑定到JSF中的selectManyListbox

情况:我有一个JavaServer Faces页面和一个会话范围的托管bean,它有两个ArrayList<Integer>属性:一个用于保存可能值列表,另一个用于保存选定值列表.在JSF页面上有一个<h:selectManyListBox>绑定了这两个属性的组件.

问题:提交表单后,所选的值将转换为字符串(ArrayList类型的属性实际上包含几个字符串!); 但是,当我使用转换器时,我收到如下错误消息:

验证错误:值无效

问题:如何正确地将ArrayList<Integer>属性绑定到<h:selectManyListBox>组件?

谢谢你的帮助.

具体代码

JSF页面:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:body>
        <h:form>
            <h:selectManyListbox value="#{testBean.selection}">
                <f:selectItems value="#{testBean.list}"></f:selectItems>
            </h:selectManyListbox>
            <h:commandButton action="#{testBean.go}" value="go" />
            <ui:repeat value="#{testBean.selection}" var="i">
                #{i}: #{i.getClass()}
            </ui:repeat>
        </h:form>
    </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

托管bean:

import java.io.Serializable;
import java.util.ArrayList;

@javax.faces.bean.ManagedBean
@javax.enterprise.context.SessionScoped
public class TestBean implements Serializable
{
    private ArrayList<Integer> selection;
    private ArrayList<Integer> list;

    public ArrayList<Integer> getList()
    { …
Run Code Online (Sandbox Code Playgroud)

glassfish jsf-2 managed-bean

2
推荐指数
1
解决办法
5473
查看次数

标签 统计

.net ×1

.net-core ×1

c# ×1

centos ×1

glassfish ×1

jsf-2 ×1

managed-bean ×1

mef ×1

raspberry-pi3 ×1