• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IJsonClassGeneratorConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: WriteClass

        public void WriteClass(IJsonClassGeneratorConfig config, TextWriter sw, JsonType type)
        {
            var visibility = config.InternalVisibility ? "Friend" : "Public";

            if (config.UseNestedClasses)
            {
                sw.WriteLine("    {0} Partial Class {1}", visibility, config.MainClass);
                if (!type.IsRoot)
                {
                    if (ShouldApplyNoRenamingAttribute(config)) sw.WriteLine("        " + NoRenameAttribute);
                    if (ShouldApplyNoPruneAttribute(config)) sw.WriteLine("        " + NoPruneAttribute);
                    sw.WriteLine("        {0} Class {1}", visibility, type.AssignedName);
                }
            }
            else
            {
                if (ShouldApplyNoRenamingAttribute(config)) sw.WriteLine("    " + NoRenameAttribute);
                if (ShouldApplyNoPruneAttribute(config)) sw.WriteLine("    " + NoPruneAttribute);
                sw.WriteLine("    {0} Class {1}", visibility, type.AssignedName);
            }

            var prefix = config.UseNestedClasses && !type.IsRoot ? "            " : "        ";

            WriteClassMembers(config, sw, type, prefix);

            if (config.UseNestedClasses && !type.IsRoot)
                sw.WriteLine("        End Class");

            sw.WriteLine("    End Class");
            sw.WriteLine();
        }
开发者ID:prasanjeevi,项目名称:AppInt,代码行数:31,代码来源:VisualBasicCodeWriter.cs


示例2: WriteFileEnd

 public void WriteFileEnd(IJsonClassGeneratorConfig config, TextWriter sw)
 {
     if (config.UseNestedClasses)
     {
         sw.WriteLine("    }");
     }
 }
开发者ID:gencer,项目名称:JsonUtils,代码行数:7,代码来源:SqlCodeWriter.cs


示例3: GetTypeName

        public string GetTypeName(JsonType type, IJsonClassGeneratorConfig config)
        {
            var arraysAsLists = !config.ExplicitDeserialization;

            switch (type.Type)
            {
                case JsonTypeEnum.Anything: return "object";
                case JsonTypeEnum.Array: return arraysAsLists ? "IList<" + GetTypeName(type.InternalType, config) + ">" : GetTypeName(type.InternalType, config) + "[]";
                case JsonTypeEnum.Dictionary: return "Dictionary<string, " + GetTypeName(type.InternalType, config) + ">";
                case JsonTypeEnum.Boolean: return "bit NOT NULL";
                case JsonTypeEnum.Float: return "[decimal](9,2) NOT NULL";
                case JsonTypeEnum.Integer: return "[int] NOT NULL";
                case JsonTypeEnum.Long: return "[bigint] NOT NULL";
                case JsonTypeEnum.Date: return "[datetime]";
                case JsonTypeEnum.NonConstrained: return "object";
                case JsonTypeEnum.NullableBoolean: return "bit NULL";
                case JsonTypeEnum.NullableFloat: return "[decimal](9,2) NULL";
                case JsonTypeEnum.NullableInteger: return "[int] NULL";
                case JsonTypeEnum.NullableLong: return "[bigint] NULL";
                case JsonTypeEnum.NullableDate: return "[datetime] NULL";
                case JsonTypeEnum.NullableSomething: return "object NULL";
                case JsonTypeEnum.Object: return type.AssignedName;
                case JsonTypeEnum.String: return "[varchar](50) NULL";
                default: throw new System.NotSupportedException("Unsupported json type");
            }
        }
开发者ID:gencer,项目名称:JsonUtils,代码行数:26,代码来源:SqlCodeWriter.cs


示例4: GetTypeName

        public string GetTypeName(JsonType type, IJsonClassGeneratorConfig config)
        {
            var arraysAsLists = !config.ExplicitDeserialization;

            switch (type.Type)
            {
                case JsonTypeEnum.Anything: return "object";
                case JsonTypeEnum.Array: return arraysAsLists ? "IList<" + GetTypeName(type.InternalType, config) + ">" : GetTypeName(type.InternalType, config) + "[]";
                case JsonTypeEnum.Dictionary: return "Dictionary<string, " + GetTypeName(type.InternalType, config) + ">";
                case JsonTypeEnum.Boolean: return "bool";
                case JsonTypeEnum.Float: return "double";
                case JsonTypeEnum.Integer: return "int";
                case JsonTypeEnum.Long: return "long";
                case JsonTypeEnum.Date: return "DateTime";
                case JsonTypeEnum.NonConstrained: return "object";
                case JsonTypeEnum.NullableBoolean: return "bool?";
                case JsonTypeEnum.NullableFloat: return "double?";
                case JsonTypeEnum.NullableInteger: return "int?";
                case JsonTypeEnum.NullableLong: return "long?";
                case JsonTypeEnum.NullableDate: return "DateTime?";
                case JsonTypeEnum.NullableSomething: return "object";
                case JsonTypeEnum.Object: return type.AssignedName;
                case JsonTypeEnum.String: return "string";
                default: throw new NotSupportedException("Unsupported json type");
            }
        }
开发者ID:modulexcite,项目名称:jsondatacontext-linqpad,代码行数:26,代码来源:CSharpCodeWriter.cs


示例5: GetTypeName

        public string GetTypeName(JsonType type, IJsonClassGeneratorConfig config)
        {
            var arraysAsLists = config.ExplicitDeserialization;

            switch (type.Type)
            {
                case JsonTypeEnum.Anything: return "Object";
                case JsonTypeEnum.Array: return arraysAsLists ? "IList(Of " + GetTypeName(type.InternalType, config) + ")" : GetTypeName(type.InternalType, config) + "()";
                case JsonTypeEnum.Dictionary: return "Dictionary(Of String, " + GetTypeName(type.InternalType, config) + ")";
                case JsonTypeEnum.Boolean: return "Boolean";
                case JsonTypeEnum.Float: return "Double";
                case JsonTypeEnum.Integer: return "Integer";
                case JsonTypeEnum.Long: return "Long";
                case JsonTypeEnum.Date: return "DateTime";
                case JsonTypeEnum.NonConstrained: return "Object";
                case JsonTypeEnum.NullableBoolean: return "Boolean?";
                case JsonTypeEnum.NullableFloat: return "Double?";
                case JsonTypeEnum.NullableInteger: return "Integer?";
                case JsonTypeEnum.NullableLong: return "Long?";
                case JsonTypeEnum.NullableDate: return "DateTime?";
                case JsonTypeEnum.NullableSomething: return "Object";
                case JsonTypeEnum.Object: return type.AssignedName;
                case JsonTypeEnum.String: return "String";
                default: throw new System.NotSupportedException("Unsupported json type");
            }
        }
开发者ID:prasanjeevi,项目名称:AppInt,代码行数:26,代码来源:VisualBasicCodeWriter.cs


示例6: WriteFileStart

        public void WriteFileStart(IJsonClassGeneratorConfig config, TextWriter sw)
        {
            if (config.UseNamespaces)
            {
                foreach (var line in JsonClassGenerator.FileHeader)
                {
                    sw.WriteLine("// " + line);
                }
                sw.WriteLine();
                sw.WriteLine("using System;");
                sw.WriteLine("using System.Collections.Generic;");
                if (ShouldApplyNoPruneAttribute(config) || ShouldApplyNoRenamingAttribute(config))
                    sw.WriteLine("using System.Reflection;");
                if (!config.ExplicitDeserialization && config.UsePascalCase)
                    sw.WriteLine("using Newtonsoft.Json;");
                sw.WriteLine("using Newtonsoft.Json.Linq;");
                if (config.ExplicitDeserialization)
                    sw.WriteLine("using JsonCSharpClassGenerator;");
                if (config.SecondaryNamespace != null && config.HasSecondaryClasses && !config.UseNestedClasses)
                {
                    sw.WriteLine("using {0};", config.SecondaryNamespace);
                }
            }

            if (config.UseNestedClasses)
            {
                sw.WriteLine("    {0} class {1}", config.InternalVisibility ? "internal" : "public", config.MainClass);
                sw.WriteLine("    {");
            }
        }
开发者ID:ryanhair,项目名称:SpecialCopy,代码行数:30,代码来源:CSharpCodeWriter.cs


示例7: WriteFileStart

 public void WriteFileStart(IJsonClassGeneratorConfig config, TextWriter sw)
 {
     foreach (var line in JsonClassGenerator.FileHeader)
     {
         sw.WriteLine("// " + line);
     }
 }
开发者ID:EvanYaoPeng,项目名称:Kalman.Studio,代码行数:7,代码来源:JavaCodeWriter.cs


示例8: WriteClass

        public void WriteClass(IJsonClassGeneratorConfig config, TextWriter sw, JsonType type)
        {
            var visibility = "public";

            sw.WriteLine();
            sw.WriteLine("package {0};",config.Namespace );
            if (config.UseNestedClasses)
            {
                if (!type.IsRoot)
                {
                    if (ShouldApplyNoRenamingAttribute(config)) sw.WriteLine("        " + NoRenameAttribute);
                    if (ShouldApplyNoPruneAttribute(config)) sw.WriteLine("        " + NoPruneAttribute);
                    sw.WriteLine("        {0} class {1}", visibility, type.AssignedName);
                    sw.WriteLine("        {");
                }
            }
            else
            {
                if (ShouldApplyNoRenamingAttribute(config)) sw.WriteLine("    " + NoRenameAttribute);
                if (ShouldApplyNoPruneAttribute(config)) sw.WriteLine("    " + NoPruneAttribute);
                sw.WriteLine("    {0} class {1}", visibility, type.AssignedName);
                sw.WriteLine("    {");
            }

            var prefix = config.UseNestedClasses && !type.IsRoot ? "            " : "        ";

            var shouldSuppressWarning = config.InternalVisibility && !config.UseProperties && !config.ExplicitDeserialization;
            if (shouldSuppressWarning)
            {
                sw.WriteLine("#pragma warning disable 0649");
                if (!config.UsePascalCase) sw.WriteLine();
            }

            if (type.IsRoot && config.ExplicitDeserialization) WriteStringConstructorExplicitDeserialization(config, sw, type, prefix);

            if (config.ExplicitDeserialization)
            {
                if (config.UseProperties) WriteClassWithPropertiesExplicitDeserialization(sw, type, prefix);
                else WriteClassWithFieldsExplicitDeserialization(sw, type, prefix);
            }
            else
            {
                WriteClassMembers(config, sw, type, prefix);
            }

            if (shouldSuppressWarning)
            {
                sw.WriteLine();
                sw.WriteLine("#pragma warning restore 0649");
                sw.WriteLine();
            }

            if (config.UseNestedClasses && !type.IsRoot)
                sw.WriteLine("        }");

            if (!config.UseNestedClasses)
                sw.WriteLine("    }");

            sw.WriteLine();
        }
开发者ID:460791814,项目名称:NewJson,代码行数:60,代码来源:JavaCodeWriter.cs


示例9: WriteNamespaceEnd

 public void WriteNamespaceEnd(IJsonClassGeneratorConfig config, TextWriter sw, bool root)
 {
     if (GetNamespace(config, root) != null)
     {
         sw.WriteLine("}");
         sw.WriteLine();
     }
 }
开发者ID:prasanjeevi,项目名称:AppInt,代码行数:8,代码来源:TypeScriptCodeWriter.cs


示例10: FieldInfo

 public FieldInfo(IJsonClassGeneratorConfig generator, string jsonMemberName, JsonType type, bool usePascalCase, IList<object> Examples)
 {
     this.generator = generator;
     this.JsonMemberName = jsonMemberName;
     this.MemberName = jsonMemberName;
     if (usePascalCase) MemberName = JsonCSharpClassGenerator.JsonClassGenerator.ToTitleCase(MemberName);
     this.Type = type;
     this.Examples = Examples;
 }
开发者ID:neeraj1032,项目名称:BluePOCO,代码行数:9,代码来源:FieldInfo.cs


示例11: JsonType

        public JsonType(IJsonClassGeneratorConfig generator, JToken token)
            : this(generator)
        {
            Type = GetFirstTypeEnum(token);

            if (Type == JsonTypeEnum.Array)
            {
                var array = (JArray)token;
                InternalType = GetCommonType(generator, array.ToArray());
            }
        }
开发者ID:neeraj1032,项目名称:BluePOCO,代码行数:11,代码来源:JsonType.cs


示例12: WriteClassMembers

        private void WriteClassMembers(IJsonClassGeneratorConfig config, TextWriter sw, JsonType type)
        {
            foreach (var field in type.Fields)
            {              
                if (config.UseProperties)
                {
                    string typeName = field.Type.InternalType == null 
                        ? field.Type.GetTypeName() 
                        : field.Type.InternalType.GetTypeName();

                    sw.WriteLine("    [{0}] {1},", field.MemberName, typeName);
                }
            }
        }
开发者ID:gencer,项目名称:JsonUtils,代码行数:14,代码来源:SqlCodeWriter.cs


示例13: WriteClass

        public void WriteClass(IJsonClassGeneratorConfig config, TextWriter sw, JsonType type)
        {
            sw.WriteLine("create table " + type.AssignedName + " (");
            sw.WriteLine("    [Id] [int] IDENTITY(1,1) NOT NULL,");

            WriteClassMembers(config, sw, type);

            sw.WriteLine("CONSTRAINT [PK_" + type.AssignedName + "] PRIMARY KEY CLUSTERED");
            sw.WriteLine("   (");
            sw.WriteLine("      [Id] asc");
            sw.WriteLine("   )");
            sw.WriteLine(")");

            sw.WriteLine();
        }
开发者ID:gencer,项目名称:JsonUtils,代码行数:15,代码来源:SqlCodeWriter.cs


示例14: GetCommonType

        public static JsonType GetCommonType(IJsonClassGeneratorConfig generator, JToken[] tokens)
        {

            if (tokens.Length == 0) return new JsonType(generator, JsonTypeEnum.NonConstrained);

            var common = new JsonType(generator, tokens[0]).MaybeMakeNullable(generator);

            for (int i = 1; i < tokens.Length; i++)
            {
                var current = new JsonType(generator, tokens[i]);
                common = common.GetCommonType(current);
            }

            return common;

        }
开发者ID:ryanhair,项目名称:SpecialCopy,代码行数:16,代码来源:JsonType.cs


示例15: WriteClass

        public void WriteClass(IJsonClassGeneratorConfig config, TextWriter sw, JsonType type)
        {
            var prefix = GetNamespace(config, type.IsRoot) != null ? "    " : "";
            var exported = !config.InternalVisibility || config.SecondaryNamespace != null;
            sw.WriteLine(prefix + (exported ? "export " : string.Empty) + "interface " + type.AssignedName + " {");
            foreach (var field in type.Fields)
            {
                var shouldDefineNamespace = type.IsRoot && config.SecondaryNamespace != null && config.Namespace != null && (field.Type.Type == JsonTypeEnum.Object || (field.Type.InternalType != null && field.Type.InternalType.Type == JsonTypeEnum.Object));
                if (config.ExamplesInDocumentation)
                {
                    sw.WriteLine();
                    sw.WriteLine(prefix + "    /**");
                    sw.WriteLine(prefix + "      * Examples: " + field.GetExamplesText());
                    sw.WriteLine(prefix + "      */");
                }

                sw.WriteLine(prefix + "    " + field.JsonMemberName + (IsNullable(field.Type.Type) ? "?" : "") + ": " + (shouldDefineNamespace ? config.SecondaryNamespace + "." : string.Empty) + GetTypeName(field.Type, config) + ";");
            }
            sw.WriteLine(prefix + "}");
            sw.WriteLine();
        }
开发者ID:prasanjeevi,项目名称:AppInt,代码行数:21,代码来源:TypeScriptCodeWriter.cs


示例16: GetTypeName

 public string GetTypeName(JsonType type, IJsonClassGeneratorConfig config)
 {
     switch (type.Type)
     {
         case JsonTypeEnum.Anything: return "any";
         case JsonTypeEnum.String: return "string";
         case JsonTypeEnum.Boolean: return "bool";
         case JsonTypeEnum.Integer:
         case JsonTypeEnum.Long:
         case JsonTypeEnum.Float: return "number";
         case JsonTypeEnum.Date: return "Date";
         case JsonTypeEnum.NullableInteger:
         case JsonTypeEnum.NullableLong:
         case JsonTypeEnum.NullableFloat: return "number";
         case JsonTypeEnum.NullableBoolean: return "bool";
         case JsonTypeEnum.NullableDate: return "Date";
         case JsonTypeEnum.Object: return type.AssignedName;
         case JsonTypeEnum.Array: return GetTypeName(type.InternalType, config) + "[]";
         case JsonTypeEnum.Dictionary: return "{ [key: string]: " + GetTypeName(type.InternalType, config) + "; }";
         case JsonTypeEnum.NullableSomething: return "any";
         case JsonTypeEnum.NonConstrained: return "any";
         default: throw new NotSupportedException("Unsupported type");
     }
 }
开发者ID:prasanjeevi,项目名称:AppInt,代码行数:24,代码来源:TypeScriptCodeWriter.cs


示例17: WriteFileStart

 public void WriteFileStart(IJsonClassGeneratorConfig config, TextWriter sw)
 {
     sw.WriteLine("Imports System");
     sw.WriteLine("Imports System.Collections.Generic");
     if (ShouldApplyNoRenamingAttribute(config) || ShouldApplyNoPruneAttribute(config))
         sw.WriteLine("Imports System.Reflection");
     if (config.UsePascalCase)
         sw.WriteLine("Imports Newtonsoft.Json");
     sw.WriteLine("Imports Newtonsoft.Json.Linq");
     if (config.SecondaryNamespace != null && config.HasSecondaryClasses && !config.UseNestedClasses)
     {
         sw.WriteLine("Imports {0}", config.SecondaryNamespace);
     }
 }
开发者ID:prasanjeevi,项目名称:AppInt,代码行数:14,代码来源:VisualBasicCodeWriter.cs


示例18: WriteFileEnd

 public void WriteFileEnd(IJsonClassGeneratorConfig config, TextWriter sw)
 {
 }
开发者ID:prasanjeevi,项目名称:AppInt,代码行数:3,代码来源:VisualBasicCodeWriter.cs


示例19: GetNull

 internal static JsonType GetNull(IJsonClassGeneratorConfig generator)
 {
     return new JsonType(generator, JsonTypeEnum.NullableSomething);
 }
开发者ID:neeraj1032,项目名称:BluePOCO,代码行数:4,代码来源:JsonType.cs


示例20: MaybeMakeNullable

 internal JsonType MaybeMakeNullable(IJsonClassGeneratorConfig generator)
 {
     if (!generator.AlwaysUseNullableValues) return this;
     return this.GetCommonType(JsonType.GetNull(generator));
 }
开发者ID:neeraj1032,项目名称:BluePOCO,代码行数:5,代码来源:JsonType.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IJsonLineInfo类代码示例发布时间:2022-05-24
下一篇:
C# IJoinable类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap