<configuration>
<configSections>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
</configSections>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
            <alias alias="IInterface" type="InterfaceNamespace.IInterface, InterfaceLibraryName" />
            <alias alias="Implementation" type="ImpNamespace.Implementation, ImpLibraryName" />
            <container name="default">
                <register type="IInterface" mapTo="Implementation" />  
            </container>
        </unity>
</configuration>假如IInterface对应有两个实现Implementation1和Implementation2时,配置文件该怎么写啊?<register type="IInterface" mapTo="Implementation1" name="imp1"/>  
<register type="IInterface" mapTo="Implementation2" name="imp2"/>  
这样是肯定不对的

解决方案 »

  1.   


    <configuration>
        <configSections>
            <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
        </configSections>
        <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
            <alias alias="IInterface" type="InterfaceNamespace.IInterface, InterfaceLibraryName" />
            <alias alias="Implementation1" type="ImpNamespace.Implementation1, ImpLibraryName" />
            <alias alias="Implementation1" type="ImpNamespace.Implementation2, ImpLibraryName" />
            <container name="default">
                <register type="IInterface" mapTo="Implementation" name="Implementation1" />  
                <register type="IInterface" mapTo="Implementation" name="Implementation2" />
            </container>
        </unity>
    </configuration>
    List<IInterface> interfaces;public Class1(IUnityContainer container)
    {
        interfaces = new List<IInterface>(container.ResolveAll<IInterface>());          
    }刚问完就找到答案了。郁闷,我的50分啊!
      

  2.   

    再问个问题:Prism里不是提供了DelegateCommand<T>了吗?为什么我找不到它。
    该引用的DLL应该都引用了呀。难道它不是在某个DLL里吗?Microsoft.Practices.Composite;
    Microsoft.Practices.Composite.Presentation;
    Microsoft.Practices.Composite.UnityExtensions;
    Microsoft.Practices.ServiceLocation;
    Microsoft.Practices.Unity;
    Microsoft.Practices.Unity.Configuration;
      

  3.   

    TMD, 我怎么老是折腾半天,刚发完贴就自己找到答案呢!NND!faint!using Microsoft.Practices.Composite.Presentation.Commands;