public static string CreateItemString(List <String> data, QuoteStyle style) { return(data.Aggregate(new StringBuilder(), (result, item) => { if (result.Length == 0) { return result.Append(style.Convert(item)); } result.Append(LIST_ITEM_SEPARATOR).Append(style.Convert(item)); return result; }).ToString()); }
public void SetParameter(string name, string value, QuoteStyle style) { if (style != QuoteStyle.NONE) { value = style.Convert(value); } items.Add(name, value); //parameterMap[name] = value; }
private string HandleSide(Expression exp, QuoteStyle style, object obj) { if (exp is BinaryExpression) { return(Parse((BinaryExpression)exp, obj)); } try { return(style.Convert(Expression.Lambda(exp).Compile().DynamicInvoke().ToString())); } catch (InvalidOperationException) { PropertyInfo prop = ((MemberExpression)exp).Member as PropertyInfo; if (Attribute.IsDefined(prop, typeof(LookupPropertyAttribute)) && Attribute.IsDefined(prop, typeof(IDColumnAttribute)) && obj != null) { var idData = prop.GetCustomAttribute(typeof(IDColumnAttribute)) as IDColumnAttribute; string propertyName = idData.ColumnName; return(style.Convert((string)obj.GetType().GetProperty(propertyName).GetValue(obj))); } return(style.Convert(prop.Name)); } }
public static string CreateMapString(Dictionary <String, String> data, QuoteStyle keyStyle, QuoteStyle valueStyle) { var mapData = new StringBuilder(); foreach (KeyValuePair <String, String> element in data) { var itemString = keyStyle.Convert(element.Key) + "=" + valueStyle.Convert(element.Value); if (mapData.Length == 0) { mapData.Append(itemString); } else { mapData.Append(LIST_ITEM_SEPARATOR).Append(itemString); } } return(mapData.ToString()); }