开发者

How can I delay the need to specify T in my Asp.net user control?

My dilemma:

  • I have a POCO: "ReportSource" that is generic.
  • I have a user control wrapping up some report building logic.
  • My user control defines a ReportSource property but it will ultimately be the job of the page that calls the user control to assign that ReportSource property.

How can I define the property in my user control without specifying a T? Btw, I tried (just for larks) to make the user control generic... That ended badly.

public ReportSource<T> ReportSource {get; set;}

(Note that I've tagged开发者_运维百科 this as C# and VB.net... C# is my norm, but I'm having to deal w/ legacy... An answer in either is appreciated)


Could you move the T specific logic inside a non-generic ReportSource? This "delays" the need to specify T until the caller needs T specifically or until ReportSource needs T. In other words, ReportSource will have generic methods taking T or would otherwise encapsulate or hide T altogether.


If your control doesn't know T, then it can't take advantage of it.

Perhaps you could get around by declaring a non-generic interface for ReportSource<T>, that includes the parts that your control needs to take advantage of ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜