private XPathNavigator GetPropertyNode(PropertyDescriptor propertyDescriptor) { string selectExpression = String.Format(CultureInfo.InvariantCulture, PropertyExpression, GetPropertyName(propertyDescriptor.PropertyInfo)); return _documentNavigator.SelectSingleNode(selectExpression); }
private void ScanPropertyDocumentation(PropertyDescriptor propertyDescriptor) { XPathNavigator propertyNode = GetPropertyNode(propertyDescriptor); string documentation = GetTagValue(propertyNode, "summary"); if (propertyDescriptor.Documentation == null && documentation != null) propertyDescriptor.Documentation = documentation; if (propertyDescriptor.Def.IsLeaf) return; if (propertyDescriptor.Def.IsArray && propertyDescriptor.SubType != null && propertyDescriptor.SubType.Def.IsObject) { foreach (PropertyDescriptor sub in propertyDescriptor.SubType.Properties) { ScanPropertyDocumentation(sub); } } else if (propertyDescriptor.Def.IsObject) { foreach (PropertyDescriptor sub in propertyDescriptor.Properties) { ScanPropertyDocumentation(sub); } } }
public void ScanTypeDefinition(HashSet<Type> parentCustomTypes) { _def = Container.GetOrCreate(_type); if (_def.IsObject) { var properties = _type.GetProperties(); _properties = new List<PropertyDescriptor>(properties.Length); _propertiesDic = new Dictionary<string, PropertyDescriptor>(properties.Length, StringComparer.CurrentCultureIgnoreCase); if (_def.IsCustomObject) { if (parentCustomTypes.Contains(_type)) return; parentCustomTypes.Add(_type); } if (!TypeDefinition.IsDictionaryType(_type)) { foreach (var property in properties) { if (property.GetCustomAttributes(typeof(JsonIgnoreAttribute), false).Length > 0) continue; var item = new PropertyDescriptor(property, _depth + 1); item.Container = Container; _properties.Add(item); _propertiesDic.Add(property.Name, item); item.ScanTypeDefinition(new HashSet<Type>(parentCustomTypes)); } } } else if (_def.IsArray && _def.SubType != null) { var subDef = Container.GetOrCreate(_def.SubType); _subType = new TypeDescriptor(_def.SubType.Name, _def.SubType, _depth); _subType.Container = Container; _subType.ScanTypeDefinition(parentCustomTypes); } }