コード例 #1
0
 /// <summary>
 /// Gets all immediate subschemas for a keyword.
 /// </summary>
 /// <param name="keyword">The keyword.</param>
 /// <returns>An `IEnumerable&lt;JsonSchema&gt;`.</returns>
 public static IEnumerable <JsonSchema> GetSubschemas(this IJsonSchemaKeyword keyword)
 {
     return(keyword switch
     {
         ISchemaContainer container => new[] { container.Schema },
         ISchemaCollector collector => collector.Schemas,
         IKeyedSchemaCollector collector => collector.Schemas.Values,
         _ => Enumerable.Empty <JsonSchema>()
     });
コード例 #2
0
 /// <summary>
 /// Gets all immediate subschemas for a keyword.
 /// </summary>
 /// <param name="keyword">The keyword.</param>
 /// <returns>An `IEnumerable&lt;JsonSchema&gt;`.</returns>
 public static IEnumerable <JsonSchema> GetSubschemas(this IJsonSchemaKeyword keyword)
 {
     return(keyword switch
     {
         // ReSharper disable once ConditionIsAlwaysTrueOrFalse
         ISchemaContainer container => container.Schema == null?Enumerable.Empty <JsonSchema>() : new[] { container.Schema },
         // ReSharper disable ConstantNullCoalescingCondition
         ISchemaCollector collector => collector.Schemas ?? Enumerable.Empty <JsonSchema>(),
         IKeyedSchemaCollector collector => collector.Schemas.Values ?? Enumerable.Empty <JsonSchema>(),
         // ReSharper restore ConstantNullCoalescingCondition
         _ => Enumerable.Empty <JsonSchema>()
     });