根据要求导出属性...?
Derive properties as per the requirement...?
所以,我有 3 个 fields/properties。比如说,它们是 paramA、paramB、paramC。我有三个 classes 作为 Class A,Class B,Class C。
要求是使用:
• paramA, paramB in Class A
• paramA, paramC in Class B
• paramB, paramC in Class D
有没有办法在一个共同的地方声明所有这 3 个属性,并根据要求在 A、B、C classes 中派生....?
更新
请查找要求的更多详细信息:
真正的要求是:
数据库中有一个 table ‘Que Table’ 具有以下字段
• bool IsQb
• bool IsOverride
• string Identifier
• string userlogin
• FolderName
以下模型 classes 正在使用“Que Table”中的 create/update/delete 数据。
• CreateQue class
• UpdateQue class
• DeleteQue class
CreateQue class 只需要 properties:IsQb、IsOverride、UserLogin、FolderName
UpdateQue class 只需要属性:IsQb、IsOverride、Identifier、UserLogin、FolderName
而 DeleteQue class 只需要:标识符 属性。
模型 class 的代码是:
public class CreateQue
{
public bool IsQb { get; set; }
public bool IsOverride { get; set; }
public string userlogin { get; set; }
public string FolderName { get; set; }
}
public class UpdateQue
{
public bool IsQb { get; set; }
public bool IsOverride { get; set; }
public string Identifier { get; set; }
public string userlogin { get; set; }
public string FolderName { get; set; }
}
public class DeleteQue
{
public string userlogin { get; set; }
public string Identifier { get; set; }
}
那么,是否有任何 pattern/architecture 可以在一个地方声明所有这些属性并根据这些模型 classes 中的要求派生......?
提前致谢
由于我们看不到您的要求,因此有点不清楚您需要做什么。您可以使用接口:
public interface IHasPropertyA
{
string PropertyA { get; set; }
}
public interface IHasPropertyB
{
string PropertyB { get; set; }
}
public class ClassA : IHasPropertyA, IHasPropertyB
{
public string PropertyA { get; set; }
public string PropertyB { get; set; }
}
所以,我有 3 个 fields/properties。比如说,它们是 paramA、paramB、paramC。我有三个 classes 作为 Class A,Class B,Class C。
要求是使用:
• paramA, paramB in Class A
• paramA, paramC in Class B
• paramB, paramC in Class D
有没有办法在一个共同的地方声明所有这 3 个属性,并根据要求在 A、B、C classes 中派生....?
更新
请查找要求的更多详细信息:
真正的要求是:
数据库中有一个 table ‘Que Table’ 具有以下字段
• bool IsQb
• bool IsOverride
• string Identifier
• string userlogin
• FolderName
以下模型 classes 正在使用“Que Table”中的 create/update/delete 数据。
• CreateQue class
• UpdateQue class
• DeleteQue class
CreateQue class 只需要 properties:IsQb、IsOverride、UserLogin、FolderName
UpdateQue class 只需要属性:IsQb、IsOverride、Identifier、UserLogin、FolderName
而 DeleteQue class 只需要:标识符 属性。
模型 class 的代码是:
public class CreateQue
{
public bool IsQb { get; set; }
public bool IsOverride { get; set; }
public string userlogin { get; set; }
public string FolderName { get; set; }
}
public class UpdateQue
{
public bool IsQb { get; set; }
public bool IsOverride { get; set; }
public string Identifier { get; set; }
public string userlogin { get; set; }
public string FolderName { get; set; }
}
public class DeleteQue
{
public string userlogin { get; set; }
public string Identifier { get; set; }
}
那么,是否有任何 pattern/architecture 可以在一个地方声明所有这些属性并根据这些模型 classes 中的要求派生......?
提前致谢
由于我们看不到您的要求,因此有点不清楚您需要做什么。您可以使用接口:
public interface IHasPropertyA
{
string PropertyA { get; set; }
}
public interface IHasPropertyB
{
string PropertyB { get; set; }
}
public class ClassA : IHasPropertyA, IHasPropertyB
{
public string PropertyA { get; set; }
public string PropertyB { get; set; }
}