コード例 #1
0
        /// <summary>
        /// Finds a property by name in the given
        /// </summary>
        /// <param name="schema">The schema to serve as a starting point</param>
        /// <param name="definition">The service definition that contains all definitions</param>
        /// <param name="propertyName">The name of the property to find</param>
        /// <returns>The schema for the found property or null</returns>
        public static Schema FindPropertyInChain(this Schema schema, ServiceDefinition definition, string propertyName)
        {
            Schema propertyDefinition = null;
            var    resolver           = new SchemaResolver(definition);

            // Try to find the property in this schema or its ancestors
            try
            {
                propertyDefinition = resolver.FindProperty(schema, propertyName);
            }
            catch (InvalidOperationException)
            {
                // There was a problem finding the property (e.g. a circular reference). Return null
            }
            return(propertyDefinition);
        }