当前位置: 首页>>代码示例>>C#>>正文


C# MediaTypeFormatterCollection.Remove方法代码示例

本文整理汇总了C#中MediaTypeFormatterCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# MediaTypeFormatterCollection.Remove方法的具体用法?C# MediaTypeFormatterCollection.Remove怎么用?C# MediaTypeFormatterCollection.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaTypeFormatterCollection的用法示例。


在下文中一共展示了MediaTypeFormatterCollection.Remove方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureFormatters

        private static void ConfigureFormatters(MediaTypeFormatterCollection formatters)
        {
            // Remove unnecessary formatters
            MediaTypeFormatter jqueryFormatter = formatters.FirstOrDefault(x => x.GetType() == typeof(JQueryMvcFormUrlEncodedFormatter));
            formatters.Remove(formatters.XmlFormatter);
            formatters.Remove(formatters.FormUrlEncodedFormatter);
            formatters.Remove(jqueryFormatter);

            // Suppressing the IRequiredMemberSelector for all formatters
            foreach (var formatter in formatters)
            {
                formatter.RequiredMemberSelector = new SuppressedRequiredMemberSelector();
            }
        }
开发者ID:FukKwang,项目名称:SignalRSamples,代码行数:14,代码来源:WebApiConfig.cs

示例2: RegisterFormatters

 public static void RegisterFormatters(MediaTypeFormatterCollection formatters)
 {
     formatters.Remove(formatters.XmlFormatter);
     formatters.Remove(formatters.JsonFormatter);
     var formatter = new JsonMediaTypeFormatter
     {
         SerializerSettings = new JsonSerializerSettings
         {
             ContractResolver = new CamelCasePropertyNamesContractResolver()
         }
     };
     formatter.SerializerSettings.Converters.Add(new ExpandoObjectConverter());
     formatters.Insert(0, formatter);
 }
开发者ID:anandraj204,项目名称:First,代码行数:14,代码来源:FormatterConfig.cs

示例3: ConfigureFormatters

        public static void ConfigureFormatters(MediaTypeFormatterCollection formatters)
        {
            formatters.Remove(formatters.XmlFormatter);

            JsonSerializerSettings settings = formatters.JsonFormatter.SerializerSettings;
            settings.Formatting = Formatting.None;
        }
开发者ID:calvin-pietersen,项目名称:ServiceFabricTSDB,代码行数:7,代码来源:FormatterConfig.cs

示例4: RegisterFormatters

 public static void RegisterFormatters(MediaTypeFormatterCollection formatters)
 {
     formatters.Remove(formatters.XmlFormatter);
     
     var json = formatters.JsonFormatter;
     json.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
 }
开发者ID:agrc,项目名称:api.mapserv.utah.gov,代码行数:7,代码来源:FormatterConfig.cs

示例5: Configure

        private static void Configure(MediaTypeFormatterCollection formatters, HttpConfiguration config)
        {
            var xml = config.Formatters.XmlFormatter;
            formatters.Remove(xml);

            var json = config.Formatters.JsonFormatter;
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        }
开发者ID:selgstoen,项目名称:QiuzWeb,代码行数:8,代码来源:WebApiConfig.cs

示例6: RegisterFormatters

 public static void RegisterFormatters(MediaTypeFormatterCollection formatters)
 {
     formatters.Remove(formatters.JsonFormatter);
     formatters.Insert(0, new JsonpMediaTypeFormatter {
         SerializerSettings = new JsonSerializerSettings {
             ContractResolver = new CamelCasePropertyNamesContractResolver()
         }
     });
 }
开发者ID:ntheile,项目名称:CrossFront-Backend,代码行数:9,代码来源:FormatterConfig.cs

示例7: SetFormatters

        private static void SetFormatters(MediaTypeFormatterCollection formatters)
        {
            formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

            formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.None;
            formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            formatters.JsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true });
            formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Include;
        }
开发者ID:1aia,项目名称:webapp,代码行数:9,代码来源:WebApiConfig.cs

示例8: RegisterFormatters

        public static void RegisterFormatters(MediaTypeFormatterCollection formatters)
        {
            // Remove xml formatter (at least for the moment)
            formatters.Remove(formatters.XmlFormatter);

            // Json formatter
            //formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            //formatters.JsonFormatter.Indent = true; ?
            //formatters.JsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter());
            //formatters.JsonFormatter.MaxDepth = 1;
            //formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
        }
开发者ID:gitter-badger,项目名称:WealthEconomy,代码行数:12,代码来源:FormatterConfig.cs

示例9: RegisterFormatters

        public static void RegisterFormatters(MediaTypeFormatterCollection formatters)
        {
            var jsonFormatter = formatters.JsonFormatter;
            jsonFormatter.SerializerSettings = new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects,
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            };

            formatters.Remove(formatters.XmlFormatter);
            formatters.Insert(0, new JsonMediaTypeFormatter());
        }
开发者ID:worldtechwonder,项目名称:RESTAPI,代码行数:13,代码来源:FormatterConfig.cs

示例10: RegisterJsonNetMediaTypeFormatter

 public static void RegisterJsonNetMediaTypeFormatter(MediaTypeFormatterCollection formatters)
 {
     formatters.Remove(formatters.OfType<JsonMediaTypeFormatter>().FirstOrDefault());
     formatters.Add(new JsonNetMediaTypeFormatter());
 }
开发者ID:richardneililagan,项目名称:JSON.net-Web-API-MediaTypeFormatter,代码行数:5,代码来源:MediaTypeFormatterConfig.cs

示例11: Remove_SetsJsonFormatter

 public void Remove_SetsJsonFormatter()
 {
     MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection();
     int count = collection.Count;
     collection.Remove(collection.JsonFormatter);
     Assert.Null(collection.JsonFormatter);
     Assert.Equal(count - 1, collection.Count);
 }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:8,代码来源:MediaTypeFormatterCollectionTests.cs

示例12: RemoveFormatters

        private static void RemoveFormatters(MediaTypeFormatterCollection formatterCollection,
            IEnumerable<MediaTypeFormatter> formattersToRemove)
        {
            Contract.Assert(formatterCollection != null);
            Contract.Assert(formattersToRemove != null);

            // Instantiate a separate array to isolate enumeration from deletions. This code would otherwise throw
            // after the first removal.
            foreach (MediaTypeFormatter formatter in formattersToRemove.ToArray())
            {
                formatterCollection.Remove(formatter);
            }
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:13,代码来源:ODataFormattingAttribute.cs


注:本文中的MediaTypeFormatterCollection.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。