コード例 #1
0
        /// <summary>
        /// Add a single definition to the `$def` keyword.
        /// </summary>
        public static JsonSchema Def(this JsonSchema schema, string name, JsonSchema definition)
        {
            var keyword = schema.OfType <DefsKeyword>().FirstOrDefault();

            if (keyword == null)
            {
                keyword = new DefsKeyword();
                schema.Add(keyword);
            }

            keyword.Add(name, definition);

            return(schema);
        }
コード例 #2
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <returns>true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.</returns>
        /// <param name="other">An object to compare with this object.</param>
        public bool Equals(DefsKeyword other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            var definitionsMatch = this.FullOuterJoin(other,
                                                      tk => tk.Key,
                                                      ok => ok.Key,
                                                      (tk, ok) => new { ThisDefinition = tk.Value, OtherDefinition = ok.Value })
                                   .ToList();

            return(definitionsMatch.All(k => Equals(k.ThisDefinition, k.OtherDefinition)));
        }