public static string GetOutputParameters(Type type) { var builder = new StringBuilder(); foreach (var prop in type.GetProperties()) { bool value = true; object[] attrs = prop.GetCustomAttributes(true); foreach (object attr in attrs) { MapToM3 attribute = attr as MapToM3; if (attribute != null) { value = attribute.Include; break; } } if (value) { builder.Append(prop.Name); if (prop.Name != type.GetProperties().Last().Name) { builder.Append(","); } } } return(builder.ToString()); }
public static string GetInputParameters(object dataObject) { if (dataObject == null) { return(""); } else { var builder = new StringBuilder(); builder.Append("?"); Type type = dataObject.GetType(); foreach (var prop in type.GetProperties()) { bool value = true; object[] attrs = prop.GetCustomAttributes(true); foreach (object attr in attrs) { MapToM3 attribute = attr as MapToM3; if (attribute != null) { value = attribute.Include; break; } } if (value) { var tempValue = prop.GetValue(dataObject, null); if (tempValue != null && tempValue.ToString() != "") { builder.Append(prop.Name + "=" + prop.GetValue(dataObject, null)); if (prop.Name != type.GetProperties().Last().Name) { builder.Append("&"); } } } } return(builder.ToString()); } }