コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }