接口实现问题

时间:2011-10-14 09:39:15

标签: asp.net c#-4.0 interface

我有这样的基础界面

public interface IHRMISBaseConnector
    {
         IHRMISEmployeeConnector EmployeeConnector { get  ; set; }  
    }

我还有一个这样的界面

public  interface IHRMISEmployeeConnector
    {
        String Add(EmployeeDetails e);
        Boolean Update(EmployeeDetails e);
        Boolean Delete(int id);
    }

我希望在此类DDWEDocumentOperations中实现IHRMISBaseConnector

我该如何实施?如果有人知道,请告诉我

2 个答案:

答案 0 :(得分:0)

以下是一个例子:

    public class DDWEDocumentOperations : IHRMISBaseConnector
    {
        private IHRMISEmployeeConnector _employeeConnector;

        public IHRMISEmployeeConnector EmployeeConnector
        {
            get { return _employeeConnector; }
            set { _employeeConnector = value; }
        }
    }

答案 1 :(得分:0)

这样的事可以帮到你:

class FakeImplementationOfEmployeeConnector : IHRMISEmployeeConnector
{
    public string Add(EmployeeDetails e)
    {
        //...
    }

    public bool Update(EmployeeDetails e)
    {
        //...
    }

    public bool Delete(int id)
    {
        //...
    }
}

class DDWEDocumentOperations : IHRMISBaseConnector
{
    IHRMISEmployeeConnector employeeConnector = new FakeImplementationOfEmployeeConnector();

    public IHRMISEmployeeConnector EmployeeConnector
    {
        get
        {
            return employeeConnector;
        }
        set
        {
            employeeConnector = value;
        }
    }
}