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


C# Formatting类代码示例

本文整理汇总了C#中Formatting的典型用法代码示例。如果您正苦于以下问题:C# Formatting类的具体用法?C# Formatting怎么用?C# Formatting使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ToJson

 public string ToJson(Formatting format = Formatting.None)
 {
     JsonSerializerSettings setting = new JsonSerializerSettings();
     setting.NullValueHandling = NullValueHandling.Ignore;
     string json = JsonConvert.SerializeObject(this, format, setting);
     return json;
 }
开发者ID:dinner3000,项目名称:CDK.MCC.SOAPServiceTest,代码行数:7,代码来源:MCCRequestParameters.cs

示例2: GetTagName

        private static string GetTagName(Formatting formatting)
        {
            switch (formatting)
            {
                case Formatting.Bold:
                    return "b";

                case Formatting.Italic:
                    return "i";

                case Formatting.Underline:
                    return "u";

                case Formatting.Strikethrough:
                    return "del";

                case Formatting.Subscript:
                    return "sub";
                
                case Formatting.Superscript:
                    return "sup";
                
                default:
                    throw new ArgumentOutOfRangeException("formatting");
            }
        }
开发者ID:kostrse,项目名称:MayMart.Wiki,代码行数:26,代码来源:FormattingElement.cs

示例3: ForTypesWithoutInterfacesCustomSerializerSerializesTheSameAsDefaultSerializer

        public void ForTypesWithoutInterfacesCustomSerializerSerializesTheSameAsDefaultSerializer(
            object instance,
            string defaultNamespace,
            Type[] extraTypes,
            string rootElementName,
            Encoding encoding,
            Formatting formatting,
            XmlSerializerNamespaces namespaces)
        {
            var defaultSerializer =
                (IXmlSerializer)Activator.CreateInstance(
                    typeof(DefaultSerializer<>).MakeGenericType(instance.GetType()),
                    defaultNamespace,
                    extraTypes,
                    rootElementName);
            var customSerializer =
                (IXmlSerializer)Activator.CreateInstance(
                    typeof(CustomSerializer<>).MakeGenericType(instance.GetType()),
                    defaultNamespace,
                    extraTypes,
                    rootElementName);

            var defaultXml = defaultSerializer.SerializeObject(instance, namespaces, encoding, formatting);
            var customXml = customSerializer.SerializeObject(instance, namespaces, encoding, formatting);

            Console.WriteLine("Default XML:");
            Console.WriteLine(defaultXml);
            Console.WriteLine();
            Console.WriteLine("Custom XML:");
            Console.WriteLine(customXml);

            Assert.That(customXml, Is.EqualTo(defaultXml));
        }
开发者ID:korzy1bj,项目名称:XSerializer,代码行数:33,代码来源:SerializationTests.cs

示例4: DocumentWriter

 public DocumentWriter(Formatting formatting)
     : this(formatting,
         new JsonSerializerSettings
         {
             ContractResolver = new CamelCasePropertyNamesContractResolver()
         })
 {
 }
开发者ID:noikiy,项目名称:graphql-dotnet,代码行数:8,代码来源:DocumentWriter.cs

示例5: JsonNetResult

 public JsonNetResult(object data, 
     Formatting formatting = Formatting.None, 
     JsonSerializerSettings settings = null)
 {
     Data = data; 
     SerializerSettings = settings ?? new JsonSerializerSettings();
     Formatting = formatting;                         
 }
开发者ID:emretiryaki,项目名称:WestwindToolkit,代码行数:8,代码来源:JsonNetResult.cs

示例6: WithJsonSerializer

 /// <summary>
 ///     To provide custom serialization using the <see cref="Newtonsoft.Json.JsonSerializer" />.
 /// </summary>
 /// <param name="configuration">The bus configuration to apply the serializer to.</param>
 /// <param name="settings">To configure serialization settings.</param>
 /// <param name="formatting">To configure serialization formatting.</param>
 /// <param name="fallbackSerializer">To add a fallback serializer (if i.e you want to support both XML and Json)</param>
 /// <returns>Bus configuration.</returns>
 public static BusBuilderConfiguration.Config WithJsonSerializer(
     this BusBuilderConfiguration.Config configuration,
     JsonSerializerSettings settings,
     Formatting formatting = Formatting.None,
     ISerializer fallbackSerializer = null)
 {
     return configuration.WithSerializer(new JsonSerializer(settings, formatting, fallbackSerializer));
 }
开发者ID:AtmosphereMessaging,项目名称:Cumulus-vNext,代码行数:16,代码来源:BusBuilderConfigurationJsonSerializerExtensions.cs

示例7: WriteObjectAsString

 public string WriteObjectAsString(object obj, Formatting formatting = Formatting.None, TypeNameHandling nameHandling = TypeNameHandling.Auto)
 {
     return JsonConvert.SerializeObject(obj, formatting,
             new JsonSerializerSettings
             {
                 NullValueHandling = NullValueHandling.Ignore,
                 TypeNameHandling = nameHandling
             });
 }
开发者ID:Websilk,项目名称:Home,代码行数:9,代码来源:Serializer.cs

示例8: SaveToFile

 public void SaveToFile(object obj, string file, Formatting formatting = Formatting.Indented, TypeNameHandling nameHandling = TypeNameHandling.Auto)
 {
     var path = Util.Str.getFolder(file);
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
     File.WriteAllText(file, WriteObjectAsString(obj, formatting, nameHandling));
 }
开发者ID:Websilk,项目名称:Home,代码行数:9,代码来源:Serializer.cs

示例9: InternalToString

		internal override string InternalToString(Formatting format, int depth)
		{
			if (Value != null && Value.Length > 0)
				return string.Concat("\"base64:",
					Convert.ToBase64String(this.Value),
				"\"");
			else
				return "\"base64:\"";
		}
开发者ID:troygeiger,项目名称:TG.JSON,代码行数:9,代码来源:JsonBinary.cs

示例10: JsonNetResult

 public JsonNetResult(object data)
 {
     this.data = data;
     formatting = Formatting.None;
     serializerSettings = new JsonSerializerSettings
     {
         ContractResolver = new CamelCasePropertyNamesContractResolver()
     };
 }
开发者ID:jasonmitchell,项目名称:aspnetmvc-knockoutjs-quickstart,代码行数:9,代码来源:JsonNetResult.cs

示例11: Serialize

 public static string Serialize(LanguageDefinition definition, Formatting formatting, bool serializeAsArrays = false)
 {
     //var json = JsonConvert.SerializeObject(definition, formatting, new InlineDefinitionJsonConverter(), new StringDefinitionJsonConverter(serializeAsArrays));
     var settings = new JsonSerializerSettings();// {TypeNameHandling = TypeNameHandling.All};
     settings.Converters.Add(new InlineDefinitionJsonConverter(serializeAsArrays));
     settings.Converters.Add(new StringDefinitionJsonConverter(serializeAsArrays));
     var json = JsonConvert.SerializeObject(definition, formatting, settings);
     return json;
 }
开发者ID:kipters,项目名称:Mascetti,代码行数:9,代码来源:Helper.cs

示例12: SinglePage

 public static string SinglePage(Formatting.FormattedHtml htmlContent)
 {
     var m = new Models.SingleFileModel()
     {
         Stylesheets = new[] { htmlContent.Stylesheet },
         PreformattedHtml = htmlContent.Html,
         Javascript = new[] { htmlContent.Javascript }
     };
     return RenderSingleFile(m);
 }
开发者ID:pombredanne,项目名称:cshighlighter,代码行数:10,代码来源:Render.cs

示例13: JsonNetResult

        public JsonNetResult()
        {
            SerializerSettings = new JsonSerializerSettings();

            //SerializerSettings.Converters.Add(new JavaScriptDateTimeConverter());
            SerializerSettings.Converters.Add(new IsoDateTimeConverter());
            SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
            SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            Formatting = Formatting.None;
        }
开发者ID:NemediDev,项目名称:Intercom.Heath,代码行数:10,代码来源:JsonNetResult.cs

示例14: ObjectToJson

        public static string ObjectToJson(this IHtmlHelper helper, object input, Formatting jsonFormatting, params JsonConverter[] converters)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings();
            if (converters != null) {
                foreach (JsonConverter converter in converters) {
                    settings.Converters.Add(converter);
                }
            }

            return JsonConvert.SerializeObject(input, jsonFormatting, settings);
        }
开发者ID:jammerware,项目名称:bazam,代码行数:11,代码来源:BazamHtmlHelpers.cs

示例15: DocumentWriter

 public DocumentWriter(Formatting formatting)
     : this(
         formatting,
         new JsonSerializerSettings
         {
             ContractResolver = new CamelCasePropertyNamesContractResolver(),
             DateFormatHandling = DateFormatHandling.IsoDateFormat,
             DateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFF'Z'",
         })
 {
 }
开发者ID:ericziko,项目名称:graphql-dotnet,代码行数:11,代码来源:DocumentWriter.cs


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