Exemple #1
0
        protected override void Initialize(HttpControllerContext controllerContext)
        {
            // ensure that the service is valid and all custom metadata providers
            // have been registered (don't worry about performance here, there's a coalesce with a static var underneath)
            Description = DataControllerDescription.GetDescription(controllerContext.ControllerDescriptor);

            base.Initialize(controllerContext);
        }
        protected override void Initialize(HttpControllerContext controllerContext)
        {
            // ensure that the service is valid and all custom metadata providers
            // have been registered (don't worry about performance here, there's a coalesce with a static var underneath)
            Description = DataControllerDescription.GetDescription(controllerContext.ControllerDescriptor);

            base.Initialize(controllerContext);
        }
Exemple #3
0
        private static IEnumerable <MediaTypeFormatter> GetFormatters(HttpControllerDescriptor httpControllerDescriptor)
        {
            var config   = httpControllerDescriptor.Configuration;
            var dataDesc = DataControllerDescription.GetDescription(httpControllerDescriptor);

            var list = new List <MediaTypeFormatter>();

            AddFormattersFromConfig(list, config);
            AddDataControllerFormatters(list, dataDesc);

            return(list);
        }
Exemple #4
0
        private static void AddDataControllerFormatters(ICollection <MediaTypeFormatter> formatters, DataControllerDescription description)
        {
            var formatterJson = new JsonMediaTypeFormatter {
                SerializerSettings = new JsonSerializerSettings {
                    PreserveReferencesHandling = PreserveReferencesHandling.Objects,
                    TypeNameHandling           = TypeNameHandling.All
                }
            };



            formatters.Add(formatterJson);
            //formatters.Add(formatterXml);
        }