code/DataType/DataTypeFactory.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace WR_Excel
{
public static class DataTypeFactory
{
private static Dictionary<string, Type> _dict = new Dictionary<string, Type>();
static DataTypeFactory()
{
_dict["int"] = typeof(DataTypeInt);
_dict["int[]"] = typeof(DataTypeInt1d);
_dict["int[][]"] = typeof(DataTypeInt2d);
_dict["int64"] = typeof(DataTypeLong);
_dict["long"] = typeof(DataTypeLong);
_dict["float"] = typeof(DataTypeFloat);
_dict["double"] = typeof(DataTypeDouble);
_dict["str"] = typeof(DatafieldType);
_dict["string"] = typeof(DatafieldType);
_dict["string[]"] = typeof(DataTypeString1d);
_dict["str[]"] = typeof(DataTypeString1d);
_dict["str[|]"] = typeof(DataTypeString1d);
_dict["item"] = typeof(DataTypeItem);
_dict["item[]"] = typeof(DataTypeItem1d);
_dict["item[][]"] = typeof(DataTypeItem2d);
_dict["attr"] = typeof(DataTypeAttr);
_dict["attr[]"] = typeof(DataTypeAttr1d);
_dict["attr[][]"] = typeof(DataTypeAttr2d);
}
public static DataType CreateDataType(string desp, string name, string fieldType, int col)
{
DataType dataType = null;
string type = fieldType.ToLower();
if (_dict.ContainsKey(type))
{
var dt = Activator.CreateInstance(_dict[type], desp, name, type, col);
dataType = dt as DataType;
}
else
{
if (type.StartsWith("int"))
{
//int[,]
if (Regex.IsMatch(type, @"int\[\W?\]"))
{
dataType = new DataTypeInt1d(desp, name, type, col);
}
//int[,;],int[,][;]
else if (Regex.IsMatch(type, @"int\[\W{2}\]") ||
后面还有 52 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
