It's just a framework. For more information about activerecord development, see terrylee's castle development article. During the development framework encapsulation, we encountered the problem of ignoring the calling of different business objects for simplified consideration. Therefore, we have added uibase with a generic parameter, however, this makes it much more complicated. I want to hear your opinions!
Using system;
Using system. Collections. Generic;
Using system. text;
Namespace consoleapplication2
{
Database access layer # region database access layer
/** // <Summary>
/// Database layer base class.
/// </Summary>
/// <Typeparam name = "T"> </typeparam>
Abstract class modelbase <t>
{
Public modelbase ()
{
}
Public abstract string current
{
Get;
}
}
/** // <Summary>
/// Database and entity layer.
/// </Summary>
Class model: modelbase <model>
{
Public Model ()
{
}
Public override string current
{
Get {return "model ";}
}
}
# Endregion
Business Layer # Region Business Layer
/** // <Summary>
/// Business layer.
/// </Summary>
/// <Typeparam name = "model"> </typeparam>
Class controller <model> where model: modelbase <model>, new ()
{
Public controller ()
{
}
Model _ model;
Public String getcurrent ()
{
_ Model = new model ();
Return _ model. Current;
}
}
# Endregion
Interface Layer # region Interface Layer
/** // <Summary>
/// Interface layer. You can call different business objects and database objects through generic parameters.
/// </Summary>
/// <Typeparam name = "M"> </typeparam>
/// <Typeparam name = "C"> </typeparam>
Class uibase <m, C> where C: controller <m>, new () where M: modelbase <m>, new ()
{
C _ c = new C ();
Public uibase ()
{
}
Public String getcurrent ()
{
Return _ c. getcurrent ();
}
}
# Endregion
/** // <Summary>
/// Test.
/// </Summary>
Class Program
{
Static void main (string [] ARGs)
{
Uibase <model, controller <model> _ base = new uibase <model, controller <model> ();
Console. writeline (_ base. getcurrent ());
}
}
}