/// <summary> /// 初始化参数 /// </summary> private void init() { //FieldName convert to lower case DateTimeFields.ForEach(p => p = p.ToLower()); DoubleFields.ForEach(p => p = p.ToLower()); AllFields.ForEach(p => p = p.ToLower()); if (AllFields.Count == 0) { AllFields = this.GetDefaultFields(); } //自动识别 if (TypeDetectable) { foreach (String field in AllFields) { Type type = dt.Columns[field].DataType; if (typeof(DateTime) == type) { DateTimeFields.Add(field); } else if (NPOIUtil.NumberType(type)) { DoubleFields.Add(field); } } } }
public static Uri GenerateTagUri(string authority = null, DateTimeFields dateFields = DateTimeFields.Day, string specific = null) { var date = DateTime.UtcNow.Date; authority = authority ?? "uuid.is4.site"; specific = specific ?? Guid.NewGuid().ToString("D"); var culture = CultureInfo.InvariantCulture; string dateString; switch (dateFields) { case DateTimeFields.Year: dateString = date.ToString("yyyy", culture); break; case DateTimeFields.Month: dateString = date.ToString("yyyy-MM", culture); break; case DateTimeFields.Day: dateString = date.ToString("yyyy-MM-dd", culture); break; default: throw new ArgumentOutOfRangeException(nameof(dateFields)); } return(new Uri($"tag:{authority},{dateString}:{specific}", UriKind.Absolute)); }
private void init() { if (AllFields.Count == 0) { AllFields = GetDefaultFields(); } //自动识别 if (TypeDetectable) { foreach (String field in AllFields) { Type type = typeof(T).GetProperty(field).PropertyType; if (typeof(DateTime) == type || typeof(DateTime?) == type) { DateTimeFields.Add(field); } else if (NPOIUtil.NumberType(type)) { DoubleFields.Add(field); } } } }