Exemple #1
0
        public static string ConvertPrintTemplate(object obj, string row)
        {
            string result = string.Empty;

            string[] tmpArray = null;
            if (row.ToLower().StartsWith("cmd"))
            {
                result = row;
                if (result.IndexOf("|") != -1)
                {
                    tmpArray = result.Substring(4).Trim().Split('|');
                    if (tmpArray.Length > 0)
                    {
                        result = string.Empty;
                        for (int j = 0; j < tmpArray.Length; j++)
                        {
                            result += (char)Convert.ToInt32(tmpArray[j]);
                        }
                    }
                }
            }
            else if (row.ToLower().StartsWith("property"))
            {
                result = row;
                if (result.IndexOf("#") != -1)
                {
                    result   = result.Substring(9);
                    tmpArray = result.Trim().Split('#');
                    if (tmpArray.Length > 0)
                    {
                        result = string.Empty;
                        for (int j = 0; j < tmpArray.Length; j++)
                        {
                            if (j % 2 == 1)
                            {
                                result = result.Replace("#" + tmpArray[j] + "#", ReflectHelper.GetObjectProperty(obj, tmpArray[j]));
                            }
                        }
                    }
                }
            }
            else if (row.ToLower().StartsWith("field"))
            {
                result = row;
                if (result.IndexOf("#") != -1)
                {
                    result   = result.Substring(6);
                    tmpArray = result.Trim().Split('#');

                    if (tmpArray.Length > 0)
                    {
                        //result = string.Empty;
                        for (int j = 0; j < tmpArray.Length; j++)
                        {
                            if (j % 2 == 1)
                            {
                                result = result.Replace("#" + tmpArray[j] + "#", ReflectHelper.GetObjectField(obj, tmpArray[j]));
                            }
                        }
                    }
                }
            }
            else
            {
                result = row;
            }
            return(result);
        }