Last change
on this file since 9311 was
9305,
checked in by fschoepp, 12 years ago
|
#1888:
- Added an Update / GetExperiment... methods to the controller for updating and querying experiments.
- The AlgorithmConverter class now properly converts from/to JSON format.
- Integrated backbone js as MVC provider for JavaScript + jquery.
- Added experiment.model.js + experiment.view.js + experiment.controller.js containing the MVC impl. for the Experiment pages.
- Added new methods to the ExperimentController usable by the backbone js model implementation.
- Added the experiment dialog from HL 3.3.7 (variate experiment parameters). It's capable of variating the algorithm parameters.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[9227] | 1 | // http://blog.duc.as/2011/06/07/making-mvc-3-a-little-more-dynamic/
|
---|
| 2 |
|
---|
| 3 | using System;
|
---|
| 4 | using System.Collections.Generic;
|
---|
| 5 | using System.Linq;
|
---|
| 6 | using System.Web;
|
---|
| 7 | using System.Web.Mvc;
|
---|
| 8 | using System.IO;
|
---|
| 9 | using System.Web.Helpers;
|
---|
| 10 | using HeuristicLab.Services.Optimization.ControllerService.Model;
|
---|
| 11 | using HeuristicLab.Services.Optimization.ControllerService.Parsers;
|
---|
| 12 |
|
---|
| 13 | namespace Mvc3TestApplication.Binders
|
---|
| 14 | {
|
---|
| 15 | public class ExperimentJsonAttribute : CustomModelBinderAttribute {
|
---|
| 16 | public override IModelBinder GetBinder() {
|
---|
| 17 | return new ExperimentJsonBinder();
|
---|
| 18 | }
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | public class ExperimentJsonBinder : IModelBinder {
|
---|
| 22 | public ExperimentJsonBinder() {
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public object BindModel(ControllerContext controllerCtx, ModelBindingContext bindingCtx) {
|
---|
| 26 | var contentType = controllerCtx.HttpContext.Request.ContentType;
|
---|
| 27 | if (!contentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
|
---|
| 28 | return null;
|
---|
| 29 |
|
---|
| 30 | string body;
|
---|
| 31 | using (var stream = controllerCtx.HttpContext.Request.InputStream) {
|
---|
| 32 | stream.Seek(0, System.IO.SeekOrigin.Begin);
|
---|
| 33 | using (var reader = new StreamReader(stream))
|
---|
| 34 | body = reader.ReadToEnd();
|
---|
| 35 | }
|
---|
| 36 | if (string.IsNullOrEmpty(body)) return null;
|
---|
[9305] | 37 | return AlgorithmConverter.ConvertJsonToExperiment(body);
|
---|
[9227] | 38 | }
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | }
|
---|
| 42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.