public static string ExtractString(TableRowBuffer node, string nodeName, string defaultVal) { string result = defaultVal; if (node == null || !node.HasFields || node.GetDataByName(nodeName) == null) { return(result); } string nodeText = node.GetDataByName(nodeName); if (!string.IsNullOrEmpty(nodeText)) { result = nodeText; } return(result); }
public static List <T> ExtractNumericList <T>(TableRowBuffer node, string nodeName, T defaultVal, bool isMust) { List <T> result = new List <T>(); if (node == null || !node.HasFields || node.GetDataByName(nodeName) == null) { return(result); } string nodeText = node.GetDataByName(nodeName); if (!string.IsNullOrEmpty(nodeText)) { result = Converter.ConvertNumericList <T>(nodeText); } return(result); }
public static T ExtractNumeric <T>(TableRowBuffer node, string nodeName, T defaultVal) { T result = defaultVal; if (node == null || !node.HasFields || node.GetDataByName(nodeName) == null) { return(result); } string nodeText = node.GetDataByName(nodeName); if (!string.IsNullOrEmpty(nodeText)) { try { result = (T)Convert.ChangeType(nodeText, typeof(T)); } catch (System.Exception ex) { GameLog.Error("ExtractNumeric {0} {1} Exception:{2}/{3}", nodeName, nodeText, ex.Message, ex.StackTrace); throw; } } return(result); }
public static bool ExtractBool(TableRowBuffer node, string nodeName, bool defaultVal) { bool result = defaultVal; if (node == null || !node.HasFields || node.GetDataByName(nodeName) == null) { return(result); } string nodeText = node.GetDataByName(nodeName); if (!string.IsNullOrEmpty(nodeText)) { if (nodeText.Trim().ToLower() == "true" || nodeText.Trim().ToLower() == "1") { result = true; } if (nodeText.Trim().ToLower() == "false" || nodeText.Trim().ToLower() == "0") { result = false; } } return(result); }
public static List <string> ExtractStringList(TableRowBuffer node, string nodeName, string[] defaultVal) { List <string> result = new List <string>(); if (node == null || !node.HasFields) { return(result); } string nodeText = node.GetDataByName(nodeName); if (!string.IsNullOrEmpty(nodeText)) { result = Converter.ConvertStringList(nodeText); } else if (null != defaultVal) { result.AddRange(defaultVal); } return(result); }