public object Render(ObjectRenderingRequest req)
        {
            IEnumerable obj = req?.RenderTarget as IEnumerable;

            if (obj == null)
            {
                return(req?.RenderTarget);
            }

            var prefix = "";
            var result = new StringBuilder();

            result.Append("[");
            result.Append(ObjectToCode.ToCSharpFriendlyTypeName(obj.GetType()));
            result.Append("]@(");
            foreach (var rec in obj)
            {
                var req2 = req.NewTarget(rec);
                result.Append(prefix);
                result.Append(req2.Render());
                prefix = ",";
            }
            result.Append(")");

            return(new AnnotatedFormattable(result.ToString()));
        }
        public object Render(ObjectRenderingRequest req)
        {
            if (req?.RenderTarget is AnnotatedFormattable)
            {
                return(req?.RenderTarget);
            }

            var target  = req.RenderTarget;
            var members = target.GetType().GetMembers().Where(m => m.MemberType == MemberTypes.Field || m.MemberType == MemberTypes.Property);
            var result  = new StringBuilder();

            result.Append("[");
            result.Append(ObjectToCode.ToCSharpFriendlyTypeName(target.GetType()));
            result.Append("]@{");

            foreach (var member in members)
            {
                result.Append('"');
                result.Append(member.Name);
                result.Append('"');
                result.Append('=');

                var value = Reflection.GetValue(member, target);
                var req2  = req.NewTarget(value);
                result.Append(req2.Render());
                result.Append(';');
            }
            result.Append("}");

            return(new AnnotatedFormattable(result.ToString()));
        }
 public object Render(ObjectRenderingRequest req)
 {
     if (!typeof(Enum).IsAssignableFrom(req.GetType()))
     {
         return(req.RenderTarget);
     }
     return(new AnnotatedFormattable(req.RenderTarget, "G", "[" + ObjectToCode.ToCSharpFriendlyTypeName(req.RenderTarget.GetType()) + "]", null));
 }
 public object Render(ObjectRenderingRequest req)
 {
     if (!(req?.RenderTarget is Exception))
     {
         return(req?.RenderTarget);
     }
     return(new AnnotatedFormattable(req.RenderTarget.ToString(), null, "[" + ObjectToCode.ToCSharpFriendlyTypeName(req.RenderTarget.GetType()) + "]", null));
 }