示例#1
0
 /// <summary>
 /// Get the description corresponding to the given type.
 /// </summary>
 /// <param name="exceptionType">The type of the exception. Cannot be null.</param>
 /// <returns></returns>
 public static ExceptionDescription GetDescription(Type exceptionType)
 {
     if (exceptionType == null)
     {
         throw new ArgumentNullException("exceptionType");
     }
     return(new ExceptionDescription(ExceptionDescription.EXCEPTION_DESCRIPTION_MARKER
                                     + SourceCodePrinting.ToCodeString(exceptionType)));
 }
示例#2
0
        /// <summary>
        /// Casts between various types
        /// </summary>
        /// <param name="mi"></param>
        /// <param name="castOp"></param>
        /// <returns></returns>
        public static bool IsCastOperator(MethodInfo mi, out string castOp)
        {
            bool status = true;

            castOp = "";
            if (mi.Name.Contains("op_Explicit") ||
                mi.Name.Contains("op_Implicit"))
            {
                castOp = "(" + SourceCodePrinting.ToCodeString(mi.ReturnType) + ")";
            }
            else if (mi.Name.Contains("op_True"))
            {
                castOp = "(bool)";
            }
            else if (mi.Name.Contains("op_False"))
            {
                castOp = "(bool)";
            }
            else
            {
                status = false;
            }
            return(status);
        }