示例#1
0
 public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
 {
     foreach (var row in rows)
     {
         if (ShouldRun(row))
         {
             var sb = StringBuilders.GetObject();
             for (var i = 0; i < _parameters.Count(); i++)
             {
                 sb.Append(row[_parameters[i].Key] ?? _parameters[i].Value.Value);
             }
             row[OutKey] = sb.ToString();
             sb.Clear();
             StringBuilders.PutObject(sb);
         }
         else
         {
             Skip();
         }
         yield return(row);
     }
 }
示例#2
0
 public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
 {
     foreach (var row in rows)
     {
         if (ShouldRun(row))
         {
             var sb = StringBuilders.GetObject();
             sb.Append('<');
             sb.Append(_tag);
             string content = null;
             foreach (var p in _parameters)
             {
                 var value = (row[p.Key] ?? (p.Value.ValueReferencesField ? row[p.Value.Value] ?? "parameter name conflict!" : p.Value.Value)).ToString();
                 if (_decode)
                 {
                     value = HttpUtility.HtmlDecode(value);
                 }
                 if (p.Value.Name.Equals("content"))
                 {
                     content = value;
                 }
                 else
                 {
                     sb.Append(' ');
                     sb.Append(p.Value.Name);
                     sb.Append("=\"");
                     if (_encode)
                     {
                         XmlEncodeOperation.SanitizeXmlString(HttpUtility.HtmlAttributeEncode(value), ref sb);
                     }
                     else
                     {
                         XmlEncodeOperation.SanitizeXmlString(value, ref sb);
                     }
                     sb.Append('\"');
                 }
             }
             if (content == null)
             {
                 sb.Append(" />");
             }
             else
             {
                 sb.Append('>');
                 if (_encode)
                 {
                     XmlEncodeOperation.SanitizeXmlString(HttpUtility.HtmlEncode(content), ref sb);
                 }
                 else
                 {
                     XmlEncodeOperation.SanitizeXmlString(content, ref sb);
                 }
                 sb.Append("</");
                 sb.Append(_tag);
                 sb.Append(">");
             }
             row[OutKey] = sb.ToString();
             sb.Clear();
             StringBuilders.PutObject(sb);
         }
         else
         {
             Skip();
         }
         yield return(row);
     }
 }