Created
September 23, 2010 11:08
-
-
Save cz75hiro/593478 to your computer and use it in GitHub Desktop.
Genericの間違えた使い方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IData //データインターフェース | |
{ | |
} | |
public abstract class SchemaBase//DBスキーマ抽象クラス | |
{ | |
public SchemaBase() { } | |
} | |
public abstract class DAOBase<TSchema, TData>//DAOパターン抽象クラス | |
where TSchema : SchemaBase | |
where TData : IData | |
{ | |
public DAOBase() { } | |
} | |
public abstract class ControlerBase//データコントローラー抽象クラス | |
{ | |
public void Create<TDao, TSchema, TData>() | |
where TDao : DAOBase<TSchema, TData> | |
where TSchema : SchemaBase | |
where TData : IData | |
{ | |
//各パタメータクラスのインスタンス生成 | |
} | |
} | |
class ControlerA : ControlerBase | |
{ | |
} | |
class ControlerB : ControlerBase | |
{ | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var a = new ControlerA(); | |
var b = new ControlerB(); | |
var list = new List<ControlerBase>(); | |
list.Add(a); | |
list.Add(b); | |
a.Create<daoA, schemaA, dataA>(); //foreachできない・・・ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment