/// <summary> /// 将整型变量转化为布尔变量(True或False). /// 规则:如果整型数值大于0,返回True,否则返回False. /// </summary> /// <param name="intParam">The int param.</param> /// <param name="mode">严格模式:只能转换0或1;宽松模式:大于0,返回True,否则返回False.</param> /// <returns></returns> public static bool IntToBoolean(int intParam, ConvertMode mode) { switch (mode) { case ConvertMode.Strict: { switch (intParam) { case 0: return(false); case 1: return(true); } throw new ArgumentOutOfRangeException(string.Format(ArgumentValidationString.ValueMustIs0or1, "intParam")); } case ConvertMode.Relaxed: return(IntToBoolean(intParam)); default: Debug.Fail(mode.ToString()); return(false); } }
private static string GetTempFile(ConvertMode type) { string extension = type.ToString().ToLower(); return(GetTempFile(extension)); }