top.First().Value() を「Node」に「キャスト」するのではなく、(NodeBase とは対照的に) 自動的にこれを想定する必要があるので、クラスの拡張属性が表示されます。ノードで定義しますか?
つまり、次のように言う方法があります。
top.Nodes.First().Value.Path;
今行かなければならないのとは対照的に:
((Node)top.Nodes.First().Value).Path)
ありがとう
[TestMethod()]
public void CreateNoteTest()
{
var top = new Topology();
Node node = top.CreateNode("a");
node.Path = "testpath";
Assert.AreEqual("testpath", ((Node)top.Nodes.First().Value).Path); // *** HERE ***
}
class Topology : TopologyBase<string, Node, Relationship>
{
}
class Node : NodeBase<string>
{
public string Path { get; set; }
}
public class NodeBase<T>
{
public T Key { get; set; }
public NodeBase()
{
}
public NodeBase(T key)
{
Key = key;
}
}
public class TopologyBase<TKey, TNode, TRelationship>
where TNode : NodeBase<TKey>, new()
where TRelationship : RelationshipBase<TKey>, new()
{
// Properties
public Dictionary<TKey, NodeBase<TKey>> Nodes { get; private set; }
public List<RelationshipBase<TKey>> Relationships { get; private set; }
}