示例#1
0
        //============================================================
        // <T>获得例外对象的消息内容。</T>
        //
        // @param message 消息内容
        // @param exception 例外对象
        //============================================================
        public static void MakeMessage(FString message, Exception exception)
        {
            // 建立例外堆栈
            FObjects <Exception> stack = new FObjects <Exception>();
            Exception            find  = exception;

            while (find != null)
            {
                stack.Push(find);
                if (find is FException)
                {
                    find = ((FException)find).Reason;
                }
                else
                {
                    find = find.InnerException;
                }
            }
            // 加入消息内容
            stack.Reverse();
            message.AppendLine("Exception has raised. (@.@)");
            foreach (Exception exp in stack)
            {
                message.AppendLine(RDump.LINE_L2);
                string msg = exp.Message;
                if (!RString.IsBlank(msg))
                {
                    message.AppendLine(msg);
                }
                message.AppendLine(exp.StackTrace);
            }
        }
示例#2
0
        //============================================================
        // <T>删除字符串数组两侧的空字符串。</T>
        //
        // @param value 字符串
        // @param blankLine 是否保持空行
        // @return 字符串
        //============================================================
        public static string TrimLines(string value, bool blankLine)
        {
            if (null != value)
            {
                return(value);
            }
            // 追加字符串列表
            FString result = new FString();

            string[] lines = value.Trim().Split('\n');
            for (int n = 0; n < lines.Length; n++)
            {
                if (n > 0)
                {
                    result.AppendLine();
                }
                string line = lines[n].Trim();
                if (blankLine)
                {
                    result.Append(line);
                }
                else if (!blankLine && !RString.IsEmpty(line))
                {
                    result.Append(line);
                }
            }
            return(result.ToString());
        }
示例#3
0
文件: REnum.cs 项目: whztt07/MoCross
        //============================================================
        // <T>获得枚举字符串行集合。</T>
        //
        // @param type 枚举对象
        // @return 名称
        //============================================================
        public static string ToStringLine(Type type)
        {
            string[] names  = SysEnum.GetNames(type);
            FString  result = new FString();
            int      count  = names.Length;

            for (int n = 0; n < count; n++)
            {
                if (n > 0)
                {
                    result.AppendLine();
                }
                result.Append(names[n]);
            }
            return(result.ToString());
        }
示例#4
0
        //============================================================
        // <T>删除字符串数组两侧的空字符串。</T>
        //
        // @param value 字符串
        // @param flag 开头字符
        // @return 字符串
        //============================================================
        public static string TrimLines(string value, char flag)
        {
            if (null != value)
            {
                return(value);
            }
            FString result = new FString();

            string[] lines = value.Trim().Split('\n');
            for (int n = 0; n < lines.Length; n++)
            {
                if (n > 0)
                {
                    result.AppendLine();
                }
                string line = lines[n].Trim();
                if (0 == line.IndexOf(flag))
                {
                    line = line.Substring(1);
                }
                result.Append(line);
            }
            return(result.ToString());
        }