Here are the examples of the csharp api System.Collections.Generic.List.Add(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
24573 Examples
19
View Source File : UiHelper.Textures.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t
public static replacedet_PartList LoadLayout(Dictionary<string, PartStruct[]> layout) {
var ret = new replacedet_PartList();
var partCount = 0;
List<string> paths = new();
foreach (var entry in layout) {
paths.Add(entry.Key);
partCount += entry.Value.Length;
}
ret.replacedetCount = (uint)paths.Count;
ret.replacedet = Createreplacedets(paths);
ret.PartsList = CreatePartsList((uint)partCount);
var partIdx = 0;
var replacedetIdx = 0;
foreach (var entry in layout) {
foreach (var part in entry.Value) {
UpdatePart(ret.PartsList, partIdx, ret.replacedet, replacedetIdx, part.U, part.V, part.Width, part.Height);
partIdx++;
}
replacedetIdx++;
}
return ret;
}
19
View Source File : Ribbon.cs
License : GNU General Public License v3.0
Project Creator : 0dteam
License : GNU General Public License v3.0
Project Creator : 0dteam
public String GetURLsAndAttachmentsInfo(MailItem mailItem)
{
string urls_and_attachments = "---------- URLs and Attachments ----------";
var domainsInEmail = new List<string>();
var emailHTML = mailItem.HTMLBody;
var doc = new HtmlAgilityPack.HtmlDoreplacedent();
doc.LoadHtml(emailHTML);
// extracting all links
var urlsText = "";
var urlNodes = doc.DoreplacedentNode.SelectNodes("//a[@href]");
if(urlNodes != null)
{
urlsText = "\n\n # of URLs: " + doc.DoreplacedentNode.SelectNodes("//a[@href]").Count;
foreach (HtmlNode link in doc.DoreplacedentNode.SelectNodes("//a[@href]"))
{
HtmlAttribute att = link.Attributes["href"];
if (att.Value.Contains("a"))
{
urlsText += "\n --> URL: " + att.Value.Replace(":", "[:]");
// Domain Extraction
try
{
domainsInEmail.Add(new Uri(att.Value).Host);
}
catch (UriFormatException)
{
// Try to process URL as email address. Example -> <a href="mailto:[email protected]">...etc
String emailAtChar = "@";
int ix = att.Value.IndexOf(emailAtChar);
if (ix != -1)
{
string emailDomain = att.Value.Substring(ix + emailAtChar.Length);
try
{
domainsInEmail.Add(new Uri(emailDomain).Host);
}
catch (UriFormatException)
{
// if it fails again, ignore domain extraction
Console.WriteLine("Bad url: {0}", emailDomain);
}
}
}
}
}
}
else
urlsText = "\n\n # of URLs: 0";
// Get domains
domainsInEmail = domainsInEmail.Distinct().ToList();
urls_and_attachments += "\n # of unique Domains: " + domainsInEmail.Count;
foreach (string item in domainsInEmail)
{
urls_and_attachments += "\n --> Domain: " + item.Replace(":", "[:]");
}
// Add Urls
urls_and_attachments += urlsText;
urls_and_attachments += "\n\n # of Attachments: " + mailItem.Attachments.Count;
foreach (Attachment a in mailItem.Attachments)
{
// Save attachment as txt file temporarily to get its hashes (saves under User's Temp folder)
var filePath = Environment.ExpandEnvironmentVariables(@"%TEMP%\Outlook-Phishaddin-" + a.DisplayName + ".txt");
a.SaveAsFile(filePath);
string fileHash_md5 = "";
string fileHash_sha256 = "";
if (File.Exists(filePath))
{
fileHash_md5 = CalculateMD5(filePath);
fileHash_sha256 = GetHashSha256(filePath);
// Delete file after getting the hashes
File.Delete(filePath);
}
urls_and_attachments += "\n --> Attachment: " + a.FileName + " (" + a.Size + " bytes)\n\t\tMD5: " + fileHash_md5 + "\n\t\tSha256: " + fileHash_sha256 + "\n";
}
return urls_and_attachments;
}
19
View Source File : StringMap.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public void Cleanup() {
lock (Pending) {
foreach (KeyValuePair<string, int> entry in Counting) {
int score = entry.Value - DemotionScore;
if (score <= 0) {
CountingUpdateKeys.Add(entry.Key);
CountingUpdateValues.Add(0);
} else if (score >= PromotionTreshold) {
CountingUpdateKeys.Add(entry.Key);
CountingUpdateValues.Add(0);
Pending.Add(entry.Key);
} else {
CountingUpdateKeys.Add(entry.Key);
CountingUpdateValues.Add(score);
}
}
for (int i = 0; i < CountingUpdateKeys.Count; i++) {
string key = CountingUpdateKeys[i];
int value = CountingUpdateValues[i];
if (value == 0)
Counting.Remove(key);
else
Counting[key] = value;
}
CountingUpdateKeys.Clear();
CountingUpdateValues.Clear();
}
}
19
View Source File : patch_Program.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
[STAThread]
public static void Main(string[] args) {
bool nothreading = true;
bool nomods = true;
Queue<string> argq = new Queue<string>(args);
while (argq.Count > 0) {
string arg = argq.Dequeue();
if (arg == "-debug")
Debugger.Launch();
else if (arg == "-yesthreading")
nothreading = false;
else if (arg == "-yesmods")
nomods = false;
}
List<string> argl = new List<string>(args);
argl.Add("<");
if (nothreading)
argl.Add("-nothreading");
if (nomods)
argl.Add("-nomods");
argl.Add(">");
args = argl.ToArray();
// Parse arguments again...
argq = new Queue<string>(args);
while (argq.Count > 0) {
string arg = argq.Dequeue();
if (arg == "-nomods")
// MonoMain.moddingEnabled = false skips ManagedContent.InitializeMods.
// InitializeMods calls ModLoader.LoadMods.
// LoadMods sets ModLoader.modHash.
// -nomods thus leaves ModLoader.modHash == null, which causes issues.
patch_ModLoader.DefaultModHash();
}
orig_Main(args);
}
19
View Source File : SqliteUserData.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public List<string> GetAllTables() {
using MiniCommand mini = new(this) {
SqliteOpenMode.ReadOnly,
@"
SELECT name
FROM sqlite_master
WHERE type = 'table';
",
};
(SqliteConnection con, SqliteCommand cmd, SqliteDataReader reader) = mini.Read();
List<string> names = new();
while (reader.Read())
names.Add(reader.GetString(0));
return names;
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
static void Repack(string input, string[] extras, string output, string name = null) {
Console.Error.WriteLine($"Repacking: {input} -> {output}");
if (name == null)
name = Path.GetFileName(output);
string outputTmp = Path.Combine(Path.GetDirectoryName(output), name);
if (File.Exists(outputTmp))
File.Delete(outputTmp);
List<string> args = new List<string>();
args.Add($"/out:{outputTmp}");
args.Add(input);
foreach (string dep in extras)
if (!string.IsNullOrWhiteSpace(dep))
args.Add(dep.Trim());
RepackOptions options = new RepackOptions(args);
ILRepack repack = new ILRepack(options);
repack.Repack();
if (output != outputTmp) {
if (File.Exists(output))
File.Delete(output);
File.Move(outputTmp, output);
}
}
19
View Source File : XnaToFnaUtil.cs
License : zlib License
Project Creator : 0x0ade
License : zlib License
Project Creator : 0x0ade
public void ScanPath(string path) {
if (Directory.Exists(path)) {
// Use the directory as "dependency directory" and scan in it.
if (Directories.Contains(path))
// No need to scan the dir if the dir is scanned...
return;
RestoreBackup(path);
Log($"[ScanPath] Scanning directory {path}");
Directories.Add(path);
replacedemblyResolver.AddSearchDirectory(path); // Needs to be added manually as DependencyDirs was already added
// Most probably the actual game directory - let's just copy XnaToFna.exe to there to be referenced properly.
string xtfPath = Path.Combine(path, Path.GetFileName(Thisreplacedembly.Location));
if (Path.GetDirectoryName(Thisreplacedembly.Location) != path) {
Log($"[ScanPath] Found separate game directory - copying XnaToFna.exe and FNA.dll");
File.Copy(Thisreplacedembly.Location, xtfPath, true);
string dbExt = null;
if (File.Exists(Path.ChangeExtension(Thisreplacedembly.Location, "pdb")))
dbExt = "pdb";
if (File.Exists(Path.ChangeExtension(Thisreplacedembly.Location, "mdb")))
dbExt = "mdb";
if (dbExt != null)
File.Copy(Path.ChangeExtension(Thisreplacedembly.Location, dbExt), Path.ChangeExtension(xtfPath, dbExt), true);
if (File.Exists(Path.Combine(Path.GetDirectoryName(Thisreplacedembly.Location), "FNA.dll")))
File.Copy(Path.Combine(Path.GetDirectoryName(Thisreplacedembly.Location), "FNA.dll"), Path.Combine(path, "FNA.dll"), true);
else if (File.Exists(Path.Combine(Path.GetDirectoryName(Thisreplacedembly.Location), "FNA.dll.tmp")))
File.Copy(Path.Combine(Path.GetDirectoryName(Thisreplacedembly.Location), "FNA.dll.tmp"), Path.Combine(path, "FNA.dll"), true);
}
ScanPaths(Directory.GetFiles(path));
return;
}
if (File.Exists(path + ".xex")) {
if (!ExtractedXEX.Contains(path)) {
// Remove the original file - let XnaToFna unpack and handle it later.
File.Delete(path);
} else {
// XnaToFna will handle the .xex instead.
}
return;
}
if (path.EndsWith(".xex")) {
string pathTarget = path.Substring(0, path.Length - 4);
if (string.IsNullOrEmpty(Path.GetExtension(pathTarget)))
return;
using (Stream streamXEX = File.OpenRead(path))
using (BinaryReader reader = new BinaryReader(streamXEX))
using (Stream streamRAW = File.OpenWrite(pathTarget)) {
XEXImageData data = new XEXImageData(reader);
int offset = 0;
int size = data.m_memorySize;
// Check if this file is a PE containing an embedded PE.
if (data.m_memorySize > 0x10000) { // One default segment alignment.
using (MemoryStream streamMEM = new MemoryStream(data.m_memoryData))
using (BinaryReader mem = new BinaryReader(streamMEM)) {
if (mem.ReadUInt32() != 0x00905A4D) // MZ
goto WriteRaw;
// This is horrible.
streamMEM.Seek(0x00000280, SeekOrigin.Begin);
if (mem.ReadUInt64() != 0x000061746164692E) // ".idata\0\0"
goto WriteRaw;
streamMEM.Seek(0x00000288, SeekOrigin.Begin);
mem.ReadInt32(); // Virtual size; It's somewhat incorrect?
offset = mem.ReadInt32(); // Virtual offset.
// mem.ReadInt32(); // Raw size; Still incorrect.
// Let's just write everything...
size = data.m_memorySize - offset;
}
}
WriteRaw:
streamRAW.Write(data.m_memoryData, offset, size);
}
path = pathTarget;
ExtractedXEX.Add(pathTarget);
} else if (!path.EndsWith(".dll") && !path.EndsWith(".exe"))
return;
// Check if .dll is CLR replacedembly
replacedemblyName name;
try {
name = replacedemblyName.GetreplacedemblyName(path);
} catch {
return;
}
ReaderParameters modReaderParams = Modder.GenReaderParameters(false);
// Don't ReadWrite if the module being read is XnaToFna or a relink target.
bool isReadWrite =
#if !CECIL0_9
modReaderParams.ReadWrite =
#endif
path != Thisreplacedembly.Location &&
!Mappings.Exists(mappings => name.Name == mappings.Target);
// Only read debug info if it exists
if (!File.Exists(path + ".mdb") && !File.Exists(Path.ChangeExtension(path, "pdb")))
modReaderParams.ReadSymbols = false;
Log($"[ScanPath] Checking replacedembly {name.Name} ({(isReadWrite ? "rw" : "r-")})");
ModuleDefinition mod;
try {
mod = MonoModExt.ReadModule(path, modReaderParams);
} catch (Exception e) {
Log($"[ScanPath] WARNING: Cannot load replacedembly: {e}");
return;
}
bool add = !isReadWrite || name.Name == ThisreplacedemblyName;
if ((mod.Attributes & ModuleAttributes.ILOnly) != ModuleAttributes.ILOnly) {
// Mono.Cecil can't handle mixed mode replacedemblies.
Log($"[ScanPath] WARNING: Cannot handle mixed mode replacedembly {name.Name}");
if (MixedDeps == MixedDepAction.Stub) {
ModulesToStub.Add(mod);
add = true;
} else {
if (MixedDeps == MixedDepAction.Remove) {
RemoveDeps.Add(name.Name);
}
#if !CECIL0_9
mod.Dispose();
#endif
return;
}
}
if (add && !isReadWrite) { // XNA replacement
foreach (XnaToFnaMapping mapping in Mappings)
if (name.Name == mapping.Target) {
mapping.IsActive = true;
mapping.Module = mod;
foreach (string from in mapping.Sources) {
Log($"[ScanPath] Mapping {from} -> {name.Name}");
Modder.RelinkModuleMap[from] = mod;
}
}
} else if (!add) {
foreach (XnaToFnaMapping mapping in Mappings)
if (mod.replacedemblyReferences.Any(dep => mapping.Sources.Contains(dep.Name))) {
add = true;
Log($"[ScanPath] XnaToFna-ing {name.Name}");
goto BreakMappings;
}
}
BreakMappings:
if (add) {
Modules.Add(mod);
ModulePaths[mod] = path;
} else {
#if !CECIL0_9
mod.Dispose();
#endif
}
}
19
View Source File : ReaderTest.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
[Test]
public static async Task Main()
{
int[] ids = { 1, 2, 3 };
Configuration[] configurations =
{
new Configuration(100, "Congratulations, {0}! You won {1}$!", "{0} {1}"),
new Configuration(100, "¡Felicidades, {0}! Ganaste {1} $", "{0}"),
};
var expected = new[]
{
"Congratulations, John Smith! You won 110$!",
"Congratulations, Mary Louie! You won 30$!",
"Congratulations, Louis Slaughter! You won 47$!",
"¡Felicidades, John! Ganaste 110 $",
"¡Felicidades, Mary! Ganaste 30 $",
"¡Felicidades, Louis! Ganaste 47 $"
};
var actual = new List<string>();
foreach (var configuration in configurations)
{
foreach (var userId in ids)
{
//The logic receives only a single explicit parameter - userId
var logic = GetGreeting(userId);
//The rest of parameters (database Id, templates) can be preplaceded implicitly
var greeting = await logic.Apply(configuration);
actual.Add(greeting);
}
}
Collectionreplacedert.AreEqual(expected, actual);
}
19
View Source File : TestFileSystem.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public void AddFile(string path, string content)
{
var dir = Path.GetDirectoryName(path) ?? string.Empty;
if (!this._directories.TryGetValue(dir, out var list))
{
list = new List<string>();
this._directories.Add(dir, list);
}
list.Add(path);
if(!this._files.TryAdd(path, content))
{
throw new Exception("File already exists: " + path);
}
}
19
View Source File : XMLParser.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
public static string[] FindByTag(string NodeName, XmlDoreplacedent doreplacedent)
{
XmlNodeList tags = doreplacedent.GetElementsByTagName(@NodeName);
// Check if nodes were found
if (tags.Count < 1)
{
// Return null if not found
return null;
}
else
{
List<string> l = new List<string>();
//Go though each found node and add it to the list
foreach(XmlNode n in tags)
{
l.Add(n.InnerText);
}
//Convert it to array, clear the list and return
string[] f = l.ToArray();
l.Clear();
return f;
}
}
19
View Source File : OutputStringArray.cs
License : GNU Lesser General Public License v3.0
Project Creator : 0xC0000054
License : GNU Lesser General Public License v3.0
Project Creator : 0xC0000054
public unsafe ReadOnlyCollection<string> ToReadOnlyCollection()
{
var items = new List<string>();
if (this.arrayPointer != IntPtr.Zero)
{
var stringMemoryAdddress = (IntPtr*)this.arrayPointer;
while (*stringMemoryAdddress != IntPtr.Zero)
{
items.Add(Marshal.PtrToStringAnsi(*stringMemoryAdddress));
stringMemoryAdddress++;
}
}
return items.AsReadOnly();
}
19
View Source File : GmicPipeServer.cs
License : GNU General Public License v3.0
Project Creator : 0xC0000054
License : GNU General Public License v3.0
Project Creator : 0xC0000054
private static List<string> DecodeMessageBuffer(byte[] bytes)
{
const byte Separator = (byte)'\n';
int startOffset = 0;
int count = 0;
List<string> messageParameters = new List<string>();
if (bytes[bytes.Length - 1] == Separator)
{
// A message with multiple values uses \n as the separator and terminator.
for (int i = 0; i < bytes.Length; i++)
{
if (bytes[i] == Separator)
{
// Empty strings are skipped.
if (count > 0)
{
messageParameters.Add(Encoding.UTF8.GetString(bytes, startOffset, count));
}
startOffset = i + 1;
count = 0;
}
else
{
count++;
}
}
}
else
{
messageParameters.Add(Encoding.UTF8.GetString(bytes));
}
return messageParameters;
}
19
View Source File : Chromium.cs
License : GNU General Public License v3.0
Project Creator : 0xfd3
License : GNU General Public License v3.0
Project Creator : 0xfd3
private static List<string> GetAllProfiles(string DirectoryPath)
{
List<string> loginDataFiles = new List<string>
{
DirectoryPath + @"\Default\Login Data",
DirectoryPath + @"\Login Data"
};
if (Directory.Exists(DirectoryPath))
{
foreach (string dir in Directory.GetDirectories(DirectoryPath))
{
if (dir.Contains("Profile"))
loginDataFiles.Add(dir + @"\Login Data");
}
}
return loginDataFiles;
}
19
View Source File : IsoHeaderParser.cs
License : MIT License
Project Creator : 13xforever
License : MIT License
Project Creator : 13xforever
public static (List<FileRecord> files, List<string> dirs) GetFilesystemStructure(this CDReader reader)
{
var fsObjects = reader.GetFileSystemEntries(reader.Root.FullName).ToList();
var nextLevel = new List<string>();
var filePaths = new List<string>();
var dirPaths = new List<string>();
while (fsObjects.Any())
{
foreach (var path in fsObjects)
{
if (reader.FileExists(path))
filePaths.Add(path);
else if (reader.DirectoryExists(path))
{
dirPaths.Add(path);
nextLevel.AddRange(reader.GetFileSystemEntries(path));
}
else
Log.Warn($"Unknown filesystem object: {path}");
}
(fsObjects, nextLevel) = (nextLevel, fsObjects);
nextLevel.Clear();
}
var filenames = filePaths.Distinct().Select(n => n.TrimStart('\\')).ToList();
var dirnames = dirPaths.Distinct().Select(n => n.TrimStart('\\')).OrderByDescending(n => n.Length).ToList();
var deepestDirnames = new List<string>();
foreach (var dirname in dirnames)
{
var tmp = dirname + "\\";
if (deepestDirnames.Any(n => n.StartsWith(tmp)))
continue;
deepestDirnames.Add(dirname);
}
dirnames = deepestDirnames.OrderBy(n => n).ToList();
var dirnamesWithFiles = filenames.Select(Path.GetDirectoryName).Distinct().ToList();
var emptydirs = dirnames.Except(dirnamesWithFiles).ToList();
var fileList = new List<FileRecord>();
foreach (var filename in filenames)
{
var clusterRange = reader.PathToClusters(filename);
if (clusterRange.Length != 1)
Log.Warn($"{filename} is split in {clusterRange.Length} ranges");
if (filename.EndsWith("."))
Log.Warn($"Fixing potential mastering error in {filename}");
fileList.Add(new FileRecord(filename.TrimEnd('.'), clusterRange.Min(r => r.Offset), reader.GetFileLength(filename)));
}
fileList = fileList.OrderBy(r => r.StartSector).ToList();
return (files: fileList, dirs: emptydirs);
}
19
View Source File : ProxyGenerator.cs
License : MIT License
Project Creator : 1100100
License : MIT License
Project Creator : 1100100
private static void FindNamespace(Type type, List<string> namespaces)
{
if (type.Namespace == "System.Threading.Tasks" && !type.IsGenericType || type.Namespace == "System" || type.Namespace == "System.Collections.Generic")
return;
namespaces.Add(type.Namespace);
if (!type.IsGenericType) return;
foreach (var item in type.GetGenericArguments())
{
FindNamespace(item, namespaces);
}
}
19
View Source File : IsoHeaderParser.cs
License : MIT License
Project Creator : 13xforever
License : MIT License
Project Creator : 13xforever
public static (List<FileRecord> files, List<string> dirs) GetFilesystemStructure(this CDReader reader)
{
var fsObjects = reader.GetFileSystemEntries(reader.Root.FullName).ToList();
var nextLevel = new List<string>();
var filePaths = new List<string>();
var dirPaths = new List<string>();
while (fsObjects.Any())
{
foreach (var path in fsObjects)
{
if (reader.FileExists(path))
filePaths.Add(path);
else if (reader.DirectoryExists(path))
{
dirPaths.Add(path);
nextLevel.AddRange(reader.GetFileSystemEntries(path));
}
else
Log.Warn($"Unknown filesystem object: {path}");
}
(fsObjects, nextLevel) = (nextLevel, fsObjects);
nextLevel.Clear();
}
var filenames = filePaths.Distinct().Select(n => n.TrimStart('\\')).ToList();
var dirnames = dirPaths.Distinct().Select(n => n.TrimStart('\\')).OrderByDescending(n => n.Length).ToList();
var deepestDirnames = new List<string>();
foreach (var dirname in dirnames)
{
var tmp = dirname + "\\";
if (deepestDirnames.Any(n => n.StartsWith(tmp)))
continue;
deepestDirnames.Add(dirname);
}
dirnames = deepestDirnames.OrderBy(n => n).ToList();
var dirnamesWithFiles = filenames.Select(Path.GetDirectoryName).Distinct().ToList();
var emptydirs = dirnames.Except(dirnamesWithFiles).ToList();
var fileList = new List<FileRecord>();
foreach (var filename in filenames)
{
var clusterRange = reader.PathToClusters(filename);
if (clusterRange.Length != 1)
Log.Warn($"{filename} is split in {clusterRange.Length} ranges");
if (filename.EndsWith("."))
Log.Warn($"Fixing potential mastering error in {filename}");
fileList.Add(new FileRecord(filename.TrimEnd('.'), clusterRange.Min(r => r.Offset), reader.GetFileLength(filename)));
}
fileList = fileList.OrderBy(r => r.StartSector).ToList();
return (files: fileList, dirs: emptydirs);
}
19
View Source File : Dumper.cs
License : MIT License
Project Creator : 13xforever
License : MIT License
Project Creator : 13xforever
public void DetectDisc(string inDir = "", Func<Dumper, string> outputDirFormatter = null)
{
outputDirFormatter ??= d => $"[{d.ProductCode}] {d.replacedle}";
string discSfbPath = null;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var drives = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.CDRom && d.IsReady);
if (string.IsNullOrEmpty(inDir))
{
foreach (var drive in drives)
{
discSfbPath = Path.Combine(drive.Name, "PS3_DISC.SFB");
if (!File.Exists(discSfbPath))
continue;
input = drive.Name;
Drive = drive.Name[0];
break;
}
}
else
{
discSfbPath = Path.Combine(inDir, "PS3_DISC.SFB");
if (File.Exists(discSfbPath))
{
input = Path.GetPathRoot(discSfbPath);
Drive = discSfbPath[0];
}
}
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
if (string.IsNullOrEmpty(inDir))
inDir = "/media";
discSfbPath = IOEx.GetFilepaths(inDir, "PS3_DISC.SFB", 2).FirstOrDefault();
if (!string.IsNullOrEmpty(discSfbPath))
input = Path.GetDirectoryName(discSfbPath);
}
else
throw new NotImplementedException("Current OS is not supported");
if (string.IsNullOrEmpty(input) || string.IsNullOrEmpty(discSfbPath))
throw new DriveNotFoundException("No valid PS3 disc was detected. Disc must be detected and mounted.");
Log.Info("Selected disc: " + input);
discSfbData = File.ReadAllBytes(discSfbPath);
var replacedleId = CheckDiscSfb(discSfbData);
var paramSfoPath = Path.Combine(input, "PS3_GAME", "PARAM.SFO");
if (!File.Exists(paramSfoPath))
throw new InvalidOperationException($"Specified folder is not a valid PS3 disc root (param.sfo is missing): {input}");
using (var stream = File.Open(paramSfoPath, FileMode.Open, FileAccess.Read, FileShare.Read))
ParamSfo = ParamSfo.ReadFrom(stream);
CheckParamSfo(ParamSfo);
if (replacedleId != ProductCode)
Log.Warn($"Product codes in ps3_disc.sfb ({replacedleId}) and in param.sfo ({ProductCode}) do not match");
// todo: maybe use discutils instead to read TOC as one block
var files = IOEx.GetFilepaths(input, "*", SearchOption.AllDirectories);
DiscFilenames = new List<string>();
var totalFilesize = 0L;
var rootLength = input.Length;
foreach (var f in files)
{
try { totalFilesize += new FileInfo(f).Length; } catch { }
DiscFilenames.Add(f.Substring(rootLength));
}
TotalFileSize = totalFilesize;
TotalFileCount = DiscFilenames.Count;
OutputDir = new string(outputDirFormatter(this).ToCharArray().Where(c => !InvalidChars.Contains(c)).ToArray());
Log.Debug($"Output: {OutputDir}");
}
19
View Source File : Dumper.cs
License : MIT License
Project Creator : 13xforever
License : MIT License
Project Creator : 13xforever
private List<string> EnumeratePhysicalDrivesWindows()
{
var physicalDrives = new List<string>();
#if !NATIVE
try
{
using var mgmtObjSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
var drives = mgmtObjSearcher.Get();
foreach (var drive in drives)
{
var tag = drive.Properties["Tag"].Value as string;
if (tag?.IndexOf("CDROM", StringComparison.InvariantCultureIgnoreCase) > -1)
physicalDrives.Add(tag);
}
}
catch (Exception e)
{
Log.Error(e, "Failed to enumerate physical media drives using WMI");
for (var i = 0; i < 32; i++)
physicalDrives.Add([email protected]"\\.\CDROM{i}");
}
#else
for (var i = 0; i < 32; i++)
physicalDrives.Add([email protected]"\\.\CDROM{i}");
#endif
return physicalDrives;
}
19
View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH
License : MIT License
Project Creator : 17MKH
private static void ResolveInForGeneric(StringBuilder sqlBuilder, string columnName, Expression exp, Type valueType, bool notContainer = false)
{
var value = ResolveDynamicInvoke(exp);
var isValueType = false;
var list = new List<string>();
if (valueType.IsEnum)
{
isValueType = true;
var valueList = (IEnumerable)value;
if (valueList != null)
{
foreach (var c in valueList)
{
list.Add(Enum.Parse(valueType, c.ToString()!).ToInt().ToString());
}
}
}
else
{
var typeName = valueType.Name;
switch (typeName)
{
case "Guid":
if (value is IEnumerable<Guid> guidValues)
{
foreach (var c in guidValues)
{
list.Add(c.ToString());
}
}
break;
case "DateTime":
if (value is IEnumerable<DateTime> dateTimeValues)
{
foreach (var c in dateTimeValues)
{
list.Add(c.ToString("yyyy-MM-dd HH:mm:ss"));
}
}
break;
case "Byte":
isValueType = true;
if (value is IEnumerable<byte> byteValues)
{
foreach (var c in byteValues)
{
list.Add(c.ToString(CultureInfo.InvariantCulture));
}
}
break;
case "Char":
if (value is IEnumerable<char> charValues)
{
foreach (var c in charValues)
{
list.Add(c.ToString());
}
}
break;
case "Int16":
isValueType = true;
if (value is IEnumerable<short> shortValues)
{
foreach (var c in shortValues)
{
list.Add(c.ToString());
}
}
break;
case "Int32":
isValueType = true;
if (value is IEnumerable<int> intValues)
{
foreach (var c in intValues)
{
list.Add(c.ToString());
}
}
break;
case "Int64":
isValueType = true;
if (value is IEnumerable<long> longValues)
{
foreach (var c in longValues)
{
list.Add(c.ToString());
}
}
break;
case "Double":
isValueType = true;
if (value is IEnumerable<double> doubleValues)
{
foreach (var c in doubleValues)
{
list.Add(c.ToString(CultureInfo.InvariantCulture));
}
}
break;
case "Single":
isValueType = true;
if (value is IEnumerable<float> floatValues)
{
foreach (var c in floatValues)
{
list.Add(c.ToString(CultureInfo.InvariantCulture));
}
}
break;
case "Decimal":
isValueType = true;
if (value is IEnumerable<decimal> decimalValues)
{
foreach (var c in decimalValues)
{
list.Add(c.ToString(CultureInfo.InvariantCulture));
}
}
break;
}
}
if (list!.Count < 1)
return;
sqlBuilder.Append(columnName);
sqlBuilder.Append(notContainer ? " NOT IN (" : " IN (");
//值类型不带引号
if (isValueType)
{
for (var i = 0; i < list.Count; i++)
{
sqlBuilder.AppendFormat("{0}", list[i]);
if (i != list.Count - 1)
{
sqlBuilder.Append(",");
}
}
}
else
{
for (var i = 0; i < list.Count; i++)
{
sqlBuilder.AppendFormat("'{0}'", list[i].Replace("'", "''"));
if (i != list.Count - 1)
{
sqlBuilder.Append(",");
}
}
}
sqlBuilder.Append(")");
}
19
View Source File : MemoryCacheHandler.cs
License : MIT License
Project Creator : 17MKH
License : MIT License
Project Creator : 17MKH
private List<string> GetAllKeys()
{
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
var entries = _cache.GetType().GetField("_entries", flags).GetValue(_cache);
var cacheItems = entries as IDictionary;
var keys = new List<string>();
if (cacheItems == null) return keys;
foreach (DictionaryEntry cacheItem in cacheItems)
{
keys.Add(cacheItem.Key.ToString());
}
return keys;
}
19
View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH
License : MIT License
Project Creator : 17MKH
private static void ResolveInForGeneric(StringBuilder sqlBuilder, string columnName, Expression exp, Type valueType, bool notContainer = false)
{
var value = ResolveDynamicInvoke(exp);
var isValueType = false;
var list = new List<string>();
if (valueType.IsEnum)
{
isValueType = true;
var valueList = (IEnumerable)value;
if (valueList != null)
{
foreach (var c in valueList)
{
list.Add(Enum.Parse(valueType, c.ToString()!).ToInt().ToString());
}
}
}
else
{
var typeName = valueType.Name;
switch (typeName)
{
case "Guid":
if (value is IEnumerable<Guid> guidValues)
{
foreach (var c in guidValues)
{
list.Add(c.ToString());
}
}
break;
case "DateTime":
if (value is IEnumerable<DateTime> dateTimeValues)
{
foreach (var c in dateTimeValues)
{
list.Add(c.ToString("yyyy-MM-dd HH:mm:ss"));
}
}
break;
case "Byte":
isValueType = true;
if (value is IEnumerable<byte> byteValues)
{
foreach (var c in byteValues)
{
list.Add(c.ToString(CultureInfo.InvariantCulture));
}
}
break;
case "Char":
if (value is IEnumerable<char> charValues)
{
foreach (var c in charValues)
{
list.Add(c.ToString());
}
}
break;
case "Int16":
isValueType = true;
if (value is IEnumerable<short> shortValues)
{
foreach (var c in shortValues)
{
list.Add(c.ToString());
}
}
break;
case "Int32":
isValueType = true;
if (value is IEnumerable<int> intValues)
{
foreach (var c in intValues)
{
list.Add(c.ToString());
}
}
break;
case "Int64":
isValueType = true;
if (value is IEnumerable<long> longValues)
{
foreach (var c in longValues)
{
list.Add(c.ToString());
}
}
break;
case "Double":
isValueType = true;
if (value is IEnumerable<double> doubleValues)
{
foreach (var c in doubleValues)
{
list.Add(c.ToString(CultureInfo.InvariantCulture));
}
}
break;
case "Single":
isValueType = true;
if (value is IEnumerable<float> floatValues)
{
foreach (var c in floatValues)
{
list.Add(c.ToString(CultureInfo.InvariantCulture));
}
}
break;
case "Decimal":
isValueType = true;
if (value is IEnumerable<decimal> decimalValues)
{
foreach (var c in decimalValues)
{
list.Add(c.ToString(CultureInfo.InvariantCulture));
}
}
break;
}
}
if (list!.Count < 1)
return;
sqlBuilder.Append(columnName);
sqlBuilder.Append(notContainer ? " NOT IN (" : " IN (");
//值类型不带引号
if (isValueType)
{
for (var i = 0; i < list.Count; i++)
{
sqlBuilder.AppendFormat("{0}", list[i]);
if (i != list.Count - 1)
{
sqlBuilder.Append(",");
}
}
}
else
{
for (var i = 0; i < list.Count; i++)
{
sqlBuilder.AppendFormat("'{0}'", list[i].Replace("'", "''"));
if (i != list.Count - 1)
{
sqlBuilder.Append(",");
}
}
}
sqlBuilder.Append(")");
}
19
View Source File : AppConfig.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
public void SaveConfig(int type = 0)
{
if(type == 0 || type == 1){
try
{
string mconfig = JsonConvert.SerializeObject(MConfig, Formatting.Indented);
if (!string.IsNullOrWhiteSpace(mconfig))
{
YSTools.YSFile.writeFileByString(MainForm.CONF_DIR + MC_NAME, mconfig, false, CONFIG_KEY);
}
}
catch (Exception ex)
{
logger.Error("保存Main配置文件异常:" + ex.Message);
logger.Error("--->" + MC_NAME);
}
}
if (type == 0 || type == 2)
{
string sconfig = null, scname = null;
int index = 0;
List<string> newFiles = new List<string>();
foreach (KeyValuePair<string, SessionConfig> item in SessionConfigDict)
{
try
{
sconfig = JsonConvert.SerializeObject(item.Value, Formatting.Indented);
if (!string.IsNullOrWhiteSpace(sconfig))
{
scname = string.Format("session{0}.json", index);
YSTools.YSFile.writeFileByString(MainForm.SESSION_DIR + scname, sconfig, false, CONFIG_KEY);
newFiles.Add(scname);
index++;
}
}
catch (Exception ex)
{
logger.Error("保存Session配置文件异常:" + ex.Message);
logger.Error("--->" + item.Key);
}
}
DirectoryInfo dirs = new DirectoryInfo(MainForm.SESSION_DIR);
FileInfo[] files = dirs.GetFiles();
foreach(FileInfo file in files){
if (!newFiles.Contains(file.Name))
{
file.Delete();
}
}
}
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : 1y0n
License : MIT License
Project Creator : 1y0n
private string Generate_JS_XSL(string type)
{
//1. 生成一个 dll 文件
string target_arch = " /platform:x86 /optimize ";
if (radioButton2.Checked)
{
target_arch = " /platform:x64 /optimize";
}
KEY = Random_Key();
List<string> temp_list = new List<string>();
foreach (byte i in KEY)
{
temp_list.Add("0x" + i.ToString("X2"));
}
KEY_String = string.Join(",", temp_list);
Compiler compiler = new Compiler();
TP_VirtualAlloc_DLL vad = new TP_VirtualAlloc_DLL(KEY_String, Handle_Payload());
compiler.compileToExe(vad.GetCode(), KEY_String, Global_Var.dll_path, target_arch, "library");
//2. 通过 DotNetToJscript 转换成 js
string js_result = DotNetToJScript.Generate();
if (js_result != null)
{
if (type == ".js")
{
return js_result;
}
else
{
TP_XSL xsl = new TP_XSL();
return xsl.GetCode(js_result);
}
}
else
{
return null;
}
}
19
View Source File : BssoFieldMarshalTest.cs
License : MIT License
Project Creator : 1996v
License : MIT License
Project Creator : 1996v
[Theory]
[InlineData((byte)10)]
[InlineData((short)-10)]
[InlineData((int)-10)]
[InlineData((long)-120)]
[InlineData((float)0.000006)]
[InlineData((double)0.000006)]
[InlineData('\u9999')]
[InlineData("12345678901234567")]//17size-> Blank0 critical value
public void Array2_WriteFieldWithBlankLength_MultipleWritesOfInconsistentLength_IsCorrectly(object fieldValue)
{
var val = new List<string>();//18size
val.Add("123456789012345678");
var buf = BssomSerializer.Serialize(val);
var bsfm = new BssomFieldMarshaller(buf);
var cOffset = bsfm.IndexOf("$0");
bsfm.TryWrite(cOffset, fieldValue).IsTrue();
bsfm.ReadValue<BssomValue>(cOffset).Is(BssomValue.Create(fieldValue));
}
19
View Source File : DefaultConfig.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
public static void InitDefaultShellList(List<string> shellList)
{
if (!shellList.Contains(SHELL_1))
{
shellList.Add(SHELL_1);
}
if (!shellList.Contains(SHELL_2))
{
shellList.Add(SHELL_2);
}
if (!shellList.Contains(SHELL_3))
{
shellList.Add(SHELL_3);
}
if (!shellList.Contains(SHELL_4))
{
shellList.Add(SHELL_4);
}
if (!shellList.Contains(SHELL_5))
{
shellList.Add(SHELL_5);
}
AppConfig.Instance.SaveConfig(2);
}
19
View Source File : DefaultConfig.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
public static void UpdateShellLisreplacedem(List<string> shellList, int index, string cmd)
{
if (index < shellList.Count)
{
shellList[index] = cmd;
}
else if (!shellList.Contains(cmd))
{
shellList.Add(cmd);
}
AppConfig.Instance.SaveConfig(2);
}
19
View Source File : VMFAdapter.cs
License : MIT License
Project Creator : 1upD
License : MIT License
Project Creator : 1upD
public NailsMap Import()
{
try {
// Reset adapter VMF
this._vmf = new VMF();
NailsMap map = new NailsMap();
List<string> lines = new List<string>();
using (StreamReader sr = new StreamReader(new FileStream(this._filename, FileMode.OpenOrCreate)))
{
while (!sr.EndOfStream)
{
lines.Add(sr.ReadLine());
}
}
VMF input_vmf = new VMF(lines.ToArray());
for (int blockIndex = 0; blockIndex < input_vmf.Body.Count; blockIndex++)
{
// Should this object be included when the VMF is output?
bool includeThisBlock = true;
// Get the next object from the VMF
var obj = input_vmf.Body[blockIndex];
try
{
// Try to cast to block
VMFParser.VBlock block = (VMFParser.VBlock)obj;
// If this block is an enreplacedy
if (block.Name == "enreplacedy")
{
var body = block.Body;
foreach (var innerObj in body) {
try
{
VMFParser.VProperty prop = (VMFParser.VProperty)innerObj;
// If this block is an instance
if (prop.Name == "clreplacedname" && prop.Value == "func_instance")
{
VProperty fileProperty = (VProperty)body.Where(p => p.Name == "file").ToList()[0];
var filePathParts = fileProperty.Value.Split('/');
// If this is a nails instance
if (filePathParts[0] == "Nails")
{
// Get position
VProperty originProperty = (VProperty)body.Where(p => p.Name == "origin").ToList()[0];
var originParts = originProperty.Value.Split(' ');
int x_pos = int.Parse(originParts[0]) / this._horizontal_scale;
int y_pos = int.Parse(originParts[1]) / this._horizontal_scale;
int z_pos = int.Parse(originParts[2]) / this._vertical_scale;
string style = filePathParts[1];
map.MarkLocation(style, x_pos, y_pos, z_pos);
// Remove this block from the vmf
includeThisBlock = false;
}
break;
}
} catch (InvalidCastException e)
{
log.Error("Invalid cast exception. VMF Object is not a VProperty.", e);
}
}
}
} catch(InvalidCastException e)
{
log.Error("Invalid cast exception. VMF object is not a VBlock.", e);
}
// If this object is not a Nails block, add it to the adapter's VMF to be output later
if (includeThisBlock)
{
this._vmf.Body.Add(obj);
}
}
return map;
} catch (Exception e)
{
log.Error("VMFAdapter.Import(): Caught exception: ", e);
log.Info(string.Format("Failed to read from VMF file: {0}", this._filename));
}
return null;
}
19
View Source File : MainWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : 1RedOne
License : GNU General Public License v3.0
Project Creator : 1RedOne
private async void CreateClientsButton_Click(object sender, RoutedEventArgs e)
{
DeviceExpander.IsExpanded = true;
string BaseName = NewClientName.Text;
int CountOfMachines = (Int32.TryParse(NumberOfClients.Text, out int unUsed)) ? Int32.Parse(NumberOfClients.Text) : 1;
int BeginningWith = (!StartingNumber.Text.Length.Equals(0)) ? Int32.Parse(StartingNumber.Text) : 0;
List<String> DeviceList = new List<string>();
int current = 0;
object lockCurrent = new object();
var progress = new Progress<int>(_ => IdCounter++) as IProgress<int>;
for (int i = BeginningWith; i <= CountOfMachines; i++)
{
string ThisClient = BaseName + i;
DeviceList.Add(ThisClient);
}
var myTask = Task.Run(() =>
{
Parallel.For(0, DeviceList.Count,
new ParallelOptions { MaxDegreeOfParallelism = MaxThreads },
(ii, loopState) =>
{
int thisCurrent = 0;
lock (lockCurrent)
{
thisCurrent = current;
current++;
}
string device = DeviceList[thisCurrent];
Device ThisDevice = new Device() { Name = device, Status = "Starting...", ImageSource = "Images\\step01.png", ProcessProgress = 10 };
Devices.Add(ThisDevice);
int thisIndex = Devices.IndexOf(ThisDevice);
RegisterClient(thisIndex);
progress.Report(0);
});
});
await myTask;
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : 1y0n
License : MIT License
Project Creator : 1y0n
private void button1_Click(object sender, EventArgs e)
{
if ((textBox2.Enabled) && (textBox2.Text.Trim() == ""))
{
MessageBox.Show("注入进程时应按照要求填写进程名或 pid", "警告");
return;
}
string file_type = comboBox1.Text;
string target_arch = null;
Compiler compiler = new Compiler();
target_arch = " /platform:x86 /optimize ";
switch (file_type)
{
case ".exe":
saveFileDialog1.Filter = "可执行文件|*.exe";
break;
case ".js":
saveFileDialog1.Filter = "js脚本|*.js";
break;
case ".xsl":
saveFileDialog1.Filter = "xsl文件|*.xsl";
break;
}
DialogResult dr = saveFileDialog1.ShowDialog();
if (dr == DialogResult.OK && saveFileDialog1.FileName.Length > 0)
{
switch (file_type)
{
case ".exe":
if (radioButton2.Checked)
{
target_arch = " /platform:x64 /optimize";
}
if (checkBox2.Checked)
{
target_arch += "/target:winexe ";
}
if (ico_filename != null)
{
target_arch += " /win32icon:" + ico_filename;
}
KEY = Random_Key();
List<string> temp_list = new List<string>();
foreach (byte i in KEY)
{
temp_list.Add("0x" + i.ToString("X2"));
}
KEY_String = string.Join(",", temp_list); //生成key的字符串形式,用于写入到文件
switch (comboBox4.Text)
{
case "直接执行(VirtualAlloc)":
TP_VirtualAlloc va = new TP_VirtualAlloc(KEY_String, Handle_Payload());
compiler.compileToExe(va.GetCode(), KEY_String, saveFileDialog1.FileName, target_arch);
break;
case "直接执行(VirtualProtect)":
TP_VirtualProtect vp = new TP_VirtualProtect(KEY_String, Handle_Payload());
compiler.compileToExe(vp.GetCode(), KEY_String, saveFileDialog1.FileName, target_arch);
break;
case "[x64]新进程注入(SYSCALL)":
TP_Syscall_New scn = new TP_Syscall_New(KEY_String, Handle_Payload(), textBox2.Text.Trim());
target_arch += " /unsafe"; //必需,因为包含了不安全代码
compiler.compileToExe(scn.GetCode(), KEY_String, saveFileDialog1.FileName, target_arch);
break;
case "新进程注入(VirtualAllocEx)":
TP_VirtualAllocEx vaex = new TP_VirtualAllocEx(KEY_String, Handle_Payload(), textBox2.Text);
compiler.compileToExe(vaex.GetCode(), KEY_String, saveFileDialog1.FileName, target_arch);
break;
case "注入现有进程(VirtualAllocEx)":
TP_VirtualAllocEx_Exist vaee = new TP_VirtualAllocEx_Exist(KEY_String, Handle_Payload(), Convert.ToInt32(textBox2.Text.Trim()));
compiler.compileToExe(vaee.GetCode(), KEY_String, saveFileDialog1.FileName, target_arch);
break;
case "[x64]注入现有进程(SYSCALL)":
TP_Syscall_Exist sce = new TP_Syscall_Exist(KEY_String, Handle_Payload(), Convert.ToInt32(textBox2.Text.Trim()));
target_arch += " /unsafe"; //必需,因为包含了不安全代码
compiler.compileToExe(sce.GetCode(), KEY_String, saveFileDialog1.FileName, target_arch);
break;
case "进程镂空(Process Hollowing)":
TP_Process_Hollowing ph = new TP_Process_Hollowing(KEY_String, Handle_Payload(), textBox2.Text);
target_arch += " /unsafe"; //必需,因为包含了不安全代码
compiler.compileToExe(ph.GetCode(), KEY_String, saveFileDialog1.FileName, target_arch);
break;
}
break;
default:
string temp = Generate_JS_XSL(file_type);
System.IO.File.WriteAllText(saveFileDialog1.FileName, temp);
break;
}
MessageBox.Show("All seems fine. Lets Hack the Plant!\r\n\r\nWARNING: 不要将生成的程序上传到在线杀毒网站!", "ALL SUCCESS!");
}
}
19
View Source File : TextFindForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private void addFindHisItem(string str) {
if (null != str && str.Length > 0 && !findHisList.Contains(str))
{
findHisList.Add(str);
text_res.Items.Add(str);
}
}
19
View Source File : CentralServerConfigForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private List<string> getTreeNodeContent(TreeListViewItemCollection items)
{
List<string> list = new List<string>();
string line = "";
int level = 0;
foreach (TreeListViewItem treeNode in items)
{
line = treeNode.Text;
if (!line.TrimStart().StartsWith("#"))
{
line += ": ";
level = Convert.ToInt32(treeNode.SubItems[2].Text);
line = YmlFormatUtil.GetSpace(level * 4) + line;
line += treeNode.SubItems[1].Text;
line += treeNode.SubItems[3].Text;
}
if (!string.IsNullOrWhiteSpace(line))
{
list.Add(line);
}
list.AddRange(getTreeNodeContent(treeNode.Items));
}
return list;
}
19
View Source File : YmlNodeForm.cs
License : Apache License 2.0
Project Creator : 214175590
License : Apache License 2.0
Project Creator : 214175590
private List<string> getParentText(TreeListViewItem node)
{
List<string> list = new List<string>();
if(node != null){
list.Add(node.Text);
List<string> plist = getParentText(node.Parent);
if (plist.Count > 0)
{
list.AddRange(plist);
}
}
return list;
}
19
View Source File : Program.cs
License : MIT License
Project Creator : 2401dem
License : MIT License
Project Creator : 2401dem
public static int Denoise()
{
if (_is_folder)
{
if (Directory.Exists(_input_path) || Directory.Exists(_input_path.Substring(0, _input_path.LastIndexOf('\\') > 0 ? _input_path.LastIndexOf('\\') : 0)))
{
if (Directory.Exists(_output_path) || Directory.Exists(_output_path.Substring(0, _output_path.LastIndexOf('\\') > 0 ? _output_path.LastIndexOf('\\') : 0)))
{
var file_paths = Directory.GetFiles(_input_path, "*.*", SearchOption.TopDirectoryOnly);
List<string> input_file_paths = new List<string>();
List<string> output_file_paths = new List<string>();
foreach (string file_path in file_paths)
{
Regex regex = new Regex(".\\.(bmp|jpg|png|tif|exr)$", RegexOptions.IgnoreCase);
if (regex.IsMatch(file_path))
{
input_file_paths.Add(file_path);
output_file_paths.Add(_output_path + "\\out_" + file_path.Substring(file_path.LastIndexOf('\\') + 1));
Console.WriteLine(file_path);
}
}
int width = _getWidth(input_file_paths[0].ToCharArray());
int height = _getHeight(input_file_paths[0].ToCharArray());
if (width == -1 || height == -1)
{
MessageBox.Show("Picture Format Error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Program.form1.unlockButton();
return -1;
}
//Bitmap pBuffer = new Bitmap(input_file_paths[0], false);
IntPtr tmpptr = new IntPtr();
_jobStart(width, height, _blend);
for (int i = 0; i < input_file_paths.Count; ++i)
{
Program.form1.SetProgress((float)i / (float)input_file_paths.Count);
if (File.Exists(output_file_paths[i]))
continue;
//IntPtr tmpptr =
tmpptr = _denoiseImplement(input_file_paths[i].ToCharArray(), output_file_paths[i].ToCharArray(), _blend, _is_folder);
/*if (tmpptr != null)
if (Program.form1.DrawToPictureBox(tmpptr, pBuffer.Width, pBuffer.Height) == 0)
continue;
else
{
MessageBox.Show("Picture Size Error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
else
{
//MessageBox.Show("Picture Size Error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//break;
}*/
}
_jobComplete();
if (tmpptr != null)
if (Program.form1.DrawToPictureBox(tmpptr, width, height) != 0)
MessageBox.Show("Picture Size Error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Program.form1.SetProgress(1.0f);
Program.form1.unlockButton();
return 0;
}
else
MessageBox.Show("Output folder does not exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Input folder does not exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (File.Exists(_input_path))
{
if (Directory.Exists(_output_path.Substring(0, _output_path.LastIndexOf('\\'))))
{
int width = _getWidth(_input_path.ToCharArray());
int height = _getHeight(_input_path.ToCharArray());
Console.WriteLine(width.ToString());
Console.WriteLine(height.ToString());
if (width == -1 || height == -1)
{
MessageBox.Show("Picture Format Error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Program.form1.unlockButton();
return -1;
}
_jobStart(width, height, _blend);
IntPtr tmpptr = _denoiseImplement(_input_path.ToCharArray(), _output_path.ToCharArray(), _blend, _is_folder);
if (tmpptr != null)
{
if (Program.form1.DrawToPictureBox(tmpptr, width, height) == -1)
MessageBox.Show("Picture Size Error(NULL to Draw)!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Picture Size Error!(NULL Return)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Program.form1.SetProgress(1.0f);
Program.form1.unlockButton();
_jobComplete();
return 0;
}
else
MessageBox.Show("Output folder does not exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Input file does not exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Program.form1.unlockButton();
return -1;
}
19
View Source File : PubSub.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
internal void Cancel(params Guid[] ids)
{
if (ids == null) return;
var readyUnsubInterKeys = new List<string>();
foreach (var id in ids)
{
if (_cancels.TryRemove(id, out var oldkeys))
foreach (var oldkey in oldkeys)
{
if (_registers.TryGetValue(oldkey, out var oldrecvs) &&
oldrecvs.TryRemove(id, out var oldrecv) &&
oldrecvs.Any() == false)
readyUnsubInterKeys.Add(oldkey);
}
}
var unsub = readyUnsubInterKeys.Where(a => !a.StartsWith(_psub_regkey_prefix)).ToArray();
var punsub = readyUnsubInterKeys.Where(a => a.StartsWith(_psub_regkey_prefix)).Select(a => a.Replace(_psub_regkey_prefix, "")).ToArray();
if (unsub.Any()) Call("UNSUBSCRIBE".Input(unsub));
if (punsub.Any()) Call("PUNSUBSCRIBE".Input(punsub));
if (!_cancels.Any())
lock (_lock)
if (!_cancels.Any())
_redisSocket?.ReleaseSocket();
}
19
View Source File : RazorModel.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public string GetTableAttribute() {
var sb = new List<string>();
if (GetCsName(this.FullTableName) != this.FullTableName)
sb.Add("Name = \"" + this.FullTableName + "\"");
if (sb.Any() == false) return null;
return "[Table(" + string.Join(", ", sb) + ")]";
}
19
View Source File : RazorModel.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public string GetColumnAttribute(DbColumnInfo col) {
var sb = new List<string>();
if (GetCsName(col.Name) != col.Name)
sb.Add("Name = \"" + col.Name + "\"");
var dbinfo = fsql.CodeFirst.GetDbInfo(col.CsType);
if (dbinfo != null && string.Compare(dbinfo.dbtypeFull.Replace("NOT NULL", "").Trim(), col.DbTypeTextFull, true) != 0)
sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
if (col.IsPrimary)
sb.Add("IsPrimary = true");
if (col.IsIdenreplacedy)
sb.Add("IsIdenreplacedy = true");
if (dbinfo != null && dbinfo.isnullable != col.IsNullable) {
if (col.IsNullable && fsql.DbFirst.GetCsType(col).Contains("?") == false && col.CsType.IsValueType)
sb.Add("IsNullable = true");
if (col.IsNullable == false && fsql.DbFirst.GetCsType(col).Contains("?") == true)
sb.Add("IsNullable = false");
}
if (sb.Any() == false) return null;
return "[Column(" + string.Join(", ", sb) + ")]";
}
19
View Source File : RazorModel.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public string GetColumnAttribute(DbColumnInfo col, bool isInsertValueSql = false)
{
var sb = new List<string>();
if (GetCsName(col.Name) != col.Name)
sb.Add("Name = \"" + col.Name + "\"");
if (col.CsType != null)
{
var dbinfo = fsql.CodeFirst.GetDbInfo(col.CsType);
if (dbinfo != null && string.Compare(dbinfo.dbtypeFull.Replace("NOT NULL", "").Trim(), col.DbTypeTextFull, true) != 0)
{
#region StringLength 反向
switch (fsql.Ado.DataType)
{
case DataType.MySql:
case DataType.OdbcMySql:
switch (col.DbTypeTextFull.ToLower())
{
case "longtext": sb.Add("StringLength = -2"); break;
case "text": sb.Add("StringLength = -1"); break;
default:
var m_stringLength = Regex.Match(col.DbTypeTextFull, @"^varchar\s*\((\w+)\)$", RegexOptions.IgnoreCase);
if (m_stringLength.Success) sb.Add($"StringLength = {m_stringLength.Groups[1].Value}");
else sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
break;
}
break;
case DataType.SqlServer:
case DataType.OdbcSqlServer:
switch (col.DbTypeTextFull.ToLower())
{
case "nvarchar(max)": sb.Add("StringLength = -2"); break;
default:
var m_stringLength = Regex.Match(col.DbTypeTextFull, @"^nvarchar\s*\((\w+)\)$", RegexOptions.IgnoreCase);
if (m_stringLength.Success) sb.Add($"StringLength = {m_stringLength.Groups[1].Value}");
else sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
break;
}
break;
case DataType.PostgreSQL:
case DataType.OdbcPostgreSQL:
case DataType.OdbcKingbaseES:
case DataType.ShenTong:
switch (col.DbTypeTextFull.ToLower())
{
case "text": sb.Add("StringLength = -2"); break;
default:
var m_stringLength = Regex.Match(col.DbTypeTextFull, @"^varchar\s*\((\w+)\)$", RegexOptions.IgnoreCase);
if (m_stringLength.Success) sb.Add($"StringLength = {m_stringLength.Groups[1].Value}");
else sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
break;
}
break;
case DataType.Oracle:
case DataType.OdbcOracle:
switch (col.DbTypeTextFull.ToLower())
{
case "nclob": sb.Add("StringLength = -2"); break;
default:
var m_stringLength = Regex.Match(col.DbTypeTextFull, @"^nvarchar2\s*\((\w+)\)$", RegexOptions.IgnoreCase);
if (m_stringLength.Success) sb.Add($"StringLength = {m_stringLength.Groups[1].Value}");
else sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
break;
}
break;
case DataType.Dameng:
case DataType.OdbcDameng:
switch (col.DbTypeTextFull.ToLower())
{
case "text": sb.Add("StringLength = -2"); break;
default:
var m_stringLength = Regex.Match(col.DbTypeTextFull, @"^nvarchar2\s*\((\w+)\)$", RegexOptions.IgnoreCase);
if (m_stringLength.Success) sb.Add($"StringLength = {m_stringLength.Groups[1].Value}");
else sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
break;
}
break;
case DataType.Sqlite:
switch (col.DbTypeTextFull.ToLower())
{
case "text": sb.Add("StringLength = -2"); break;
default:
var m_stringLength = Regex.Match(col.DbTypeTextFull, @"^nvarchar\s*\((\w+)\)$", RegexOptions.IgnoreCase);
if (m_stringLength.Success) sb.Add($"StringLength = {m_stringLength.Groups[1].Value}");
else sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
break;
}
break;
case DataType.MsAccess:
switch (col.DbTypeTextFull.ToLower())
{
case "longtext": sb.Add("StringLength = -2"); break;
default:
var m_stringLength = Regex.Match(col.DbTypeTextFull, @"^varchar\s*\((\w+)\)$", RegexOptions.IgnoreCase);
if (m_stringLength.Success) sb.Add($"StringLength = {m_stringLength.Groups[1].Value}");
else sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
break;
}
break;
}
#endregion
}
if (col.IsPrimary)
sb.Add("IsPrimary = true");
if (col.IsIdenreplacedy)
sb.Add("IsIdenreplacedy = true");
if (dbinfo != null && dbinfo.isnullable != col.IsNullable)
{
if (col.IsNullable && fsql.DbFirst.GetCsType(col).Contains("?") == false && col.CsType.IsValueType)
sb.Add("IsNullable = true");
if (col.IsNullable == false && fsql.DbFirst.GetCsType(col).Contains("?") == true)
sb.Add("IsNullable = false");
}
if (isInsertValueSql)
{
var defval = GetColumnDefaultValue(col, false);
if (defval == null) //c#默认属性值,就不需要设置 InsertValueSql 了
{
defval = GetColumnDefaultValue(col, true);
if (defval != null)
{
sb.Add("InsertValueSql = \"" + defval.Replace("\"", "\\\"") + "\"");
sb.Add("CanInsert = false");
}
}
else
sb.Add("CanInsert = false");
}
}
if (sb.Any() == false) return null;
return "[Column(" + string.Join(", ", sb) + ")]";
}
19
View Source File : DataFilter.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public IDisposable Disable(params string[] filterName) {
if (filterName == null || filterName.Any() == false) return new UsingAny(() => { });
List<string> restore = new List<string>();
foreach (var name in filterName) {
if (_filters.TryGetValue(name, out var tryfi)) {
if (tryfi.IsEnabled) {
restore.Add(name);
tryfi.IsEnabled = false;
}
}
}
return new UsingAny(() => this.Enable(restore.ToArray()));
}
19
View Source File : DataFilter.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public IDisposable DisableAll() {
List<string> restore = new List<string>();
foreach (var val in _filters) {
if (val.Value.IsEnabled) {
restore.Add(val.Key);
val.Value.IsEnabled = false;
}
}
return new UsingAny(() => this.Enable(restore.ToArray()));
}
19
View Source File : DataFilter.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public IDisposable Enable(params string[] filterName) {
if (filterName == null || filterName.Any() == false) return new UsingAny(() => { });
List<string> restore = new List<string>();
foreach (var name in filterName) {
if (_filters.TryGetValue(name, out var tryfi)) {
if (tryfi.IsEnabled == false) {
restore.Add(name);
tryfi.IsEnabled = true;
}
}
}
return new UsingAny(() => this.Disable(restore.ToArray()));
}
19
View Source File : DataFilter.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public IDisposable EnableAll() {
List<string> restore = new List<string>();
foreach (var val in _filters) {
if (val.Value.IsEnabled == false) {
restore.Add(val.Key);
val.Value.IsEnabled = true;
}
}
return new UsingAny(() => this.Disable(restore.ToArray()));
}
19
View Source File : RazorModel.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public string GetTableAttribute()
{
var sb = new List<string>();
if (GetCsName(this.FullTableName) != this.FullTableName)
{
if (this.FullTableName.IndexOf('.') == -1)
sb.Add("Name = \"" + this.FullTableName + "\"");
else
sb.Add("Name = \"" + this.FullTableName + "\""); //Todo: QuoteSqlName
}
sb.Add("DisableSyncStructure = true");
if (sb.Any() == false) return null;
return "[Table(" + string.Join(", ", sb) + ")]";
}
19
View Source File : RoutingRuleSettingDetailsForm.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
private void EndBindingData()
{
if (rulesItem != null)
{
rulesItem.port = txtPort.Text.TrimEx();
var inboundTag = new List<String>();
for (int i = 0; i < clbInboundTag.Items.Count; i++)
{
if (clbInboundTag.GereplacedemChecked(i))
{
inboundTag.Add(clbInboundTag.Items[i].ToString());
}
}
rulesItem.inboundTag = inboundTag;
rulesItem.outboundTag = cmbOutboundTag.Text;
rulesItem.domain = Utils.String2List(txtDomain.Text);
rulesItem.ip = Utils.String2List(txtIP.Text);
var protocol = new List<string>();
for (int i = 0; i < clbProtocol.Items.Count; i++)
{
if (clbProtocol.GereplacedemChecked(i))
{
protocol.Add(clbProtocol.Items[i].ToString());
}
}
rulesItem.protocol = protocol;
rulesItem.enabled = chkEnabled.Checked;
}
}
19
View Source File : ImClient.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public void ClearChanClient(string chan)
{
var websocketIds = _redis.HKeys($"{_redisPrefix}Chan{chan}");
var offline = new List<string>();
var span = websocketIds.replacedpan();
var start = span.Length;
while (start > 0)
{
start = start - 10;
var length = 10;
if (start < 0)
{
length = start + 10;
start = 0;
}
var slice = span.Slice(start, length);
var hvals = _redis.HMGet($"{_redisPrefix}Online", slice.ToArray().Select(b => b.ToString()).ToArray());
for (var a = length - 1; a >= 0; a--)
{
if (string.IsNullOrEmpty(hvals[a]))
{
offline.Add(span[start + a]);
span[start + a] = null;
}
}
}
//删除离线订阅
if (offline.Any()) _redis.HDel($"{_redisPrefix}Chan{chan}", offline.ToArray());
}
19
View Source File : TypeExtension.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public static IEnumerable<MethodInfo> GetApis(this Type type)
{
var addMethods = type.GetEvents().Select(_event => _event.GetAddMethod());
var removeMethods = type.GetEvents().Select(_event => _event.GetRemoveMethod());
var getMethods = type.GetProperties().Select(_propety => _propety.GetGetMethod());
var setMethods = type.GetProperties().Select(_propety => _propety.GetSetMethod());
var enumerable = addMethods
.Concat(removeMethods)
.Concat(getMethods)
.Concat(setMethods)
.Where(_method=>_method != null)
.Select(_method => _method.Name);
var methods = enumerable.ToList();
methods.Add("Dispose");
return type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Where(_method=> !methods.Contains(_method.Name));
}
19
View Source File : RoutingSettingDetailsForm.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
private void EndBindingData()
{
if (routingItem != null)
{
routingItem.remarks = txtRemarks.Text.TrimEx();
routingItem.port = txtPort.Text.TrimEx();
routingItem.outboundTag = cmbOutboundTag.Text;
routingItem.domain = Utils.String2List(txtDomain.Text);
routingItem.ip = Utils.String2List(txtIP.Text);
var protocol = new List<string>();
for (int i = 0; i < clbProtocol.Items.Count; i++)
{
if (clbProtocol.GereplacedemChecked(i))
{
protocol.Add(clbProtocol.Items[i].ToString());
}
}
routingItem.protocol = protocol;
}
}
19
View Source File : Utils.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public static List<string> GetHostIPAddress()
{
List<string> lstIPAddress = new List<string>();
try
{
IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ipa in IpEntry.AddressList)
{
if (ipa.AddressFamily == AddressFamily.InterNetwork)
lstIPAddress.Add(ipa.ToString());
}
}
catch (Exception ex)
{
SaveLog(ex.Message, ex);
}
return lstIPAddress;
}
19
View Source File : Program.cs
License : GNU Affero General Public License v3.0
Project Creator : 3CORESec
License : GNU Affero General Public License v3.0
Project Creator : 3CORESec
public static void Main(string[] args)
{
int ruleCount = 0;
int gradientMax = 0;
Parser.Default.ParseArguments<Options>(args)
.WithParsed(o =>
{
LoadConfig(o);
if (!o.Suricata)
{
LoadMismatchSearchMatrix(o);
foreach (var ruleFilePath in Directory.EnumerateFiles(o.RulesDirectory, "*.yml", SearchOption.AllDirectories))
{
try
{
var dict = DeserializeYamlFile(ruleFilePath, o);
if (dict != null && dict.ContainsKey("tags"))
{
ruleCount++;
var tags = dict["tags"];
var categories = new List<string>();
string lastEntry = null;
foreach (string tag in tags)
{
//If its the technique id entry, then this adds the file name to the techniques map
if (tag.ToLower().StartsWith("attack.t"))
{
var techniqueId = tag.Replace("attack.", "").ToUpper();
if (!techniques.ContainsKey(techniqueId))
techniques[techniqueId] = new List<string>();
techniques[techniqueId].Add(ruleFilePath.Split("\\").Last());
if (techniques.Count > gradientMax)
gradientMax = techniques.Count;
//then if there are any categories so far, it checks for a mismatch for each one
if (categories.Count > 0 && o.Warning)
{
foreach (string category in categories)
if (!(mismatchSearchMatrix.ContainsKey(techniqueId) && mismatchSearchMatrix[techniqueId].Contains(category)))
mismatchWarnings.Add($"MITRE ATT&CK technique ({techniqueId}) and tactic ({category}) mismatch in rule: {ruleFilePath.Split("\\").Last()}");
}
}
else
{
//if its the start of a new technique block, then clean categories and adds first category
if (lastEntry == null || lastEntry.StartsWith("attack.t"))
categories = new List<string>();
categories.Add(
tag.Replace("attack.", "")
.Replace("_", "-")
.ToLower());
}
lastEntry = tag;
}
}
}
catch (YamlException e)
{
Console.Error.WriteLine($"Ignoring rule {ruleFilePath} (parsing failed)");
}
}
WriteSigmaFileResult(o, gradientMax, ruleCount, techniques);
PrintWarnings();
}
else
{
List<Dictionary<string, List<string>>> res = new List<Dictionary<string, List<string>>>();
foreach (var ruleFilePath in Directory.EnumerateFiles(o.RulesDirectory, "*.rules", SearchOption.AllDirectories))
{
res.Add(ParseRuleFile(ruleFilePath));
}
WriteSuricataFileResult(o,
res
.SelectMany(dict => dict)
.ToLookup(pair => pair.Key, pair => pair.Value)
.ToDictionary(group => group.Key,
group => group.SelectMany(list => list).ToList()));
}
});
}
19
View Source File : Program.cs
License : GNU Affero General Public License v3.0
Project Creator : 3CORESec
License : GNU Affero General Public License v3.0
Project Creator : 3CORESec
public static Dictionary<string, List<string>> ParseRuleFile(string ruleFilePath)
{
Dictionary<string, List<string>> res = new Dictionary<string, List<string>>();
var contents = new StringReader(File.ReadAllText(ruleFilePath));
string line = contents.ReadLine();
while (line != null)
{
try
{
//if the line contains a mitre_technique
if (line.Contains("mitre_technique_id "))
{
List<string> techniques = new List<string>();
//get all indexes from all technique ids and add them all to a list
IEnumerable<int> indexes = Regex.Matches(line, "mitre_technique_id ").Cast<Match>().Select(m => m.Index + "mitre_technique_id ".Length);
foreach (int index in indexes)
techniques.Add(line.Substring(index, line.IndexOfAny(new [] { ',', ';' }, index) - index));
int head = line.IndexOf("msg:\"") + "msg:\"".Length;
int tail = line.IndexOf("\"", head);
string msg = line.Substring(head, tail - head);
head = line.IndexOf("sid:") + "sid:".Length;
tail = line.IndexOfAny(new char[] { ',', ';' }, head);
string sid = line.Substring(head, tail - head);
//for each found technique add the sid along with the message to the content
foreach( string technique in techniques)
{
if (res.ContainsKey(technique))
res[technique].Add($"{sid} - {msg}");
else
res.Add(technique, new List<string> { $"{sid} - {msg}" });
}
}
line = contents.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(line);
Console.WriteLine(e.Message);
line = contents.ReadLine();
}
}
return res;
}
19
View Source File : PlyHeader.cs
License : MIT License
Project Creator : 3DBear
License : MIT License
Project Creator : 3DBear
private List<string> GetProperties(IList<string> header, int elementIndex)
{
var properties = new List<string>();
for (int i = elementIndex + 1; i < header.Count; i++)
{
var property = header[i];
if (property.Contains("property"))
{
properties.Add(property);
}
else
{
break;
}
}
return properties;
}
See More Examples