Beispiel #1
0
        public override string ToString()
        {
            var result = new StringBuilder();

            if (MethodBase is MethodInfo info)
            {
                if (info.ReturnType != typeof(void))
                {
                    result.Append(Stringly.ToTypeName(info.ReturnType)).Append(" ");
                }
                else
                {
                    result.Append("void ");
                }
            }

            result.Append(MethodBase.Name);
            if (MethodBase.IsGenericMethod)
            {
                var generic = ((MethodInfo)MethodBase).GetGenericMethodDefinition();
                result
                .Append("<")
                .Append(string.Join(", ", generic.GetGenericArguments().Select(t => t.Name)))
                .Append(">");
            }

            result
            .Append("(")
            .Append(Arguments.ToString())
            .Append(")");

            return(result.ToString());
        }
Beispiel #2
0
        public override string ToString()
        {
            var result = new StringBuilder();

            if (MethodBase is MethodInfo info)
            {
                if (info.ReturnType != typeof(void))
                {
                    result.Append(Stringly.ToTypeName(info.ReturnType)).Append(" ");
                }
                else
                {
                    result.Append("void ");
                }
            }

            if (MethodBase.IsSpecialName)
            {
                if (MethodBase.Name.StartsWith("get_", StringComparison.Ordinal) ||
                    MethodBase.Name.StartsWith("set_", StringComparison.Ordinal))
                {
                    result.Append(MethodBase.Name.Substring(4));
                }
                else if (MethodBase.Name.StartsWith("add_", StringComparison.Ordinal))
                {
                    result.Append(MethodBase.Name.Substring(4) + " += ");
                }
                else if (MethodBase.Name.StartsWith("remove_", StringComparison.Ordinal))
                {
                    result.Append(MethodBase.Name.Substring(7) + " -= ");
                }
            }
            else
            {
                result.Append(MethodBase.Name);
            }

            if (MethodBase.IsGenericMethod)
            {
                var generic = ((MethodInfo)MethodBase).GetGenericMethodDefinition();
                result
                .Append("<")
                .Append(string.Join(", ", generic.GetGenericArguments().Select(t => t.Name)))
                .Append(">");
            }

            // TODO: render indexer arguments?
            if (!MethodBase.IsSpecialName)
            {
                return(result
                       .Append("(")
                       .Append(Arguments.ToString())
                       .Append(")")
                       .ToString());
            }

            return(result.ToString());
        }
Beispiel #3
0
        public override string ToString()
        {
            var result = new StringBuilder();

            if (setup.MethodBase is MethodInfo info)
            {
                if (info.ReturnType != typeof(void))
                {
                    result.Append(Stringly.ToTypeName(info.ReturnType)).Append(" ");
                }
                else
                {
                    result.Append("void ");
                }
            }

            result.Append(setup.MethodBase.Name);
            if (setup.MethodBase.IsGenericMethod)
            {
                var generic = ((MethodInfo)setup.MethodBase).GetGenericMethodDefinition();
                result
                .Append("<")
                .Append(string.Join(", ", generic.GetGenericArguments().Select(t => t.Name)))
                .Append(">");
            }

            var parameters = setup.MethodBase.GetParameters();

            return(result
                   .Append("(")
                   .Append(string.Join(", ", parameters.Select((p, i) =>
                                                               Stringly.ToTypeName(p.ParameterType) + " " +
                                                               p.Name + " = " +
                                                               matchers[i].ToString()
                                                               )))
                   .Append(")")
                   .ToString());
        }
Beispiel #4
0
 public override string ToString() => "Any<" + Stringly.ToTypeName(ArgumentType) + ">";
Beispiel #5
0
        public override string ToString()
        {
            var result = new StringBuilder();

            if (invocation.MethodBase is MethodInfo info)
            {
                if (info.ReturnType != typeof(void))
                {
                    result.Append(Stringly.ToTypeName(info.ReturnType)).Append(" ");
                }
                else
                {
                    result.Append("void ");
                }
            }

            if (invocation.MethodBase.IsSpecialName)
            {
                if (invocation.MethodBase.Name.StartsWith("get_", StringComparison.Ordinal) ||
                    invocation.MethodBase.Name.StartsWith("set_", StringComparison.Ordinal))
                {
                    result.Append(invocation.MethodBase.Name.Substring(4));
                }
                else if (invocation.MethodBase.Name.StartsWith("add_", StringComparison.Ordinal))
                {
                    result.Append(invocation.MethodBase.Name.Substring(4) + " += ");
                }
                else if (invocation.MethodBase.Name.StartsWith("remove_", StringComparison.Ordinal))
                {
                    result.Append(invocation.MethodBase.Name.Substring(7) + " -= ");
                }
            }
            else
            {
                result.Append(invocation.MethodBase.Name);
            }

            if (invocation.MethodBase.IsGenericMethod)
            {
                var generic = ((MethodInfo)invocation.MethodBase).GetGenericMethodDefinition();
                result
                .Append("<")
                .Append(string.Join(", ", generic.GetGenericArguments().Select(t => t.Name)))
                .Append(">");
            }

            var parameters = invocation.MethodBase.GetParameters();

            // TODO: render indexer arguments?
            if (!invocation.MethodBase.IsSpecialName)
            {
                return(result
                       .Append("(")
                       .Append(string.Join(", ", parameters.Select((p, i) =>
                                                                   (p.IsOut ? "out " : (p.ParameterType.IsByRef ? "ref " : "")) +
                                                                   Stringly.ToTypeName(p.ParameterType) + " " +
                                                                   p.Name +
                                                                   (p.IsOut ? "" : (" = " + matchers[i]))
                                                                   )))
                       .Append(")")
                       .ToString());
            }

            return(result.ToString());
        }