📄 iniinfo.cs
字号:
using System;
using System.Collections.Generic;
namespace LicenseManage.BaseClasses
{
using System.Collections;
class IniInfo
{
public static string fingerPrint = "";
public static Array sections = new Array[0];
public static ArrayList IPs = new ArrayList();
public const string filePath = "C:\\cdkp.ini";
static cIni cdkIni = new cIni(filePath);
private static int sectLength;
//[general]
public static string UserName = IniFile.IniReadValue("general", "server_uname", filePath);
public static string pass = IniFile.IniReadValue("general", "server_pass", filePath);
public static string key = IniFile.IniReadValue("general", "server_key", filePath);
public static string file = IniFile.IniReadValue("general", "server_file", filePath);
public static string HostIp = IniFile.IniReadValue("general", "server_ip", filePath);
public static string SubNetStart = IniFile.IniReadValue("general", "store_subnet_start", filePath);
public static string SubNetEnd = IniFile.IniReadValue("general", "store_subnet_end", filePath);
public static string SubNet_Bool = IniFile.IniReadValue("general", "use_subnet", filePath);
public static readonly int sleep1 = Convert.ToInt32(IniFile.IniReadValue("general", "Sleep1", IniInfo.filePath));
public static readonly int sleep2 = Convert.ToInt32(IniFile.IniReadValue("general", "Sleep2", IniInfo.filePath));
public static bool UseSubNet = false;
//useless Constructor - made for fun and experience or later usage..
public IniInfo()
{
if (SubNet_Bool.ToLower() == "true")
{
UseSubNet = true;
}
cdkIni.ReadSections(ref sections);
sectLength = sections.Length;
int i = 0;
var StrSubNetEnd = SubNetEnd;
int x = StrSubNetEnd.LastIndexOf(".");
string StrSubNet = StrSubNetEnd.Remove(x);
StrSubNetEnd = StrSubNetEnd.Substring(x+1);
int z = Convert.ToInt32(StrSubNetEnd);
while (i < z + 1)
{
IPs.Add(StrSubNet +"." + i);
i++;
}
}
~IniInfo() // destructor of the class constructor
{
}
public static List<string> getSections()
{
List<string> SectionStr = new List<string>();
foreach (string sectStr in sections)
{
if (sectStr == "general") //remove general from section names.
continue;
SectionStr.Add(sectStr); //add all to an Array list
}
return SectionStr;
}
//read all ini values and return the in an jagged array , array of arrays , per section inner array
public static string[][] ReadAllIni()
{
string[][] jaggedA = new string[sectLength][];
string[][] jaggedAreturn = new string[sectLength - 1][];
for (var i = 1; i < sectLength; i++)
{
Array my1DArray = new Array[0];
List<string> my2DArray = new List<string>();
//if (sections.GetValue(i).ToString().ToLower() == "general")
// continue;
cdkIni.ReadValues(sections.GetValue(i).ToString(), ref my1DArray);
jaggedA[i] = new string[my1DArray.Length];
ArrayList test = new ArrayList();
foreach (string value in my1DArray)
{
test.Add(value);
my2DArray.Add(cdkIni.ReadValue(sections.GetValue(i).ToString(), value));
}
for (int z = 0; z < test.Count;)
{
for (int x = 0; x < my2DArray.Count; x++ , z++)
{
string arrayX = my2DArray[x];
jaggedA[i][x] = test[z] + " = " + arrayX;
jaggedA[i][x].Trim();
//Console.WriteLine(value + " = " + my2DArray[x].ToString());
}
}
for (int d = 0; d < jaggedA.Length; d++)
{
if (jaggedA[d] == null)
continue;
if (jaggedA[d] != null)
jaggedAreturn[d-1] = jaggedA[d];
}
}
return jaggedAreturn;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -