Common/TypeParse.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/**********************************************
* 类作用: 类型转换类
* 建立人: abaal
* 建立时间: 2008-09-03
* Copyright (C) 2007-2008 abaal
* All rights reserved
* http://blog.csdn.net/abaal888
***********************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Svnhost.Common
{
public class TypeParse
{
/// <summary>
/// string型转换为bool型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的bool类型结果</returns>
public static bool StrToBool(object Expression, bool defValue)
{
if (Expression != null)
{
if (string.Compare(Expression.ToString(), "true", true) == 0)
{
return true;
}
else if (string.Compare(Expression.ToString(), "false", true) == 0)
{
return false;
}
}
return defValue;
}
/// <summary>
/// 将对象转换为Int32类型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int StrToInt(object Expression, int defValue)
{
if (Expression != null)
{
string str = Expression.ToString();
if (str.Length > 0 && str.Length <= 11 && Regex.IsMatch(str, @"^[-]?[0-9]*$"))
{
if ((str.Length < 10) || (str.Length == 10 && str[0] == '1') || (str.Length == 11 && str[0] == '-' && str[1] == '1'))
{
return Convert.ToInt32(str);
}
}
}
后面还有 72 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。