public Task Customize(SchemaCustomizerArgs args) { var schemaProp = args.SchemaProperty; if (schemaProp.ExtensionData == null) { schemaProp.ExtensionData = new Dictionary <String, Object>(); } var searchValueProperty = new SearchValueProperty() { Provider = SearchProviderName }; if (CurrentValuePropertyName != null) { var currentValueProp = args.Type.GetProperty(CurrentValuePropertyName); if (currentValueProp == null) { throw new InvalidOperationException($"Cannot find a property on {args.Type.Name} named {CurrentValuePropertyName}. Please fix the SearchValueAttribute on that property."); } searchValueProperty.ValueProperty = args.SchemaGenerator.GetPropertyName(DummyProperty, currentValueProp); //Using dummy property here, the call in the superclass will look at the member info first (v9.9.10) } schemaProp.ExtensionData.Add(DisplayIfName, searchValueProperty); return(Task.FromResult(0)); }
public Task Customize(SchemaCustomizerArgs args) { var schemaProp = args.SchemaProperty; if (schemaProp.ExtensionData == null) { schemaProp.ExtensionData = new Dictionary <String, Object>(); } var expressionFieldInfo = args.TypeProperty.DeclaringType.GetTypeInfo().DeclaredFields.First(i => i.Name == expressionName); var expression = expressionFieldInfo.GetValue(null) as LambdaExpression; schemaProp.ExtensionData.Add(DisplayIfName, new DisplayExpressionNode(expression.Body)); return(Task.FromResult(0)); }