string VisitMemberAccess(MemberExpression m, bool literal) { if (m.Expression == null) { return(m.Member.Name); } else if (m.Expression is ConstantExpression) { object obj = ((ConstantExpression)m.Expression).Value; object value = m.Member is FieldInfo ? ((FieldInfo)m.Member).GetValue(obj) : ((PropertyInfo)m.Member).GetValue(obj, null); if (literal) { return(value == null ? "null" : value.ToString()); } else { return(CSharpRenderer.Value(value, value?.Let(v => v.GetType()), ImportedNamespaces)); } } else { return("{0}.{1}".FormatWith(Visit(m.Expression, m.NodeType), m.Member.Name)); } }
string VisitConstant(ConstantExpression c, bool literal) { if (literal) { return(c.Value.ToString()); } else { return(CSharpRenderer.Value(c.Value, c.Type, ImportedNamespaces)); } }