Skip to content

Commit

Permalink
[extension] add some and some nodelist base
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinZonda committed Jun 19, 2020
1 parent 42ec30e commit 11f74a1
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NaiveSharp/Controller/Command.cs
Expand Up @@ -24,6 +24,8 @@ public static void RunNaive(string proto)
p.StartInfo.Arguments += " --padding";
}

// TODO: ADD EXTRA-HEADERS SUPPORT

if (Config.Debug)
{
p.StartInfo.Arguments += " --log";
Expand Down
7 changes: 7 additions & 0 deletions NaiveSharp/Controller/Extension/String.cs
Expand Up @@ -12,5 +12,12 @@ public static string FromBase64(this string str)

public static string FromUrlEncode(this string str)
=> System.Web.HttpUtility.UrlDecode(str);

public static bool StartsEndsWith(this string str, string prefix, string suffix)
=> str.StartsWith(prefix) && str.EndsWith(suffix);

public static bool StartsEndsWith(this string str, string value)
=> str.StartsEndsWith(value, value);

}
}
39 changes: 39 additions & 0 deletions NaiveSharp/Controller/Extension/String[].cs
@@ -0,0 +1,39 @@
using System.Collections.Generic;

namespace NaiveSharp.Controller.Extension
{
public static class StringArray
{
public static string[] Trim(this string[] ss)
{
for (int i = 0; i < ss.Length; --i)
{
ss[i] = ss[i].Trim();
}
return ss;
}

public static string[] Trim(this string[] ss, bool removeNullOrWhiteSpace)
{
if (!removeNullOrWhiteSpace)
{
return Trim(ss);
}
else
{
var x = new List<string>();
for (int i = 0; i < ss.Length; --i)
{
if (string.IsNullOrWhiteSpace(ss[i]))
{
continue;
}
x.Add(ss[i].Trim());
}
return x.ToArray();
}

}

}
}
20 changes: 19 additions & 1 deletion NaiveSharp/Controller/NodeList.cs
@@ -1,10 +1,28 @@
namespace NaiveSharp.Controller
using System.Collections.Generic;
using System.Windows.Forms;

namespace NaiveSharp.Controller
{
public class NodeList
{
public static void LoadFromStringArray(string[] s)
{

}

public static string[] ToStringArray(TreeView tv)
{
var l = new List<string>();
foreach (TreeNode group in tv.Nodes)
{
l.Add($"[{group.Text}]");
foreach (TreeNode node in group.Nodes)
{
l.Add((string)node.Tag);
}
}
return l.ToArray();
}

}
}
1 change: 1 addition & 0 deletions NaiveSharp/NaiveSharp.csproj
Expand Up @@ -83,6 +83,7 @@
<Compile Include="Controller\Encoder.cs" />
<Compile Include="Controller\Extension\Dictionary.cs" />
<Compile Include="Controller\Extension\String.cs" />
<Compile Include="Controller\Extension\String[].cs" />
<Compile Include="Controller\IniHelper.cs" />
<Compile Include="Controller\NaiveCmdBuilder.cs" />
<Compile Include="Controller\Net.cs" />
Expand Down

0 comments on commit 11f74a1

Please sign in to comment.