- Timestamp:
- 03/11/13 14:40:04 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Web/Binders/AlgorithmJsonAttribute.cs
r9227 r9305 13 13 namespace Mvc3TestApplication.Binders 14 14 { 15 public class AlgorithmJsonAttribute : CustomModelBinderAttribute16 {17 public override IModelBinder GetBinder()18 {19 return new AlgorithmJsonBinder();20 }21 }22 23 public class AlgorithmJsonBinder : IModelBinder24 {25 public AlgorithmJsonBinder()26 {27 }28 29 public object BindModel(ControllerContext controllerCtx, ModelBindingContext bindingCtx)30 {31 var contentType = controllerCtx.HttpContext.Request.ContentType;32 if (!contentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))33 return null;34 35 string body;36 using (var stream = controllerCtx.HttpContext.Request.InputStream)37 {38 stream.Seek(0, System.IO.SeekOrigin.Begin);39 using (var reader = new StreamReader(stream))40 body = reader.ReadToEnd();41 }42 if (string.IsNullOrEmpty(body)) return null;43 return AlgorithmConverter.Convert(body);44 }45 46 47 }48 49 15 public class ExperimentJsonAttribute : CustomModelBinderAttribute { 50 16 public override IModelBinder GetBinder() { … … 69 35 } 70 36 if (string.IsNullOrEmpty(body)) return null; 71 return AlgorithmConverter.Convert Experiment(body);37 return AlgorithmConverter.ConvertJsonToExperiment(body); 72 38 } 73 39
Note: See TracChangeset
for help on using the changeset viewer.