Exemple #1
0
        /// <summary>
        ///     Get a string representing the method.
        /// </summary>
        /// <param name="self">The method instance.</param>
        /// <param name="methodFullName">Indiciates whether to use full name of the method.</param>
        /// <param name="parameterTypesFullName">
        ///     <see langword="null" /> to omit the parameter types; otherwise <see langword="true" /> to use the full name of the
        ///     parameter types or <see langword="false" /> to use simple name of the parameter types.
        /// </param>
        /// <param name="withGenericParameterTypes">
        ///     <see langword="true" /> to append generic parameter types; otherwise, <see langword="false" /> to omit generic
        ///     parameter types.
        /// </param>
        public static string ToString(this MethodBase self, bool methodFullName,
                                      bool?parameterTypesFullName = false, bool withGenericParameterTypes = true)
        {
            Ensure.Argument.NotNull(self, "self");

            var builder = new StringBuilder();

            MethodBaseInternal.ToString(self, builder,
                                        methodFullName, parameterTypesFullName, withGenericParameterTypes);
            return(builder.ToString());
        }
Exemple #2
0
        /// <summary>
        ///     Get a string representing the method.
        /// </summary>
        /// <param name="self">The method instance.</param>
        /// <param name="methodFullName">Indiciates whether to use full name of the method.</param>
        /// <param name="returnTypeFullName">
        ///     <see langword="null" /> to omit the return type; otherwise <see langword="true" /> to use the full name of the
        ///     return type or <see langword="false" /> to use simple name of the return type.
        /// </param>
        /// <param name="parameterTypesFullName">
        ///     <see langword="null" /> to omit the parameter types; otherwise <see langword="true" /> to use the full name of the
        ///     parameter types or <see langword="false" /> to use simple name of the parameter types.
        /// </param>
        /// <param name="withGenericParameterTypes">
        ///     <see langword="true" /> to append generic parameter types; otherwise, <see langword="false" /> to omit generic
        ///     parameter types.
        /// </param>
        public static string ToString(this MethodInfo self, bool methodFullName,
                                      bool?returnTypeFullName        = false, bool?parameterTypesFullName = false,
                                      bool withGenericParameterTypes = true)
        {
            Ensure.Argument.NotNull(self, "self");

            var builder = new StringBuilder();

            if (returnTypeFullName != null)
            {
                var rt = self.ReturnType;
                builder.Append(returnTypeFullName.Value ? rt.FullName : rt.Name).Append(' ');
            }

            MethodBaseInternal.ToString(self, builder,
                                        methodFullName, parameterTypesFullName, withGenericParameterTypes);

            return(builder.ToString());
        }