рджрд┐рди рдХреЗ рд╕рднреА рд╕рдордп рдХреА рддрд░рд╣, рдЗрд╕ рд▓реЗрдЦ рдореЗрдВ рдореИрдВ рдЗрдирдХреЛрдбрд┐рдВрдЧ рдлреНрд░реЗрдорд╡рд░реНрдХ рд▓рд╛рдЗрдмреНрд░реЗрд░реА рд╕реЗ рдПрдХ рдФрд░ рдШрдЯрдХ рдХреЛ рдЙрдЬрд╛рдЧрд░ рдХрд░рдирд╛ рдЪрд╛рд╣рддрд╛ рд╣реВрдВред
рдореЙрдбрд▓ рд╡реНрдпреВ рдбрд┐рд╕реНрдкреИрдЪрд░ (рдПрдорд╡реАрдбреА) - рдЖрдкрдХреЛ рдХреНрд▓рд╛рдЗрдВрдЯ рдФрд░ рд╕рд░реНрд╡рд░ рдХреЛрдб рдХреЗ рдмреАрдЪ рд╕рд╛рд░ рдХреА рд╕рдВрдЦреНрдпрд╛ рдХреЛ рдХрдо рдХрд░рдХреЗ рдЕрдирд╛рд╡рд╢реНрдпрдХ рдХреЛрдб (рдЕрд░реНрдерд╛рддреН, asp.net mvc рдирд┐рдпрдВрддреНрд░рдХ) рд╕реЗ рдЫреБрдЯрдХрд╛рд░рд╛ рдкрд╛рдиреЗ рдФрд░ рдкреНрд░реЛрдЬреЗрдХреНрдЯ рдиреЗрд╡рд┐рдЧреЗрд╢рди рдХреЛ рд╕рд░рд▓ рдмрдирд╛рдиреЗ рдХреА рдЕрдиреБрдорддрд┐ рджреЗрддрд╛ рд╣реИред
Habr├й рдкрд░ IML рдФрд░ CQRS рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рдХреБрдЫ рд▓реЗрдЦ рд╣реИрдВ рдЬреЛ рдлреНрд░реЗрдорд╡рд░реНрдХ рдХрд╛ рдПрдХ рд╣рд┐рд╕реНрд╕рд╛ рд╣реИрдВ
- рдкреЗрд╢ рд╣реИ рдЖрдИ.рдПрдо.рдПрд▓.
- рдЗрдирдХрдорд┐рдВрдЧ CQRS
рдиреЛрдЯ: рд▓реЗрдЦ рдкреНрд░рдХрд╛рд╢рд┐рдд рдХрд┐рдпрд╛ рдЧрдпрд╛ рдерд╛, рд▓реЗрдХрд┐рди рдЙрд╕ рд╕рдордп Habr├й рдкрд░ рдЦрд╛рддреЗ рдХреЗ рд╕рд╛рде рд╕рдорд╕реНрдпрд╛рдПрдВ рдереАрдВ рдФрд░ рдпрд╣ рдХрд┐рд╕реА рдХрд╛ рдзреНрдпрд╛рди рдирд╣реАрдВ рдЧрдпрд╛
- рдЖрдИрдПрдордПрд▓ рдмрдирд╛рдо рдПрдВрдЧреБрд▓рд░рдЬ
рдиреЛрдЯ: рд▓реЗрдЦ рдХреА рдЖрд▓реЛрдЪрдирд╛ рдХреА рдЧрдИ (рдЙрджреНрджреЗрд╢реНрдп рдФрд░ рд╡реНрдпрдХреНрддрд┐рдкрд░рдХ)
- IMl рдмрдирд╛рдо AngularJs рдХрд╛ рдЙрддреНрддрд░ рджреЗрдВ
рдиреЛрдЯ: рд╕рдлрд▓рддрд╛ рдирд╣реАрдВ рдХрд╣рд╛ рдЬрд╛ рд╕рдХрддрд╛ рд╣реИ, рд▓реЗрдХрд┐рди рдереЛрдбрд╝рд╛ рдмреЗрд╣рддрд░ рд╣реИ
MVD рдХреБрдЫ рд▓реЗрдЦреЛрдВ рдореЗрдВ рджрд┐рдЦрд╛рдИ рджрд┐рдпрд╛, рд▓реЗрдХрд┐рди IML рдХреА рдХреНрд╖рдорддрд╛рдУрдВ рдХрд╛ рдкреНрд░рджрд░реНрд╢рди рдХрд░рдиреЗ рд╡рд╛рд▓реЗ рдЙрджрд╛рд╣рд░рдг рдХреЗ рд░реВрдк рдореЗрдВ, рдЗрд╕рд▓рд┐рдП рдореИрдВрдиреЗ рдЗрд╕рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рдЕрд▓рдЧ рд╕реЗ рдмрд╛рдд рдХрд░рдиреЗ рдХрд╛ рдлреИрд╕рд▓рд╛ рдХрд┐рдпрд╛, рд▓реЗрдХрд┐рди рдХреНрд░рдо рдореЗрдВ рд╕рдм рдХреБрдЫ рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ ...
рдХреНрдпреЛрдВ?
рдПрдХ asp.net mvc + cqrs рдПрдкреНрд▓рд┐рдХреЗрд╢рди рдкрд░рд┐рджреГрд╢реНрдп рдкрд░ рд╡рд┐рдЪрд╛рд░ рдХрд░реЗрдВ
- рдирд┐рдпрдВрддреНрд░рдХ
public ActionResult Details(GetUserDetailsQuery query) { var model = dispatcher.Query(query); return Json(model); }
: action binding query Dispatcher Json
- View
$.get('@Url.Action("Details","Controller")',callback)
: Query , Action
controller ┬л┬╗ Mediator ( ), Interface Generic, , , Controller/Action.
Model View Dispatcher (MVD) тАФ Command/Query ┬л┬╗ asp.net mvc. , MVD
$.get('@Url.Dispatcher().Query(new GetUserDetailsQuery()).AsJson()',callback)
- Action
- , (go to delcaration )
- URL (visual studio intelisence, refactor utilities)
MVC ???
, MVD :
DispatcherController ( 1.1 nuget), DispatcherControllerBase
public class DispatcherController : DispatcherControllerBase { public DispatcherController() : base(typeof(T).Assembly) { } }
: Assembly Command/Query
DispatcherControllerBase (Actions):
Query(string incType, string incGeneric, bool? incValidate) Render(string incView, string incType, string incGeneric) Push(string incType, string incGeneric) Composite(string incTypes) QueryToFile(string incType, string incGeneric, string incContentType, string incFileDownloadName)
url, Push command
Url.Action("Push", "Dispatcher", new { incType = typeof(Command).Name } )
DSL (domain specific language)
Url.Dispatcher().Push(new Command())
: ( ), ( ..)
- MVD IDispatcher, IoCFactory ( StructureMap )
- ActionResult IncodingResult, JSON
{ success: true/false , data:something/null , redirectTo:url/null }
: MVD asp.net mvc, ( generic) Controller, httphandler http .
?
MVD , - asp.net mvc:
: GitHub
- Push
Url.Dispatcher().Push(new AddUserCommand { Id = "59140B31-8BB2-49BA-AE52-368680D5418A", Name = "Vlad" })
:
- Push generic
Url.Dispatcher().Push(new AddEntityCommand<T>())
- omposite
Url.Dispatcher() .Push(new AddUserCommand { Id = "1", Name = "Name" }) .Push(new ApproveUserCommand { UserId = "2" })
- Query as json
Url.Dispatcher() .Query(new GetCurrentDtQuery()) .AsJson()
- Query generic
Url.Dispatcher() .Query(new GetTypeNameQuery<T>()) .AsJson()
- Query as view
Url.Dispatcher() .Query(new GetUserQuery()) .AsView("~/Views/Home/User.cshtml")
: View ( asp.net mvc Controller) , .
- Query as file
<a href="@Url.Dispatcher().Query(new GetFileQuery()).AsFile(incFileDownloadName: "framework")">Download</a>
: QueryBase<byte[]> Query
- Model as view
Url.Dispatcher() .Model(new GetUserQuery.Response { Id = "2", Name = "Incoding Framework" }) .AsView("~/Views/Home/User.cshtml")
- View
Url.Dispatcher().AsView("~/Views/Home/Template.cshtml")
MVD DispatcherController ( ), CQRS Command/Query Url.Dispatcher ( , ) url, , IML.
- Post
@(Html.When(JqueryBind.Change) .AjaxPost(Url.Dispatcher().Push<AddAcoGroupCommand>(new {Value = Selector.Jquery.Self() } )) .OnSuccess(dsl => dsl.Utilities.Window.Alert("Success")) .AsHtmlAttributes() .ToCheckBox(true))
: , ( Value AddAcoGroupCommand exception) .
- Post form
@model AddAcoGroupCommand <form action="@Url.Dispatcher().Push(new AddAcoGroupCommand())"> @Html.HiddenFor(r=>r.Id) <input type="submit"/> </form>
- Render View
@(Html.When(JqueryBind.InitIncoding) .AjaxGet(Url.Dispatcher().AsView("~/Views/Patient/BenefitListControl.cshtml")) .OnSuccess(dsl => dsl.Self().Core().Insert.Html()) .AsHtmlAttributes() .ToDiv())
: template
var urlTmpl = Url.Dispatcher().AsView("~/Views/Medication/MedicationTmpl.cshtml"); dsl.Self().Core().Insert.WithTemplateByUrl(urlTemplate).Append();
- Render model
@(Html.When(JqueryBind.InitIncoding) .AjaxGet(Url.Dispatcher() .Model( new BenefitModel() { GroupName = Selector.Incoding.QueryString<BenefitModel>(r=>r.GroupName), IsPrimary = true }) .AsView("~/Views/Patient/BenefitListControl.cshtml")) .OnSuccess(dsl => dsl.Self().Core().Insert.Html()) .AsHtmlAttributes() .ToDiv())
: Selector ( ) url routes .
: Inc-todo
Action Attributes
(-╠Б тАО), , , :
- DispatcherController
: , CRM
- Dispatcher event тАФ Command/Query , Action attributes.
: Action Command/Query
Incoding Framework ( js framework Server/Client ) MVD .
@(using(Html.When(JqueryBind.InitIncoding) .Direct() .OnSuccess(dsl => dsl.Self().Core().Form.Validation.Parse()) .When(JqueryBind.Submit) .PreventDefault() .Submit() .OnError(dsl => dsl.Self().Core().Form.Validation.Refresh()) .AsHtmlAttributes() .ToBeginForm(Url.Dispatcher().Push(new AddUserCommand())))) { @Html.TextBoxFor(r=>r.Name) @Html.ValidationMessageFor(r=>r.Name) }
: , html helper
asp.net mvc Html.BeginForm ( iml html attributes), :
- Submit ( ) ajax post (Url.Dispatcher().Push(new AddUserCommand())
- (, ) Model State ( )
, Validation.Refresh Push dispatcher contoller
if (!ModelState.IsValid) return IncodingResult.Error(ModelState) try { dispatcher.Push(composite); return IncodingResult.Success(); } catch (IncWebException exception) { foreach (var pairError in exception.Errors) { foreach (var errorMessage in pairError.Value) ModelState.AddModelError(pairError.Key, errorMessage); } return IncodingResult.Error(ModelState) }
: - , Incoding Framework TryPush MVD push
catch IncWebException ( ModelState), exception global.asax.
?
, Incoding Framework , asp.net mvc
public ActionResult Add(AddUserCommand command) { if (ModelState.IsValid) return View(command); return Execute(command); }
ModelState , View, command (, Container , ), . :
- ,
- html ( json), action, API ()
MVD Action, ┬л┬╗ , . MVD IML, Selector routes, , - , ┬л┬╗ (pure js) .
, MVD ( ) , Controller Action ( 5% тАФ 10%) .
, ?
MVD 10-15% , , end point ( wcf endpoint)тАж
, ?
api :
- Api тАФ , /GetUsers?Active=true
- Api тАФ user ( Comment, City, State )
- Api тАФ , City /GetCities
- Api тАФ , , State ,
- тАФ , %sitename%-api-%current-version%
: %current-version%, ,
, mvd end-points
- Api тАФ
- тАФ appDomain/Dispatcher/Endpoints?
- Api тАФ , command/query
: , API, UI (user interface) (unit test , ) -
: , , , , .
: , API . , , , , - , .
P.S. ( beta) Incoding Framework nuget, . , ( bugtracker)
-
Break.If(r=>r.Is(()=>Selector.Jquery.Self()).And.Is(()=>"id".ToId()== 12)) // Old Break.If(()=>Selector.Jquery.Self() && id.ToId() == 12) // New
- EF, RavenDB, MongoDb ( command ORM github inc-todo-ravendb)
-
inDsl.Core().JQuery.Attributes.SetAttr(HtmlAttribute.Checked) // Now inDsl.Attr.Set(HtmlAttr.Checked) // Future
: beta ( ) , ,