public void Enrich(HtmlConventionsPreviewContext context, HtmlConventionsPreviewViewModel model) { var links = new List <PropertyLink>(); context .NonConvertibleProperties() .Each(prop => { var path = "{0}-{1}".ToFormat(context.Path, prop.Name); var type = prop.PropertyType; if (type.IsInterface || type.IsAbstract || type.IsGenericType || type.GetConstructor(new Type[0]) == null) { path = ""; } links.Add(new PropertyLink { Path = path, Source = _sourceGenerator.SourceFor(prop) }); }); model.Links = links; }
public void Enrich(HtmlConventionsPreviewContext context, HtmlConventionsPreviewViewModel model) { var examples = new List <PropertyExample>(); var tagGenerator = _generatorFactory.GeneratorFor(context.ModelType); tagGenerator.SetModel(context.Instance); _populator.PopulateInstance(context.Instance, context.SimpleProperties()); context .SimpleProperties() .Each(prop => { Accessor property; if (context.PropertyChain.Any()) { property = new PropertyChain(context .PropertyChain .Concat <PropertyInfo>(new[] { prop }) .Select(x => new PropertyValueGetter(x)) .ToArray()); } else { property = new SingleProperty(prop); } var propertyExpression = "x => x." + property.PropertyNames.Join("."); var propertySource = _sourceGenerator.SourceFor(prop); var propExamples = new List <Example>(); propExamples.Add(createExample(tagGenerator.LabelFor(tagGenerator.GetRequest(property)), "LabelFor({0})".ToFormat(propertyExpression))); propExamples.Add(createExample( tagGenerator.DisplayFor(tagGenerator.GetRequest(property)), "DisplayFor({0})".ToFormat(propertyExpression))); propExamples.Add(createExample(tagGenerator.InputFor(tagGenerator.GetRequest(property)), "InputFor({0})".ToFormat(propertyExpression))); var propExample = new PropertyExample { Source = propertySource, Examples = propExamples }; examples.Add(propExample); }); model.Examples = examples; }