Exemple #1
0
        public static string GetValue <T>(PropertyInfo info, T data, ValueSelectType valueSelectType)
        {
            if (info.GetValue(data) != null && info.GetValue(data).ToString().Length > 0)
            {
                if (valueSelectType == ValueSelectType.NamesAndValues)
                {
                    return($"{info.Name}='{info.GetValue(data).ToString()}'");
                }
                if (valueSelectType == ValueSelectType.Names)
                {
                    return($"'{info.Name}'");
                }
                if (valueSelectType == ValueSelectType.Values)
                {
                    return($"'{info.GetValue(data).ToString()}'");
                }
                return("");
            }

            return($"{info.Name}=''");
        }
Exemple #2
0
        public static string FormatProperties <T>(PropertyInfo[] props, T data, List <string> excludeStrings = null, ValueSelectType valueSelectType = ValueSelectType.NamesAndValues)
        {
            string returnString = "";

            string[] properties = new string[props.Length];

            for (int i = 0; i < props.Length; i++)
            {
                if (excludeStrings != null)
                {
                    if (excludeStrings.Contains(props[i].Name))
                    {
                        continue;
                    }
                }
                properties[i] = GetValue <T>(props[i], data, valueSelectType);
            }

            returnString += String.Join(",", properties);
            return(returnString);
        }