c# - Interdependent Generic Classes? -


An example below this post is how a solution might seem, though clearly the example is invalid because it is in BaseNode and Without giving type while doing basic inheritance to BaseEdge

I am trying to create an intangible graph class, where both the node class and the square of the side should also be intact. Essential methods must be implemented from the base classes by adding methods and properties of individual implementation of each class.

I have an existing solution that uses base types only for everything, although I quickly found myself in a mess casting.

Only the graph class should be exposed publicly, although others may be, so the solutions containing the nodes and the incremental classes inside the graph class are acceptable.

Can it be structured in any way that all such assets are of the right kind, which are expensive in the system without any reason? It is more important that the implementing classes do not have to be put everywhere, but in this case performance is definitely a matter of concern (this is really), so I have not completely left completely avoiding it.

  abstract class Graph & lt; TNode, TEgege & gt; Where TNode: BaseNode & lt; TEgege & gt; Where tease: bassadegge & lt; TNode & gt; {Tnode root; & Lt; TNode & gt; Nodes; & Lt; TEdge & gt; Edges; Public abstract float process (); } Abstract class basseed & lt; TEgege & gt; // Here is the problem where the Tage: BaseAge {list & lt; TEgege & gt; Inputs; Public listing & lt; TEgege & gt; Input {receive return returns; }} Public abstract float process (); } Abstract square basses & lt; TNode & gt; // Here is the problem where TNode: BaseNode {to TNode; TNode to; {To get public TNode {Back; }} Public from TNode {get {return from; }} Public abstract float process (); }  

@Marsalen wanted to see my current implementation, so here it is. This is the only thing without genetics.

  Abstract class graph {BaseNode root; & Lt; BaseNode & gt; Nodes; & Lt; BaseEdge & gt; Edges; Public abstract float process (); } Abstract class bynod {list & lt; Base Easy & gt; Inputs; Public List & amp; Bidgeage & gt; Input {receive return returns; }} Public abstract float process (); } Abstraction from class bassage {from; To Besodod; Public BaseNode {return to {return}; }} Received from public BaseNode {return; }} Public abstract float process (); }  

While the node's implementation may look like this:

  class implemented node: besnode {public override float process (foreach (execution) .inputs) {// some}} public bool getImplementationSpecificInfo () {return true; }}  

If you type BaseEdge and BaseNode So you can do something like the example below.

I have the interface INode and IEdge just because whatever works with it, it is called Bizid and BaseNode

TNode, TEgege & gt; Where TNode: BaseNode & lt; TEgege & gt; Where tease: bassadegge & lt; TNode & gt; {Receive the public TNode Route; Set; } Public listing & lt; TNode & gt; Nodes {receive; Set; } Public listing & lt; TEgege & gt; Edges {receive; Set; }} Public Essentials Bypass & lt; TEgege & gt; : Indode Where Tage: IGG {List & lt; TEgege & gt; Inputs; Public listing & lt; TEgege & gt; Input {receive return returns; }} Public abstract float process (); } Public abstract class basses & lt; TNode & gt; : IEdge where TNode: from INode {to TNode; TNode to; {To get public TNode {Back; }} Public from TNode {get {return from; }} Public abstract float process (); } Public class concrete node: Besnode & lt; Concrete Edge & gt; {Public Override Float Processing () {Return 0; }} Public Class Concrete Edge: Base Edge & lt; ConcreteTods & gt; {Public Override Float Processing () {Return 0; }} Public Sector Concrete Graph: Stories & lt; Concretetod, concrete edge & gt; {}


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -