我有四个课程:
Author.cs
类,即
public class Author : Interfaces.INode
{
public int _aID { get; set; }
public string _aName { get; set; }
public List<CoAuthor> _aCoAuthors { get; set; }
public List<Venue> _aVenue { get; set; }
public List<Paper> _aPapers { get; set; }
public string _aArea { get; set; }
}
CoAuthor.cs
类,即
public class CoAuthor : Interfaces.INode
{
public int _coaID { get; set; }
public string _coaName { get; set; }
public List<Paper> _coaPapers { get; set; }
public string _coaArea { get; set; }
}
Venue.cs
类,即
public class Venue : Interfaces.INode
{
public int _vID { get; set; }
public string _vName { get; set; }
public List<Paper> _vPapers { get; set; }
public string _vArea { get; set; }
}
Paper.cs
类,即
public class Paper : Interfaces.INode
{
public int _pID { get; set; }
public Author _pAuthor { get; set; }
public List<CoAuthor> _pCoAuthors { get; set; }
public Venue _pVenue { get; set; }
public int _pYear { get; set; }
public string _pRField { get; set; }
}
所有这些类都实现了interface
,即Interfaces.INode
,其定义为:
public interface INode
{
List<INode> _TargetObject { get; }
List<INode> _AttributeObject { get; }
}
现在Author.cs
类的类型为_TargetObject
,即在INode
中定义,所有其他3个类的类型为_AttributeObject
,即在INode
中定义。
如何将这些类与相应的INode
成员关联起来,目前还不清楚哪些是_TargetObject
和_AttributeObject
?
答案 0 :(得分:0)
正如评论中所解释的,我建议你定义更好的对象和小费。在此实现中,您可以更好地控制Target的类型和属性
public interface INode
{
List<INode> _TargetObject { get; }
List<IAttribute> _AttributeObject { get; }
}
public interface IAttribute : INode
{
}
public class Author : Interfaces.INode
{
private List<INode> _targetList ;
private List<IAttribute> _attributeObject ;
public Author()
{
_targetList = new List<INode>();
}
//implementazion of _TargetObject INode method
public List<INode> _TargetObject
{
get
{
return _targetList;
}
}
//implementazion of _AttributeObject INode method
public List<IAttribute> _AttributeObject
{
get
{
return _attributeObject ;
}
}
}
public class CoAuthor : Interfaces.IAttribute
{... your class implementation ...}
public class Venue : Interfaces.IAttribute
{... your class implementation ...}
public class Paper : Interfaces.IAttribute
{... your class implementation ...}