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


C# JsonSchemaType类代码示例

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


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

示例1: TestType

        private bool TestType(JsonSchemaModel currentSchema, JsonSchemaType currentType)
        {
            if (!JsonSchemaGenerator.HasFlag(currentSchema.Type, currentType))
            {
                RaiseError("Invalid type. Expected {0} but got {1}.".FormatWith(CultureInfo.InvariantCulture, currentSchema.Type, currentType), currentSchema);
                return false;
            }

            return true;
        }
开发者ID:nerai,项目名称:nibbler,代码行数:10,代码来源:JsonValidatingReader.cs

示例2: AddNullType

    private JsonSchemaType AddNullType(JsonSchemaType type, Required valueRequired)
    {
      if (valueRequired != Required.Always)
        return type | JsonSchemaType.Null;

      return type;
    }
开发者ID:AshD,项目名称:Newtonsoft.Json,代码行数:7,代码来源:JsonSchemaGenerator.cs

示例3: HasFlag

    internal static bool HasFlag(JsonSchemaType? value, JsonSchemaType flag)
    {
      // default value is Any
      if (value == null)
        return true;

      return ((value & flag) == flag);
    }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:8,代码来源:JsonSchemaGenerator.cs

示例4: MapType

 internal static string MapType(JsonSchemaType type)
 {
   return JsonSchemaConstants.JsonSchemaTypeMapping.Single(kv => kv.Value == type).Key;
 }
开发者ID:GCC-Autobahn,项目名称:Newtonsoft.Json,代码行数:4,代码来源:JsonSchemaBuilder.cs

示例5: MapType

 internal static string MapType(JsonSchemaType type)
 {
   return Enumerable.Single<KeyValuePair<string, JsonSchemaType>>((IEnumerable<KeyValuePair<string, JsonSchemaType>>) JsonSchemaConstants.JsonSchemaTypeMapping, (Func<KeyValuePair<string, JsonSchemaType>, bool>) (kv => kv.Value == type)).Key;
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:4,代码来源:JsonSchemaBuilder.cs

示例6: TestType

 private bool TestType(JsonSchemaModel currentSchema, JsonSchemaType currentType)
 {
   if (JsonSchemaGenerator.HasFlag(new JsonSchemaType?(currentSchema.Type), currentType))
     return true;
   this.RaiseError(StringUtils.FormatWith("Invalid type. Expected {0} but got {1}.", (IFormatProvider) CultureInfo.InvariantCulture, (object) currentSchema.Type, (object) currentType), currentSchema);
   return false;
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:7,代码来源:JsonValidatingReader.cs

示例7: Map

		public static string Map(JsonSchemaType? type)
		{
			return type == null || !typeConversion.ContainsKey(type.Value) ? null : typeConversion[type.Value];
		}
开发者ID:Kristinn-Stefansson,项目名称:raml-dotnet-tools,代码行数:4,代码来源:NetTypeMapper.cs

示例8: GetPrimitiveTypeAsString

 /// <summary>
 ///     Get the primitive name of a type if it exists.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns>The primitive type as a string, if it exists.</returns>
 public static string GetPrimitiveTypeAsString(JsonSchemaType? type)
 {
     string sType = type.ToString();
     return Primitives.ContainsKey(sType) ? Primitives[sType] : "System.Object";
 }
开发者ID:aeagle,项目名称:json-schema-2-poco,代码行数:10,代码来源:TypeUtils.cs

示例9: JsonSchemaTypesToLabel

        private static string JsonSchemaTypesToLabel(JsonSchemaType type)
        {
            var types = new string[6];

            int index = 0;

            if ((type & JsonSchemaType.String) == JsonSchemaType.String)
                types[index++] = "string";
            if ((type & JsonSchemaType.Float) == JsonSchemaType.Float || (type & JsonSchemaType.Integer) == JsonSchemaType.Integer)
                types[index++] = "number";
            if ((type & JsonSchemaType.Boolean) == JsonSchemaType.Boolean)
                types[index++] = "boolean";
            if ((type & JsonSchemaType.Object) == JsonSchemaType.Object)
                types[index++] = "object";
            if ((type & JsonSchemaType.Array) == JsonSchemaType.Array)
                types[index++] = "array";
            if ((type & JsonSchemaType.Null) == JsonSchemaType.Null)
                types[index++] = "null";

            switch (index)
            {
                case 0:
                    return "";
                case 1:
                    return types[0];
                case 2:
                    return types[0] + " or " + types[1];
                default:
                    return string.Join(", ", types, 0, index - 1) + ", or " + types[index - 1];
            }
        }
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:31,代码来源:MarkdownGenerator.cs

示例10: WriteType

 // Token: 0x06000A0F RID: 2575
 // RVA: 0x0003F7F8 File Offset: 0x0003D9F8
 private void WriteType(string propertyName, JsonWriter writer, JsonSchemaType type)
 {
     IList<JsonSchemaType> list;
     if (Enum.IsDefined(typeof(JsonSchemaType), type))
     {
         list = new List<JsonSchemaType>
         {
             type
         };
     }
     else
     {
         list = Enumerable.ToList<JsonSchemaType>(Enumerable.Where<JsonSchemaType>(EnumUtils.GetFlagsValues<JsonSchemaType>(type), (JsonSchemaType v) => v != JsonSchemaType.None));
     }
     if (list.Count == 0)
     {
         return;
     }
     writer.WritePropertyName(propertyName);
     if (list.Count == 1)
     {
         writer.WriteValue(JsonSchemaBuilder.MapType(list[0]));
         return;
     }
     writer.WriteStartArray();
     foreach (JsonSchemaType current in list)
     {
         writer.WriteValue(JsonSchemaBuilder.MapType(current));
     }
     writer.WriteEndArray();
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:33,代码来源:JsonSchemaWriter.cs

示例11: WriteType

 private void WriteType(string propertyName, JsonWriter writer, JsonSchemaType type)
 {
   IList<JsonSchemaType> list;
   if (Enum.IsDefined(typeof (JsonSchemaType), (object) type))
     list = (IList<JsonSchemaType>) new List<JsonSchemaType>()
     {
       type
     };
   else
     list = (IList<JsonSchemaType>) Enumerable.ToList<JsonSchemaType>(Enumerable.Where<JsonSchemaType>((IEnumerable<JsonSchemaType>) EnumUtils.GetFlagsValues<JsonSchemaType>(type), (Func<JsonSchemaType, bool>) (v => v != JsonSchemaType.None)));
   if (list.Count == 0)
     return;
   writer.WritePropertyName(propertyName);
   if (list.Count == 1)
   {
     writer.WriteValue(JsonSchemaBuilder.MapType(list[0]));
   }
   else
   {
     writer.WriteStartArray();
     foreach (JsonSchemaType type1 in (IEnumerable<JsonSchemaType>) list)
       writer.WriteValue(JsonSchemaBuilder.MapType(type1));
     writer.WriteEndArray();
   }
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:25,代码来源:JsonSchemaWriter.cs

示例12: MapType

 // Token: 0x06000B75 RID: 2933
 // RVA: 0x00042A00 File Offset: 0x00040C00
 internal static string MapType(JsonSchemaType type)
 {
     return Enumerable.Single<KeyValuePair<string, JsonSchemaType>>(JsonSchemaConstants.JsonSchemaTypeMapping, (KeyValuePair<string, JsonSchemaType> kv) => kv.Value == type).Key;
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:6,代码来源:JsonSchemaBuilder.cs

示例13: HasFlag

 // Token: 0x06000B8C RID: 2956
 // RVA: 0x000431E0 File Offset: 0x000413E0
 internal static bool HasFlag(JsonSchemaType? value, JsonSchemaType flag)
 {
     return !value.HasValue || (value & flag) == flag || (flag == JsonSchemaType.Integer && (value & JsonSchemaType.Float) == JsonSchemaType.Float);
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:6,代码来源:JsonSchemaGenerator.cs

示例14: HasFlag

    internal static bool HasFlag(JsonSchemaType? value, JsonSchemaType flag)
    {
      // default value is Any
      if (value == null)
        return true;

      bool match = ((value & flag) == flag);
      if (match)
        return true;

      // integer is a subset of float
      if (value == JsonSchemaType.Float && flag == JsonSchemaType.Integer)
        return true;

      return false;
    }
开发者ID:AshD,项目名称:Newtonsoft.Json,代码行数:16,代码来源:JsonSchemaGenerator.cs

示例15: JsonSchemaTypesToLabel

        private string JsonSchemaTypesToLabel(JsonSchemaType type)
        {
            var types = new string[6];

            int index = 0;

            if ((type & JsonSchemaType.String) == JsonSchemaType.String)
                types[index++] = "string";
            if ((type & JsonSchemaType.Float) == JsonSchemaType.Float || (type & JsonSchemaType.Integer) == JsonSchemaType.Integer)
                types[index++] = "number";
            if ((type & JsonSchemaType.Boolean) == JsonSchemaType.Boolean)
                types[index++] = "boolean";
            if ((type & JsonSchemaType.Object) == JsonSchemaType.Object)
                types[index++] = "object";
            if ((type & JsonSchemaType.Array) == JsonSchemaType.Array)
                types[index++] = "array";
            if ((type & JsonSchemaType.Null) == JsonSchemaType.Null)
                types[index++] = "null";

            if (index == 0)
                return "";
            else if (index == 1)
                return types[0];
            else if (index == 2)
                return types[0] + " or " + types[1];
            else
                return String.Join(", ", types, 0, index - 1) + ", or " + types[index - 1];
        }
开发者ID:hanokhaloni,项目名称:czml-writer,代码行数:28,代码来源:MarkdownGenerator.cs


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