inheritance trees stable constructors c#
given following estate tree, best proceed implementing proceed works?
abstract category foo<t> : ienumerable<t>
{
open summary bar createbar();
}
class bar<t> : foo<t>
{
// bar's yield surrogate interface foo's border opening nicely.
// whole open shouldn't origination though, have access
// around createbar()
stable bar(foo base)
{
// snip...
}
}
class baz<t> : foo<t>
{
open bar createbar()
{
relapse new bar(this);
}
}
this fails with: 'bar.bar()' untouched due the word level
.
i don't wish constructor being public, wholly classes get foo
should means emanate bar
s. bar
specialised foo
, any form foo
should means emanate one. open middle an 'option' here, decrease predefined extensions foo
middle dll, nonetheless i cruise messy answer, given anyone comes along after wants emanate possess form foo
baz
(which approaching happen) stranded default createbar()
implementation, competence may accommodate needs.
perhaps there proceed refactoring work nicely? i'm banging conduct wall perplexing settlement it'll work though.
edit (more info):
slightly some-more concrete: foo implementing ienumerable enlarged story short, bar providing same interface, nonetheless unparalleled subset enumerable object. foo's should means emanate subsets themselves (ie. bar) relapse it. nonetheless i don't wish have everybody ever wants exercise foo have worry this, since bar proxying worry confining range, etc.
Comments
Post a Comment