コード例 #1
0
        public CaseModel TestTimeSpan()
        {
            return(new CaseModel()
            {
                NameSign = @"两个时间的差值",
                ExeEvent = () => {
                    DateTime EDT = DateTime.MinValue;
                    DateTime dt1 = ConvertTool.ObjToDateTime(@"2018-08-27 11:57:40.300", EDT);
                    DateTime dt2 = ConvertTool.ObjToDateTime(@"2018-08-27 11:57:40.500", EDT);
                    TimeSpan tS = dt2 - dt1;
                    Print.WriteLine("Days: {0}", tS.Days);
                    Print.WriteLine("Hours: {0}", tS.Hours);
                    Print.WriteLine("Milliseconds: {0}", tS.Milliseconds);
                    Print.WriteLine("Minutes: {0}", tS.Minutes);
                    Print.WriteLine("Seconds: {0}", tS.Seconds);
                    Print.WriteLine("Ticks: {0}", tS.Ticks);
                    Print.WriteLine("TotalDays: {0}", tS.TotalDays);
                    Print.WriteLine("TotalHours: {0}", tS.TotalHours);
                    Print.WriteLine("TotalMilliseconds: {0}", tS.TotalMilliseconds);
                    Print.WriteLine("TotalMinutes: {0}", tS.TotalMinutes);
                    Print.WriteLine("TotalSeconds: {0}", tS.TotalSeconds);

                    /*
                     * 正则解析
                     *
                     * \s+//.*
                     * ^\s+public \w+ (\w+) { get; }
                     * Print.WriteLine("$1: {0}", uri.$1);
                     */
                },
            });
        }
コード例 #2
0
        /// <summary>
        /// 输出转换
        /// </summary>
        public override object InputConvert(object sourceValue, ColumnItemModel colmodel)
        {
            //string name = colmodel.Property.Name;
            //if (name == @"TimeAdd") {
            //    name = name;
            //}
            Type propertytype = colmodel.Property.PropertyType;

            if (propertytype.BaseType.FullName == typeof(Enum).FullName)
            {
                sourceValue = ConvertTool.ObjToInt(sourceValue, 0);
            }

            if (propertytype.FullName == typeof(Int32).FullName)
            {
                sourceValue = ConvertTool.ObjToInt(sourceValue, 0);
            }
            if (propertytype.FullName == typeof(Single).FullName)
            {
                sourceValue = ConvertTool.ObjToFloat(sourceValue, 0);
            }
            if (propertytype.FullName == typeof(Double).FullName)
            {
                sourceValue = ConvertTool.ObjToFloat(sourceValue, 0);
            }
            if (propertytype.FullName == typeof(Boolean).FullName)
            {
                sourceValue = ConvertTool.ObjToBool(sourceValue, false);
            }
            if (propertytype.FullName == typeof(DateTime).FullName)
            {
                sourceValue = ConvertTool.ObjToDateTime(sourceValue, SqlDateTime.MinValue.Value);
            }

            return(sourceValue);
        }