Example #1
0
        /// <summary>
        /// Gets properties that was not created from schema.
        /// </summary>
        /// <param name="parserContext">Source parser context.</param>
        /// <param name="schema">Source schema.</param>
        /// <param name="recursive">Recursive search in children schemas.</param>
        /// <returns>Properties that was not created from schema.</returns>
        public static IEnumerable <IProperty> GetPropertiesNotFromSchema(this IXmlParserContext parserContext, ISchema?schema = null, bool recursive = true)
        {
            // Use root schema.
            schema ??= parserContext.Schema;

            IEnumerable <IProperty> properties = schema.GetProperties();

            foreach (IProperty property in properties)
            {
                if (property.GetIsNotFromSchema())
                {
                    yield return(property);
                }

                if (recursive)
                {
                    if (parserContext.GetSchema(property) is { } subSchema)
                    {
                        foreach (IProperty subProperty in parserContext.GetPropertiesNotFromSchema(subSchema, recursive))
                        {
                            yield return(subProperty);
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Gets properties that was not created from schema for the property.
        /// </summary>
        /// <param name="parserContext">Source parser context.</param>
        /// <param name="property">Property to get schema..</param>
        /// <param name="recursive">Recursive search in children schemas.</param>
        /// <returns>Properties that was not created from schema.</returns>
        public static IEnumerable <IProperty> GetPropertiesNotFromSchema(this IXmlParserContext parserContext, IProperty property, bool recursive = true)
        {
            ISchema?schema = parserContext.GetSchema(property);

            if (schema == null)
            {
                return(Array.Empty <IProperty>());
            }

            return(parserContext.GetPropertiesNotFromSchema(schema, recursive: recursive));
        }