private object GetValue(MfPropDef prop, string value, TraceSource log) { value = value ?? String.Empty; switch ((MFDataType)prop.DataType) { case MFDataType.MFDatatypeText: case MFDataType.MFDatatypeMultiLineText: return(value); case MFDataType.MFDatatypeBoolean: return(GetBoolValue(value)); case MFDataType.MFDatatypeDate: return(GetDate(value, log)); case MFDataType.MFDatatypeLookup: case MFDataType.MFDatatypeMultiSelectLookup: var itemId = GetIdFromValueList(prop.ValueList, value, log); if (itemId != null) { return(itemId.Value); } break; case MFDataType.MFDatatypeInteger: case MFDataType.MFDatatypeInteger64: int val; var ok = int.TryParse(value, out val); if (ok) { return(val); } if (log != null) { log.TraceEvent(TraceEventType.Warning, 0, "不是数字:" + value); } break; case MFDataType.MFDatatypeFloating: double dVal; ok = double.TryParse(value, out dVal); if (ok) { return(dVal); } if (log != null) { log.TraceEvent(TraceEventType.Warning, 0, "不是数字:" + value); } break; } if (!String.IsNullOrEmpty(value)) { throw new Exception("未能找到对应的属性值:" + value); } return(null); }
private static MfPropDef GetProp(Vault vault, int def) { if (!PropDict.ContainsKey(def)) { var propDef = vault.PropertyDefOperations.GetPropertyDef(def); if (propDef.AutomaticValueType != MFAutomaticValueType.MFAutomaticValueTypeNone) { return(null); } var mp = new MfPropDef { Def = def, DataType = (int)propDef.DataType, Name = propDef.Name, ValueList = propDef.ValueList }; PropDict.Add(def, mp); } return(PropDict[def]); }
public object GetValue(MfPropDef prop, string value) { return(GetValue(prop, value, null)); }