我已經創建瞭如下所示的接口。 DTO對象是一個具有3個參數的複雜值對象。擴展必須在接口中使用的類
public interface IOperation
{
DTO Operate(DTO ArchiveAndPurgeDTO);
}
我需要使這個接口能夠從原始Value對象繼承並且在需要時擴展它的人。
我的假設是,他們可以簡單地繼承DTO對象,添加(例如)另一個屬性,並使用它在相同的類中實現此接口。
當我嘗試使用擴展值對象時,Visual Studio抱怨說我不再提示接口。
我該如何實現這一功能。
在此先感謝您的任何建議和/或建議。
Gineer
編輯: DTO代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Company.ArchiveAndPurge
{
public class DTO
{
public DTO(String FriendlyID)
{
friendlyId = FriendlyID;
}
private String friendlyId = String.Empty;
public String FriendlyId
{
get { return friendlyId; }
set { friendlyId = value; }
}
private String internalId = String.Empty;
public String InternalyId
{
get { return internalId; }
set { internalId = value; }
}
private Boolean archivedSuccessfully = false;
public Boolean ArchivedSuccessfully
{
get { return archivedSuccessfully; }
set { archivedSuccessfully = value; }
}
}
}
擴展DTO:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Company.MSO.ArchiveAndPurge
{
public class DTO: Company.ArchiveAndPurge.DTO
{
private Boolean requiresArchiving = true;
public Boolean RequiresArchiving
{
get { return requiresArchiving; }
set { requiresArchiving = value; }
}
}
}
接口實現,其中VS訴說:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Company.ArchiveAndPurge.Contracts;
using Company.ArchiveAndPurge;
namespace Company.MSO.ArchiveAndPurge
{
public class ResolveFriendlyId: IOperation
{
#region IOperation Members
public DTO Operate(DTO ArchiveAndPurgeDTO)
{
ArchiveAndPurgeDTO.InternalyId = ArchiveAndPurgeDTO.FriendlyId;
return ArchiveAndPurgeDTO;
}
#endregion
}
}
顯示DTO類代碼和代碼在哪裏VS抱怨錯誤 – sll