private TypeEntry CreateEntry(DTEValue e) { var entryName = e.Name; //条目名称 if (e.Value == null) { throw new DTOException(string.Format(Strings.DTONotSpecifyType, GetPathName(entryName))); } var valueCode = e.Value.ToString().Trim(); if (valueCode.Length == 0) { throw new DTOException(string.Format(Strings.DTONotSpecifyType, GetPathName(entryName))); } TypeEntry target = null; if (this.Index.TryGet(valueCode, out target)) { //valueCode是已有类型的名称 var entry = target.Clone(); entry.Name = entryName; entry.TypeName = valueCode; entry.Owner = this; return(entry); } else { var temp = valueCode.Split(',').Select((t) => t.Trim()).ToList(); var typeName = temp[0]; //第一项作为类型名 temp.RemoveAt(0); var descriptions = temp; return(new ValueEntry(this, entryName, typeName, e.GetCode(false), descriptions)); } }
private bool IsValueEmpty(DTEValue entity) { if (entity == null) { return(true); } return(IsValueEmpty(entity.Value)); }
public T GetValue <T>(string findExp, T defaultValue) { DTEValue entity = FindEntity <DTEValue>(findExp, false); if (IsValueEmpty(entity)) { return(defaultValue); } return(DataUtil.ToValue <T>(entity.Value)); }
public bool TryGetValue <T>(string findExp, out T value) { DTEValue entity = FindEntity <DTEValue>(findExp, false); if (IsValueEmpty(entity)) { value = default(T); return(false); } value = DataUtil.ToValue <T>(entity.Value); return(true); }