private static void defaultInsertValue(IEnumerable <XElement> elements, ResponseInsertMode mode, string value) { XElement element = XElement.Parse(value, LoadOptions.PreserveWhitespace); switch (mode) { case ResponseInsertMode.ReplaceWith: insertValueOnElements(elements, e => e.ReplaceWith(addNamespace(e, element))); break; case ResponseInsertMode.InsertBefore: insertValueOnElements(elements, e => e.AddBeforeSelf(addNamespace(e, element))); break; case ResponseInsertMode.InsertAfter: insertValueOnElements(elements, e => e.AddAfterSelf(addNamespace(e, element))); break; case ResponseInsertMode.AppendTo: insertValueOnElements(elements, e => e.Add(addNamespace(e, element))); break; case ResponseInsertMode.PrependTo: insertValueOnElements(elements, e => e.AddFirst(addNamespace(e, element))); break; } }
public ResponseInsert(Func <int, string> getValue, ResponseInsertMode mode, Func <string, IEnumerable <string> > selectorFunction, Func <string, IEnumerable <string>, ResponseInsertMode, Func <int, string>, string> insertValueFunction) { this.getValue = getValue; this.mode = mode; this.selectorFunction = selectorFunction; this.insertValueFunction = insertValueFunction; }
public ResponseInsert(string value, ResponseInsertMode mode, Func <XDocument, IEnumerable <XElement> > selectorFunction, Action <IEnumerable <XElement>, ResponseInsertMode, string> insertValueFunction) { this.value = value; this.mode = mode; this.selectorFunction = selectorFunction; this.insertValueFunction = insertValueFunction; }
private static void insertValue(IEnumerable <XElement> elements, ResponseInsertMode mode, string value) { switch (mode) { case ResponseInsertMode.AppendTo: insertValueOnElements(elements, e => e.Value += value); break; case ResponseInsertMode.PrependTo: insertValueOnElements(elements, e => e.Value = value + e.Value); break; case ResponseInsertMode.ReplaceWith: case ResponseInsertMode.InsertBefore: case ResponseInsertMode.InsertAfter: throw new NotSupportedException(); } }
public ResponseInsert(string value, ResponseInsertMode mode, Func <XDocument, IEnumerable <XElement> > selectorFunction) : this(value, mode, selectorFunction, (e, m, v) => defaultInsertValue(e, m, v)) { }
public ResponseInsert(string value, ResponseInsertMode mode, string selector, Action <IEnumerable <XElement>, ResponseInsertMode, string> insertValueFunction) : this(value, mode, generateSelectorFunction(selector), (e, m, v) => defaultInsertValue(e, m, v)) { }
public ResponseInsert(string value, ResponseInsertMode mode, string selector) : this(value, mode, generateSelectorFunction(selector)) { }
private static string defaultInsertValue(string doc, IEnumerable <string> elements, ResponseInsertMode mode, Func <int, string> getValue) { switch (mode) { case ResponseInsertMode.ReplaceWith: return(insertValueOnElements(doc, elements, (e, i) => replaceWith(getValue(i)))); case ResponseInsertMode.InsertBefore: return(insertValueOnElements(doc, elements, (e, i) => insertBefore(e, getValue(i)))); case ResponseInsertMode.InsertAfter: return(insertValueOnElements(doc, elements, (e, i) => insertAfter(e, getValue(i)))); case ResponseInsertMode.AppendTo: return(insertValueOnElements(doc, elements, (e, i) => appendTo(e, getValue(i)))); case ResponseInsertMode.PrependTo: return(insertValueOnElements(doc, elements, (e, i) => prependTo(e, getValue(i)))); case ResponseInsertMode.Wrap: return(insertValueOnElements(doc, elements, (e, i) => wrap(e, getValue(i)))); case ResponseInsertMode.Remove: return(insertValueOnElements(doc, elements, (e, i) => remove(e))); } return(doc); }
public ResponseInsert(Func <int, string> getValue, ResponseInsertMode mode, Func <string, IEnumerable <string> > selectorFunction) : this(getValue, mode, selectorFunction, defaultInsertValue) { }
public ResponseInsert(Func <int, string> getValue, ResponseInsertMode mode, string selector, Func <string, IEnumerable <string>, ResponseInsertMode, Func <int, string>, string> insertValueFunction) : this(getValue, mode, generateSelectorFunction(selector), insertValueFunction) { }
public ResponseInsert(Func <int, string> getValue, ResponseInsertMode mode, string selector) : this(getValue, mode, generateSelectorFunction(selector)) { }