mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-28 00:15:47 +02:00
* Switch to .NET Framework 4.7.2 & C# 8.0, update libraries * Add TweetLib.Core project targeting .NET Standard 2.0 * Enable reference nullability checks for TweetLib.Core * Move a bunch of utility classes into TweetLib.Core & refactor * Partially move TweetDuck plugin & update system to TweetLib.Core * Move some constants and CultureInfo setup to TweetLib.Core * Move some configuration classes to TweetLib.Core * Minor refactoring and warning suppression * Add App to TweetLib.Core * Add IAppErrorHandler w/ implementation * Continue moving config, plugin, and update classes to TweetLib.Core * Fix a few nullability checks * Update installers to check for .NET Framework 4.7.2
38 lines
1006 B
C#
38 lines
1006 B
C#
using System;
|
|
|
|
namespace TweetLib.Core.Data{
|
|
public sealed class InjectedHTML{
|
|
public enum Position{
|
|
Before, After
|
|
}
|
|
|
|
private readonly Position position;
|
|
private readonly string search;
|
|
private readonly string html;
|
|
|
|
public InjectedHTML(Position position, string search, string html){
|
|
this.position = position;
|
|
this.search = search;
|
|
this.html = html;
|
|
}
|
|
|
|
public string InjectInto(string targetHTML){
|
|
int index = targetHTML.IndexOf(search, StringComparison.Ordinal);
|
|
|
|
if (index == -1){
|
|
return targetHTML;
|
|
}
|
|
|
|
int cutIndex;
|
|
|
|
switch(position){
|
|
case Position.Before: cutIndex = index; break;
|
|
case Position.After: cutIndex = index + search.Length; break;
|
|
default: return targetHTML;
|
|
}
|
|
|
|
return targetHTML.Insert(cutIndex, html);
|
|
}
|
|
}
|
|
}
|