引用没有类名的接口名称

时间:2013-10-30 00:09:05

标签: c# interface namespaces

这是probalby非常简单,我只是看了太长时间。在我的项目中,我有一个Contracts.cs,代码如下:

namespace RC.Common.Core.ProcessPlugin
{
    public class Contracts
    {
        public interface IProcessPlugin
        {
            void RunProcess(int jobID);
        }

        public interface IProcessMetaData
        {
            string Process { get; }
        }
    }
}

然后我将PluginProcessFactory.cs作为它的一些代码:

namespace RC.Common.Core.ProcessPlugin
{
    public class PluginProcessFactory
    {
        [ImportMany]
        IEnumerable<Lazy<Contracts.IProcessPlugin, Contracts.IProcessMetaData>> processes;

        // more code
    }
}

如何获取它以便IEnumerable中对接口的引用不包含名称中的类引用?所以它看起来像这样:

        IEnumerable<Lazy<IProcessPlugin, IProcessMetaData>> processes;

1 个答案:

答案 0 :(得分:1)

不要将接口放在类中:

namespace RC.Common.Core.ProcessPlugin
{
    // Place directly in namespace
    // public class Contracts
    // {
        public interface IProcessPlugin
        {
            void RunProcess(int jobID);
        }

        public interface IProcessMetaData
        {
            string Process { get; }
        }
    // }
}
相关问题