Here are the examples of the csharp api System.Collections.Generic.Dictionary.Add(string, string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
6534 Examples
19
View Source File : HealthMonitor.cs
License : MIT License
Project Creator : 0ffffffffh
License : MIT License
Project Creator : 0ffffffffh
private string RebuildArgList(string argList, string extras)
{
if (string.IsNullOrEmpty(extras))
return argList;
StringBuilder sb = new StringBuilder();
string s;
Dictionary<string, string> eArgs = Helper.ParseOptions(argList);
Dictionary<string, string> extraDict = Helper.ParseOptions(extras);
foreach (var key in extraDict.Keys)
{
if (eArgs.ContainsKey(key))
{
eArgs[key] = extraDict[key];
}
else
{
eArgs.Add(key, extraDict[key]);
}
}
extraDict.Clear();
extraDict = null;
foreach (var key in eArgs.Keys)
{
sb.AppendFormat("{0} {1} ", key, eArgs[key]);
}
s = sb.ToString().TrimEnd();
eArgs.Clear();
eArgs = null;
sb.Clear();
sb = null;
return s;
}
19
View Source File : Helper.cs
License : MIT License
Project Creator : 0ffffffffh
License : MIT License
Project Creator : 0ffffffffh
public static Dictionary<string, string> ParseOptions(string s)
{
Dictionary<string, string> argDict = new Dictionary<string, string>();
string tmp = "";
bool putTmp = false;
string opt = null;
if (string.IsNullOrEmpty(s))
return argDict;
string[] breaks = s.Split(' ');
foreach (string item in breaks)
{
if (item.StartsWith("\""))
{
tmp = item;
putTmp = true;
}
else if (item.EndsWith("\""))
{
putTmp = false;
if (opt != null)
{
argDict.Add(opt, tmp + item);
opt = null;
}
else
argDict.Add(tmp + item, "");
tmp = "";
}
else
{
if (putTmp)
tmp += item;
else
{
var value = item.Trim();
if (value.Length > 0)
{
if (value.StartsWith("-"))
{
if (opt != null)
{
argDict.Add(opt, "");
}
opt = value;
}
else
{
if (opt != null)
{
argDict.Add(opt, value);
opt = null;
}
else
argDict.Add(value, "");
}
}
}
}
}
if (opt != null)
argDict.Add(opt, "");
breaks = null;
return argDict;
}
19
View Source File : RequestObject.cs
License : MIT License
Project Creator : 0ffffffffh
License : MIT License
Project Creator : 0ffffffffh
private void Parse(string data)
{
string key,value, tagEnd;
int beg=-1, end=0;
beg = data.IndexOf("<", beg+1);
while (beg != -1)
{
end = data.IndexOf(">", beg);
if (end == -1)
break;
beg++;
key = data.Substring(beg, end - beg);
tagEnd = string.Format("</{0}>", key);
beg = end + 1;
end = data.IndexOf(tagEnd, beg);
if (end == -1)
break;
value = data.Substring(beg, end - beg);
items.Add(key.ToLower(), NormalizeValue(value));
beg = data.IndexOf("<", end + 1);
}
}
19
View Source File : EdisFace.cs
License : MIT License
Project Creator : 0ffffffffh
License : MIT License
Project Creator : 0ffffffffh
private Dictionary<string,string> BuildForm(HttpListenerContext ctx)
{
string[] items;
string post;
using (StreamReader sr = new StreamReader(ctx.Request.InputStream))
{
post = sr.ReadToEnd();
}
if (string.IsNullOrEmpty(post))
return null;
items = post.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
var dict = new Dictionary<string, string>();
foreach (var item in items)
{
string[] kv = item.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
if (kv.Length == 2)
{
kv[1] = System.Web.HttpUtility.UrlDecode(kv[1],Encoding.GetEncoding("iso-8859-9"));
dict.Add(kv[0], kv[1]);
}
}
return dict;
}
19
View Source File : InternalTalk.cs
License : MIT License
Project Creator : 0ffffffffh
License : MIT License
Project Creator : 0ffffffffh
public Dictionary<string, string> Parse(byte[] data, int length)
{
Dictionary<string, string> talkInfo = new Dictionary<string, string>();
string s = Encoding.ASCII.GetString(data,0,length);
var items = s.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
Log.Verbose(s);
foreach (var item in items)
{
var kv = item.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
if (!talkInfo.ContainsKey(kv[0].ToLower()))
talkInfo.Add(kv[0].ToLower(), kv[1]);
}
return talkInfo;
}
19
View Source File : CacheBuilder.cs
License : GNU General Public License v3.0
Project Creator : 1330-Studios
License : GNU General Public License v3.0
Project Creator : 1330-Studios
public static void Build() {
ResourceSet resourceSet = BloonSprites.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
foreach (DictionaryEntry v in resourceSet) {
if (v.Key is string id && v.Value is Byte[] bytes) {
built.Add(id, Convert.ToBase64String(bytes));
}
}
}
19
View Source File : DynamicProxyAbstract.cs
License : MIT License
Project Creator : 1100100
License : MIT License
Project Creator : 1100100
public void SetMeta(string key, string value)
{
if (Meta == null)
Meta = new Dictionary<string, string>();
Meta.Add(key, value);
}
19
View Source File : ExpressionActivator.cs
License : Apache License 2.0
Project Creator : 1448376744
License : Apache License 2.0
Project Creator : 1448376744
private Dictionary<string, string> Factorization(string expression)
{
var experssions = new Dictionary<string, string>();
var pattern = @"\([^\(\)]+\)";
var text = $"({expression})";
while (Regex.IsMatch(text, pattern))
{
var key = $"${experssions.Count}";
var value = Regex.Match(text, pattern).Value;
experssions.Add(key, value);
text = text.Replace(value, key);
}
return experssions;
}
19
View Source File : XmlCommandsProvider.cs
License : Apache License 2.0
Project Creator : 1448376744
License : Apache License 2.0
Project Creator : 1448376744
private Dictionary<string, string> ResolveVariables(XmlElement element)
{
var variables = new Dictionary<string, string>();
var elements = element.Cast<XmlNode>()
.Where(a => a.Name == "var");
foreach (XmlElement item in elements)
{
if (item.Name == "var")
{
var id = item.GetAttribute("id");
var value = string.IsNullOrEmpty(item.InnerXml)
? item.GetAttribute("value") : item.InnerXml;
variables.Add(id, value);
}
}
return variables;
}
19
View Source File : XmlCommandsProvider.cs
License : Apache License 2.0
Project Creator : 1448376744
License : Apache License 2.0
Project Creator : 1448376744
private void Resolve(XmlDoreplacedent doreplacedent)
{
if (doreplacedent.DoreplacedentElement.Name != "commands")
{
return;
}
lock (this)
{
var @namespace = doreplacedent.DoreplacedentElement
.GetAttribute("namespace") ?? string.Empty;
//解析全局变量
var globalVariables = ResolveVariables(doreplacedent.DoreplacedentElement);
//获取命令节点
var elements = doreplacedent.DoreplacedentElement
.Cast<XmlNode>()
.Where(a => a.Name != "var" && a is XmlElement);
foreach (XmlElement item in elements)
{
var id = item.GetAttribute("id");
id = string.IsNullOrEmpty(@namespace) ? $"{id}" : $"{@namespace}.{id}";
//解析局部变量
var localVariables = ResolveVariables(item);
//合并局部和全局变量,局部变量可以覆盖全局变量
var variables = new Dictionary<string, string>(globalVariables);
foreach (var ariable in localVariables)
{
if (variables.ContainsKey(ariable.Key))
{
variables[ariable.Key] = ariable.Value;
}
else
{
variables.Add(ariable.Key, ariable.Value);
}
}
//替换变量
var xml = ReplaceVariable(variables, item.OuterXml);
var doc = new XmlDoreplacedent();
doc.LoadXml(xml);
//通过变量解析命令
var cmd = ResolveCommand(doc.DoreplacedentElement);
if (_commands.ContainsKey(id))
{
_commands[id] = cmd;
}
else
{
_commands.Add(id, cmd);
}
}
}
}
19
View Source File : XmlHelper.cs
License : MIT License
Project Creator : 279328316
License : MIT License
Project Creator : 279328316
public T DeserializeNode<T>(XmlNode node = null) where T : clreplaced, new()
{
T model = new T();
XmlNode firstChild;
if (node == null)
{
node = root;
}
firstChild = node.FirstChild;
Dictionary<string, string> dict = new Dictionary<string, string>();
XmlAttributeCollection xmlAttribute = node.Attributes;
if (node.Attributes.Count > 0)
{
for (int i = 0; i < node.Attributes.Count; i++)
{
if (!dict.Keys.Contains(node.Attributes[i].Name))
{
dict.Add(node.Attributes[i].Name, node.Attributes[i].Value);
}
}
}
if (!dict.Keys.Contains(firstChild.Name))
{
dict.Add(firstChild.Name, firstChild.InnerText);
}
XmlNode next = firstChild.NextSibling;
while (next != null)
{
if (!dict.Keys.Contains(next.Name))
{
dict.Add(next.Name, next.InnerText);
}
else
{
throw new Exception($"重复的属性Key:{next.Name}");
}
next = next.NextSibling;
}
#region 为对象赋值
Type modelType = typeof(T);
List<PropertyInfo> piList = modelType.GetProperties().Where(pro => (pro.PropertyType.Equals(typeof(string)) || pro.PropertyType.IsValueType) && pro.CanRead && pro.CanWrite).ToList();
foreach (PropertyInfo pi in piList)
{
string dictKey = dict.Keys.FirstOrDefault(key => key.ToLower() == pi.Name.ToLower());
if (!string.IsNullOrEmpty(dictKey))
{
string value = dict[dictKey];
TypeConverter typeConverter = TypeDescriptor.GetConverter(pi.PropertyType);
if (typeConverter != null)
{
if (typeConverter.CanConvertFrom(typeof(string)))
pi.SetValue(model, typeConverter.ConvertFromString(value));
else
{
if (typeConverter.CanConvertTo(pi.PropertyType))
pi.SetValue(model, typeConverter.ConvertTo(value, pi.PropertyType));
}
}
}
}
#endregion
return model;
}
19
View Source File : ShareHandler.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public static string GetShareUrl(Config config, int index)
{
try
{
string url = string.Empty;
VmessItem item = config.vmess[index];
if (item.configType == (int)EConfigType.Vmess)
{
VmessQRCode vmessQRCode = new VmessQRCode
{
v = item.configVersion.ToString(),
ps = item.remarks.TrimEx(), //备注也许很长 ;
add = item.address,
port = item.port.ToString(),
id = item.id,
aid = item.alterId.ToString(),
scy = item.security,
net = item.network,
type = item.headerType,
host = item.requestHost,
path = item.path,
tls = item.streamSecurity,
sni = item.sni
};
url = Utils.ToJson(vmessQRCode);
url = Utils.Base64Encode(url);
url = string.Format("{0}{1}", Global.vmessProtocol, url);
}
else if (item.configType == (int)EConfigType.Shadowsocks)
{
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
url = string.Format("{0}:{1}@{2}:{3}",
item.security,
item.id,
item.address,
item.port);
url = Utils.Base64Encode(url);
url = string.Format("{0}{1}{2}", Global.ssProtocol, url, remark);
}
else if (item.configType == (int)EConfigType.Socks)
{
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
url = string.Format("{0}:{1}@{2}:{3}",
item.security,
item.id,
item.address,
item.port);
url = Utils.Base64Encode(url);
url = string.Format("{0}{1}{2}", Global.socksProtocol, url, remark);
}
else if (item.configType == (int)EConfigType.Trojan)
{
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
string query = string.Empty;
if (!Utils.IsNullOrEmpty(item.sni))
{
query = string.Format("?sni={0}", Utils.UrlEncode(item.sni));
}
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = string.Format("{0}{1}{2}{3}", Global.trojanProtocol, url, query, remark);
}
else if (item.configType == (int)EConfigType.VLESS)
{
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utils.IsNullOrEmpty(item.flow))
{
dicQuery.Add("flow", item.flow);
}
if (!Utils.IsNullOrEmpty(item.security))
{
dicQuery.Add("encryption", item.security);
}
else
{
dicQuery.Add("encryption", "none");
}
if (!Utils.IsNullOrEmpty(item.streamSecurity))
{
dicQuery.Add("security", item.streamSecurity);
}
else
{
dicQuery.Add("security", "none");
}
if (!Utils.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utils.IsNullOrEmpty(item.network))
{
dicQuery.Add("type", item.network);
}
else
{
dicQuery.Add("type", "tcp");
}
switch (item.network)
{
case "tcp":
if (!Utils.IsNullOrEmpty(item.headerType))
{
dicQuery.Add("headerType", item.headerType);
}
else
{
dicQuery.Add("headerType", "none");
}
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
break;
case "kcp":
if (!Utils.IsNullOrEmpty(item.headerType))
{
dicQuery.Add("headerType", item.headerType);
}
else
{
dicQuery.Add("headerType", "none");
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("seed", Utils.UrlEncode(item.path));
}
break;
case "ws":
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("path", Utils.UrlEncode(item.path));
}
break;
case "http":
case "h2":
dicQuery["type"] = "http";
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("path", Utils.UrlEncode(item.path));
}
break;
case "quic":
if (!Utils.IsNullOrEmpty(item.headerType))
{
dicQuery.Add("headerType", item.headerType);
}
else
{
dicQuery.Add("headerType", "none");
}
dicQuery.Add("quicSecurity", Utils.UrlEncode(item.requestHost));
dicQuery.Add("key", Utils.UrlEncode(item.path));
break;
case "grpc":
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("serviceName", Utils.UrlEncode(item.path));
if (item.headerType == Global.GrpcgunMode || item.headerType == Global.GrpcmultiMode)
{
dicQuery.Add("mode", Utils.UrlEncode(item.headerType));
}
}
break;
}
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = string.Format("{0}{1}{2}{3}", Global.vlessProtocol, url, query, remark);
}
else
{
}
return url;
}
catch
{
return "";
}
}
19
View Source File : ShareHandler.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public static string GetShareUrl(Config config, int index)
{
try
{
string url = string.Empty;
VmessItem item = config.vmess[index];
if (item.configType == (int)EConfigType.Vmess)
{
VmessQRCode vmessQRCode = new VmessQRCode
{
v = item.configVersion.ToString(),
ps = item.remarks.TrimEx(), //备注也许很长 ;
add = item.address,
port = item.port.ToString(),
id = item.id,
aid = item.alterId.ToString(),
scy = item.security,
net = item.network,
type = item.headerType,
host = item.requestHost,
path = item.path,
tls = item.streamSecurity,
sni = item.sni
};
url = Utils.ToJson(vmessQRCode);
url = Utils.Base64Encode(url);
url = string.Format("{0}{1}", Global.vmessProtocol, url);
}
else if (item.configType == (int)EConfigType.Shadowsocks)
{
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
url = string.Format("{0}:{1}@{2}:{3}",
item.security,
item.id,
item.address,
item.port);
url = Utils.Base64Encode(url);
url = string.Format("{0}{1}{2}", Global.ssProtocol, url, remark);
}
else if (item.configType == (int)EConfigType.Socks)
{
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
url = string.Format("{0}:{1}@{2}:{3}",
item.security,
item.id,
item.address,
item.port);
url = Utils.Base64Encode(url);
url = string.Format("{0}{1}{2}", Global.socksProtocol, url, remark);
}
else if (item.configType == (int)EConfigType.Trojan)
{
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
string query = string.Empty;
if (!Utils.IsNullOrEmpty(item.sni))
{
query = string.Format("?sni={0}", Utils.UrlEncode(item.sni));
}
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = string.Format("{0}{1}{2}{3}", Global.trojanProtocol, url, query, remark);
}
else if (item.configType == (int)EConfigType.VLESS)
{
string remark = string.Empty;
if (!Utils.IsNullOrEmpty(item.remarks))
{
remark = "#" + Utils.UrlEncode(item.remarks);
}
var dicQuery = new Dictionary<string, string>();
if (!Utils.IsNullOrEmpty(item.flow))
{
dicQuery.Add("flow", item.flow);
}
if (!Utils.IsNullOrEmpty(item.security))
{
dicQuery.Add("encryption", item.security);
}
else
{
dicQuery.Add("encryption", "none");
}
if (!Utils.IsNullOrEmpty(item.streamSecurity))
{
dicQuery.Add("security", item.streamSecurity);
}
else
{
dicQuery.Add("security", "none");
}
if (!Utils.IsNullOrEmpty(item.sni))
{
dicQuery.Add("sni", item.sni);
}
if (!Utils.IsNullOrEmpty(item.network))
{
dicQuery.Add("type", item.network);
}
else
{
dicQuery.Add("type", "tcp");
}
switch (item.network)
{
case "tcp":
if (!Utils.IsNullOrEmpty(item.headerType))
{
dicQuery.Add("headerType", item.headerType);
}
else
{
dicQuery.Add("headerType", "none");
}
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
break;
case "kcp":
if (!Utils.IsNullOrEmpty(item.headerType))
{
dicQuery.Add("headerType", item.headerType);
}
else
{
dicQuery.Add("headerType", "none");
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("seed", Utils.UrlEncode(item.path));
}
break;
case "ws":
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("path", Utils.UrlEncode(item.path));
}
break;
case "http":
case "h2":
dicQuery["type"] = "http";
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
}
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("path", Utils.UrlEncode(item.path));
}
break;
case "quic":
if (!Utils.IsNullOrEmpty(item.headerType))
{
dicQuery.Add("headerType", item.headerType);
}
else
{
dicQuery.Add("headerType", "none");
}
dicQuery.Add("quicSecurity", Utils.UrlEncode(item.requestHost));
dicQuery.Add("key", Utils.UrlEncode(item.path));
break;
case "grpc":
if (!Utils.IsNullOrEmpty(item.path))
{
dicQuery.Add("serviceName", Utils.UrlEncode(item.path));
if (item.headerType == Global.GrpcgunMode || item.headerType == Global.GrpcmultiMode)
{
dicQuery.Add("mode", Utils.UrlEncode(item.headerType));
}
}
break;
}
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
url = string.Format("{0}@{1}:{2}",
item.id,
GetIpv6(item.address),
item.port);
url = string.Format("{0}{1}{2}{3}", Global.vlessProtocol, url, query, remark);
}
else
{
}
return url;
}
catch
{
return "";
}
}
19
View Source File : GrblCodeTranslator.cs
License : MIT License
Project Creator : 3RD-Dimension
License : MIT License
Project Creator : 3RD-Dimension
private static void LoadBuildCoads(Dictionary<string, string> dict, string path)
{
if (!File.Exists(path))
{
MainWindow.Logger.Warn("Build Code File Missing: {0}", path);
}
try
{
using (var reader = new StreamReader(path))
{
while (!reader.EndOfStream)
{
// Todo Remove Header -> First line
reader.ReadLine(); // Read and Discard Header line
var line = reader.ReadLine().Replace("\"", ""); // Remove " from each line
var values = line.Split(','); // Split into Values - values[0] Code, values[1] Desc, values [2] Enabled/Disabled
dict.Add(values[0], values[1] + " " + values[2]); // Add to BuildCodes Dictionary
}
}
}
catch (Exception ex)
{
MainWindow.Logger.Error(ex.Message);
return;
}
}
19
View Source File : SettingsWindow.xaml.cs
License : MIT License
Project Creator : 3RD-Dimension
License : MIT License
Project Creator : 3RD-Dimension
private void ComboBoxSerialPort_DropDownOpened(object sender, EventArgs e)
{
ComboBoxSerialPort.Items.Clear();
Dictionary<string, string> ports = new Dictionary<string, string>();
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_SerialPort");
foreach (ManagementObject queryObj in searcher.Get())
{
string id = queryObj["DeviceID"] as string;
string name = queryObj["Name"] as string;
ports.Add(id, name);
}
}
catch (ManagementException ex)
{
MessageBox.Show("An error occurred while querying for WMI data: " + ex.Message);
}
// fix error of some boards not being listed properly
foreach (string port in SerialPort.GetPortNames())
{
if (!ports.ContainsKey(port))
{
ports.Add(port, port);
}
}
foreach (var port in ports)
{
ComboBoxSerialPort.Items.Add(new ComboBoxItem() { Content = port.Value, Tag = port.Key });
}
}
19
View Source File : HotKeys.cs
License : MIT License
Project Creator : 3RD-Dimension
License : MIT License
Project Creator : 3RD-Dimension
public static void LoadHotKeys()
{
hotkeyCode.Clear();
hotkeyDescription.Clear();
if (!File.Exists(HotKeyFile))
{
MainWindow.Logger.Error("Hotkey file not found, going to create default");
CheckCreateFile.CreateDefaultXML();
}
XmlReader r = XmlReader.Create(HotKeyFile); // "hotkeys.xml");
while (r.Read())
{
if (!r.IsStartElement())
continue;
switch (r.Name)
{
case "Hotkeys":
// Get Hotkey Version Number, used for modifying or updating to newer hotkey files (ie if new features are added)
if (r["HotkeyFileVer"].Length > 0)
{
CurrentHotKeyFileVersion = Convert.ToInt32(r["HotkeyFileVer"]); // Current Hotkey File Version
}
break;
case "bind":
if ((r["keyfunction"].Length > 0) && (r["keycode"] != null))
{
if (!hotkeyCode.ContainsKey(r["keyfunction"]))
hotkeyCode.Add(r["keyfunction"], r["keycode"]);
hotkeyDescription.Add(r["keyfunction"], r["key_description"]);
}
break;
}
}
r.Close();
// Check if CurrentFileVersion and NewFileVersion is different and if so, Update the file then reload by running ths process again.
MainWindow.Logger.Info("Hotkey file found, checking if needing update/modification");
if (CurrentHotKeyFileVersion < CheckCreateFile.HotKeyFileVer) // If CurrentHotKeyFileVersion does not equal HotKeyFileVer then update is required
{
CheckCreateFile.CheckAndUpdateXMLFile(CurrentHotKeyFileVersion);
}
}
19
View Source File : DefatultAlipayHelper.cs
License : MIT License
Project Creator : 52ABP
License : MIT License
Project Creator : 52ABP
private Dictionary<string, string> GetRequestGet(HttpRequest request)
{
Dictionary<string, string> sArray = new Dictionary<string, string>();
ICollection<string> requesreplacedem = request.Query.Keys;
foreach (var item in requesreplacedem)
{
sArray.Add(item, request.Query[item]);
}
return sArray;
}
19
View Source File : DefatultAlipayHelper.cs
License : MIT License
Project Creator : 52ABP
License : MIT License
Project Creator : 52ABP
private Dictionary<string, string> GetRequestPost(HttpRequest request)
{
Dictionary<string, string> sArray = new Dictionary<string, string>();
ICollection<string> requesreplacedem = request.Form.Keys;
foreach (var item in requesreplacedem)
{
sArray.Add(item, request.Form[item]);
}
return sArray;
}
19
View Source File : ResourceRepository.cs
License : MIT License
Project Creator : 99x
License : MIT License
Project Creator : 99x
private PathExecutionParams GetExecutionParams(string method, string reqUrl)
{
PathExecutionParams executionParams = null;
bool isFound = false;
Dictionary<string, string> variables = null;
PathExecutionInfo executionInfo = null;
string[] urlSplit = reqUrl.Split('/');
if (pathExecutionInfo.ContainsKey(method))
{
variables = new Dictionary<string, string>();
foreach (KeyValuePair<string, PathExecutionInfo> onePath in pathExecutionInfo[method])
{
string[] definedPathSplit = onePath.Key.Split('/');
if (definedPathSplit.Length == urlSplit.Length)
{
variables.Clear();
isFound = true;
for (int i = 0; i < definedPathSplit.Length; i++)
{
if (definedPathSplit[i].StartsWith("@"))
variables.Add(definedPathSplit[i].Substring(1), urlSplit[i]);
else
{
if (definedPathSplit[i] != urlSplit[i])
{
isFound = false;
break;
}
}
}
}
if (isFound)
{
executionInfo = onePath.Value;
break;
}
}
}
if (isFound)
{
executionParams = new PathExecutionParams
{
ExecutionInfo = executionInfo,
Parameters = variables
};
}
return executionParams;
}
19
View Source File : DynamicCharacterSystem.cs
License : Apache License 2.0
Project Creator : A7ocin
License : Apache License 2.0
Project Creator : A7ocin
private void AddCharacterRecipes(Textreplacedet[] characterRecipes)
{
foreach (Textreplacedet characterRecipe in characterRecipes)
{
if (!CharacterRecipes.ContainsKey(characterRecipe.name))
CharacterRecipes.Add(characterRecipe.name, characterRecipe.text);
else
CharacterRecipes[characterRecipe.name] = characterRecipe.text;
}
//This doesn't actually seem to do anything apart from slow things down- maybe we can hook into the UMAGarbage collection rate and do this at the same time? Or just after?
//StartCoroutine(CleanFilesFromResourcesAndBundles());
}
19
View Source File : AssetBundleManager.cs
License : Apache License 2.0
Project Creator : A7ocin
License : Apache License 2.0
Project Creator : A7ocin
void ProcessFinishedOperation(replacedetBundleLoadOperation operation)
{
replacedetBundleDownloadOperation download = operation as replacedetBundleDownloadOperation;
if (download == null)
return;
if (String.IsNullOrEmpty(download.error))
{
//Debug.Log("[replacedetBundleManager] processed downloaded bundle " + download.replacedetBundleName);
m_LoadedreplacedetBundles.Add(download.replacedetBundleName, download.replacedetBundle);
}
else
{
string msg = string.Format("Failed downloading bundle {0} from {1}: {2}",
download.replacedetBundleName, download.GetSourceURL(), download.error);
m_DownloadingErrors.Add(download.replacedetBundleName, msg);
}
m_DownloadingBundles.Remove(download.replacedetBundleName);
}
19
View Source File : BitstampApi.cs
License : MIT License
Project Creator : aabiryukov
License : MIT License
Project Creator : aabiryukov
private string Query(string operation, NameValueDictionary args = null)
{
if(args == null)
args = new NameValueDictionary();
lock (m_nonceLock)
{
var nonce = GetNonce();
var signature = GetSignature(nonce);
args.Add("key", m_key);
args.Add("signature", signature);
args.Add("nonce", nonce.ToString(CultureInfo.InvariantCulture));
var path = new Uri("https://www.bitstamp.net/api/" + operation + "/");
var httpContent = new FormUrlEncodedContent(args);
var response = WebApi.Client.PostAsync(path, httpContent).Result;
var resultString = response.Content.ReadreplacedtringAsync().Result;
return resultString;
}
}
19
View Source File : WexApi.cs
License : MIT License
Project Creator : aabiryukov
License : MIT License
Project Creator : aabiryukov
public TransHistory GetTransHistory(
int? from = null,
int? count = null,
int? fromId = null,
int? endId = null,
bool? orderAsc = null,
DateTime? since = null,
DateTime? end = null
)
{
var args = new NameValueDictionary();
if (from != null) args.Add("from", from.Value.ToString(CultureInfo.InvariantCulture));
if (count != null) args.Add("count", count.Value.ToString(CultureInfo.InvariantCulture));
if (fromId != null) args.Add("from_id", fromId.Value.ToString(CultureInfo.InvariantCulture));
if (endId != null) args.Add("end_id", endId.Value.ToString(CultureInfo.InvariantCulture));
if (orderAsc != null) args.Add("order", orderAsc.Value ? "ASC" : "DESC");
if (since != null) args.Add("since", UnixTime.GetFromDateTime(since.Value).ToString(CultureInfo.InvariantCulture));
if (end != null) args.Add("end", UnixTime.GetFromDateTime(end.Value).ToString(CultureInfo.InvariantCulture));
var json = Query("TransHistory", args);
var result = DeserializeBtceObject<TransHistory>(json);
return result;
}
19
View Source File : WexApi.cs
License : MIT License
Project Creator : aabiryukov
License : MIT License
Project Creator : aabiryukov
public TransHistory GetTransHistory(
int? from = null,
int? count = null,
int? fromId = null,
int? endId = null,
bool? orderAsc = null,
DateTime? since = null,
DateTime? end = null
)
{
var args = new NameValueDictionary();
if (from != null) args.Add("from", from.Value.ToString(CultureInfo.InvariantCulture));
if (count != null) args.Add("count", count.Value.ToString(CultureInfo.InvariantCulture));
if (fromId != null) args.Add("from_id", fromId.Value.ToString(CultureInfo.InvariantCulture));
if (endId != null) args.Add("end_id", endId.Value.ToString(CultureInfo.InvariantCulture));
if (orderAsc != null) args.Add("order", orderAsc.Value ? "ASC" : "DESC");
if (since != null) args.Add("since", UnixTime.GetFromDateTime(since.Value).ToString(CultureInfo.InvariantCulture));
if (end != null) args.Add("end", UnixTime.GetFromDateTime(end.Value).ToString(CultureInfo.InvariantCulture));
var json = Query("TransHistory", args);
var result = DeserializeBtceObject<TransHistory>(json);
return result;
}
19
View Source File : WexApi.cs
License : MIT License
Project Creator : aabiryukov
License : MIT License
Project Creator : aabiryukov
public TradeHistory GetTradeHistory(
int? from = null,
int? count = null,
int? fromId = null,
int? endId = null,
bool? orderAsc = null,
DateTime? since = null,
DateTime? end = null
)
{
var args = new NameValueDictionary();
if (from != null) args.Add("from", from.Value.ToString(CultureInfo.InvariantCulture));
if (count != null) args.Add("count", count.Value.ToString(CultureInfo.InvariantCulture));
if (fromId != null) args.Add("from_id", fromId.Value.ToString(CultureInfo.InvariantCulture));
if (endId != null) args.Add("end_id", endId.Value.ToString(CultureInfo.InvariantCulture));
if (orderAsc != null) args.Add("order", orderAsc.Value ? "ASC" : "DESC");
if (since != null) args.Add("since", UnixTime.GetFromDateTime(since.Value).ToString(CultureInfo.InvariantCulture));
if (end != null) args.Add("end", UnixTime.GetFromDateTime(end.Value).ToString(CultureInfo.InvariantCulture));
var json = Query("TradeHistory", args);
var result = DeserializeBtceObject<TradeHistory>(json);
return result;
}
19
View Source File : WexApi.cs
License : MIT License
Project Creator : aabiryukov
License : MIT License
Project Creator : aabiryukov
public TradeHistory GetTradeHistory(
int? from = null,
int? count = null,
int? fromId = null,
int? endId = null,
bool? orderAsc = null,
DateTime? since = null,
DateTime? end = null
)
{
var args = new NameValueDictionary();
if (from != null) args.Add("from", from.Value.ToString(CultureInfo.InvariantCulture));
if (count != null) args.Add("count", count.Value.ToString(CultureInfo.InvariantCulture));
if (fromId != null) args.Add("from_id", fromId.Value.ToString(CultureInfo.InvariantCulture));
if (endId != null) args.Add("end_id", endId.Value.ToString(CultureInfo.InvariantCulture));
if (orderAsc != null) args.Add("order", orderAsc.Value ? "ASC" : "DESC");
if (since != null) args.Add("since", UnixTime.GetFromDateTime(since.Value).ToString(CultureInfo.InvariantCulture));
if (end != null) args.Add("end", UnixTime.GetFromDateTime(end.Value).ToString(CultureInfo.InvariantCulture));
var json = Query("TradeHistory", args);
var result = DeserializeBtceObject<TradeHistory>(json);
return result;
}
19
View Source File : WexApi.cs
License : MIT License
Project Creator : aabiryukov
License : MIT License
Project Creator : aabiryukov
public OrderList ActiveOrders(WexPair? pair = null)
{
var args = new NameValueDictionary();
if (pair != null)
args.Add("pair", WexPairHelper.ToString(pair.Value));
var json = Query("ActiveOrders", args);
if (json.Contains("\"no orders\""))
{
return new OrderList();
}
var result = DeserializeBtceObject<OrderList>(json);
return result;
}
19
View Source File : WexApi.cs
License : MIT License
Project Creator : aabiryukov
License : MIT License
Project Creator : aabiryukov
private string InternalQuery(NameValueDictionary args)
{
lock (m_nonceLock)
{
args.Add("nonce", GetNonce().ToString(CultureInfo.InvariantCulture));
var dataStr = BuildPostData(args);
var data = Encoding.ASCII.GetBytes(dataStr);
using (var httpContent = new FormUrlEncodedContent(args))
{
using (var request = new HttpRequestMessage(HttpMethod.Post, WebApi.RootUrl + "/tapi"))
{
request.Headers.Add("Key", m_key);
request.Headers.Add("Sign", ByteArrayToString(m_hashMaker.ComputeHash(data)).ToLowerInvariant());
request.Content = httpContent;
var response = WebApi.Client.SendAsync(request).Result;
var resultString = response.Content.ReadreplacedtringAsync().Result;
return resultString;
}
}
}
}
19
View Source File : CsharpMemberProvider.cs
License : MIT License
Project Creator : Abc-Arbitrage
License : MIT License
Project Creator : Abc-Arbitrage
public Dictionary<string, string> GetClreplacedFields(IClreplacedBody clreplacedBody, PsiLanguageType languageType)
{
var dic = new Dictionary<string, string>();
var fields = clreplacedBody.FieldDeclarations.Select(x => x.TypeUsage.FirstChild as IReferenceName).Where(x => x != null && x.ShortName == "Mock").ToArray();
foreach (var referenceName in fields)
{
var types = referenceName.TypeArguments.Select(x => x.GetPresentableName(languageType, DeclaredElementPresenterTextStyles.Empty).Text);
var strType = string.Join(",", types);
var mockType = GetGenericMock(strType);
var field = (IFieldDeclaration)referenceName.Parent.NextSibling.NextSibling;
if (!dic.ContainsKey(mockType))
dic.Add(mockType, field.DeclaredName);
}
return dic;
}
19
View Source File : TokenController.cs
License : MIT License
Project Creator : Abdulrhman5
License : MIT License
Project Creator : Abdulrhman5
[HttpPost]
[Route("token")]
public async Task<IActionResult> Token([FromBody]LoginDto loginDto)
{
HttpClient client = new HttpClient();
var clientId = _configuration["IdenreplacedyServerConfigs:client_id"];
var clientSecret = _configuration["IdenreplacedyServerConfigs:client_secret"];
var accessTokenUrl = _configuration["IdenreplacedyServerConfigs:AccessTokenUrl"];
var dic = new Dictionary<string, string>();
dic.Add("client_id", clientId);
dic.Add("client_secret", clientSecret);
if (loginDto != null)
{
dic.Add("grant_type", loginDto.grant_type);
dic.Add("username", loginDto.username);
dic.Add("preplacedword", loginDto.preplacedword);
}
var request = new HttpRequestMessage(HttpMethod.Post, accessTokenUrl)
{
Content = new FormUrlEncodedContent(dic)
};
try
{
var response = await client.SendAsync(request);
await _responseMessageConverter.ConvertAndCopyResponse(HttpContext, response);
return new EmptyResult();
}
catch
{
var message = new ErrorMessage
{
ErrorCode = "ACCESS.TOKEN.INTERNAL.ERROR",
Message = "there were an error while trying to create access token"
};
return StatusCode(500, message);
}
}
19
View Source File : TokenController.cs
License : MIT License
Project Creator : Abdulrhman5
License : MIT License
Project Creator : Abdulrhman5
[HttpPost]
[Route("token")]
public async Task<IActionResult> Token([FromBody]LoginDto loginDto)
{
HttpClient client = new HttpClient();
var clientId = _configuration["IdenreplacedyServerConfigs:client_id"];
var clientSecret = _configuration["IdenreplacedyServerConfigs:client_secret"];
var accessTokenUrl = _configuration["Services:Authorization"] +"/connect/token";
var dic = new Dictionary<string, string>();
dic.Add("client_id", clientId);
dic.Add("client_secret", clientSecret);
if (loginDto != null)
{
dic.Add("grant_type", loginDto.grant_type);
dic.Add("username", loginDto.username);
dic.Add("preplacedword", loginDto.preplacedword);
dic.Add("loginInfo", loginDto.LoginInfo);
}
var request = new HttpRequestMessage(HttpMethod.Post, accessTokenUrl)
{
Content = new FormUrlEncodedContent(dic)
};
try
{
var response = await client.SendAsync(request);
await _responseMessageConverter.ConvertAndCopyResponse(HttpContext, response);
return new EmptyResult();
}
catch(Exception e)
{
var message = new ErrorMessage
{
ErrorCode = "ACCESS.TOKEN.INTERNAL.ERROR",
Message = "there were an error while trying to create access token"
};
return StatusCode(500, message);
}
}
19
View Source File : GltfUtility.cs
License : Apache License 2.0
Project Creator : abist-co-ltd
License : Apache License 2.0
Project Creator : abist-co-ltd
private static Dictionary<string, string> GetGltfExtensions(string jsonString, Regex regex)
{
var jsonObjects = new Dictionary<string, string>();
if (!regex.IsMatch(jsonString))
{
return jsonObjects;
}
var matches = regex.Matches(jsonString);
var nodeName = string.Empty;
for (var i = 0; i < matches.Count; i++)
{
for (int j = 0; j < matches[i].Groups.Count; j++)
{
for (int k = 0; k < matches[i].Groups[i].Captures.Count; k++)
{
nodeName = GetGltfNodeName(matches[i].Groups[i].Captures[i].Value);
}
}
if (!jsonObjects.ContainsKey(nodeName))
{
jsonObjects.Add(nodeName, GetJsonObject(jsonString, matches[i].Index + matches[i].Length));
}
}
return jsonObjects;
}
19
View Source File : DataEntry.cs
License : MIT License
Project Creator : absurd-joy
License : MIT License
Project Creator : absurd-joy
void updateRoomDataStore(string roomID, string key, string value)
{
Dictionary<string, string> kvPairs = new Dictionary<string, string>();
kvPairs.Add(key, value);
printOutputLine("Trying to set k=" + key + " v=" + value + " for room " + roomID);
Rooms.UpdateDataStore(Convert.ToUInt64(roomID), kvPairs).OnComplete(getCurrentRoomCallback);
}
19
View Source File : ExampleManager.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public static IDictionary<string, string> GetAllExampleDefinitions()
{
var dictionary = new Dictionary<string, string>();
var replacedembly = typeof(ExampleManager).replacedembly;
var exampleNames = replacedembly.GetManifestResourceNames().Where(x => x.Contains("ExampleSourceFiles")).ToList();
exampleNames.Sort();
foreach (var example in exampleNames)
{
using (var s = replacedembly.GetManifestResourceStream(example))
using (var sr = new StreamReader(s))
{
dictionary.Add(example.Replace("SciChart.Example.Resources.ExampleDefinitions.", string.Empty),
sr.ReadToEnd());
}
}
return dictionary;
}
19
View Source File : ProjectWriter.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public static string WriteProject(Example example, string selectedPath, string replacedembliesPath, bool showMessageBox = true)
{
var files = new Dictionary<string, string>();
var replacedembly = typeof(ProjectWriter).replacedembly;
var names = replacedembly.GetManifestResourceNames();
var templateFiles = names.Where(x => x.Contains("Templates")).ToList();
foreach (var templateFile in templateFiles)
{
var fileName = GetFileNameFromNs(templateFile);
using (var s = replacedembly.GetManifestResourceStream(templateFile))
{
if (s == null) break;
using (var sr = new StreamReader(s))
{
files.Add(fileName, sr.ReadToEnd());
}
}
}
string projectName = "SciChart_" + Regex.Replace(example.replacedle, @"[^A-Za-z0-9]+", string.Empty);
files[ProjectFileName] = GenerateProjectFile(files[ProjectFileName], example, replacedembliesPath);
files[SolutionFileName] = GenerateSolutionFile(files[SolutionFileName], projectName);
files.RenameKey(ProjectFileName, projectName + ".csproj");
files.RenameKey(SolutionFileName, projectName + ".sln");
files[MainWindowFileName] = GenerateShellFile(files[MainWindowFileName], example).Replace("[Examplereplacedle]", example.replacedle);
foreach (var codeFile in example.SourceFiles)
{
files.Add(codeFile.Key, codeFile.Value);
}
WriteProjectFiles(files, Path.Combine(selectedPath, projectName));
if (showMessageBox && Application.Current.MainWindow != null)
{
var message = $"The {example.replacedle} example was successfully exported to {selectedPath + projectName}";
MessageBox.Show(Application.Current.MainWindow, message, "Success!");
}
return projectName;
}
19
View Source File : ProjectWriter.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public static string WriteProject(Example example, string selectedPath, string replacedembliesPath, bool showMessageBox = true)
{
var files = new Dictionary<string, string>();
var replacedembly = typeof(ProjectWriter).replacedembly;
var names = replacedembly.GetManifestResourceNames();
var templateFiles = names.Where(x => x.Contains("Templates")).ToList();
foreach (var templateFile in templateFiles)
{
var fileName = GetFileNameFromNs(templateFile);
using (var s = replacedembly.GetManifestResourceStream(templateFile))
{
if (s == null) break;
using (var sr = new StreamReader(s))
{
files.Add(fileName, sr.ReadToEnd());
}
}
}
string projectName = "SciChart_" + Regex.Replace(example.replacedle, @"[^A-Za-z0-9]+", string.Empty);
files[ProjectFileName] = GenerateProjectFile(files[ProjectFileName], example, replacedembliesPath);
files[SolutionFileName] = GenerateSolutionFile(files[SolutionFileName], projectName);
files.RenameKey(ProjectFileName, projectName + ".csproj");
files.RenameKey(SolutionFileName, projectName + ".sln");
files[MainWindowFileName] = GenerateShellFile(files[MainWindowFileName], example).Replace("[Examplereplacedle]", example.replacedle);
foreach (var codeFile in example.SourceFiles)
{
files.Add(codeFile.Key, codeFile.Value);
}
WriteProjectFiles(files, Path.Combine(selectedPath, projectName));
if (showMessageBox && Application.Current.MainWindow != null)
{
var message = $"The {example.replacedle} example was successfully exported to {selectedPath + projectName}";
MessageBox.Show(Application.Current.MainWindow, message, "Success!");
}
return projectName;
}
19
View Source File : ACBrConsultaCPF.cs
License : MIT License
Project Creator : ACBrNet
License : MIT License
Project Creator : ACBrNet
public ACBrPessoa Consulta(string cpf, DateTime dataNascimento, string captcha = "")
{
Guard.Against<ACBrException>(cpf.IsEmpty(), "Necess�rio informar o CPF.");
Guard.Against<ACBrException>(dataNascimento == DateTime.MinValue, "Necess�rio informar a data de nascimento.");
Guard.Against<ACBrException>(!cpf.IsCPF(), "CPF inv�lido.");
if (captcha.IsEmpty() && OnGetCaptcha != null)
{
var e = new CaptchaEventArgs();
OnGetCaptcha.Raise(this, e);
captcha = e.Captcha;
}
Guard.Against<ACBrException>(captcha.IsEmpty(), "Necess�rio digitar o captcha.");
var request = GetClient(urlBaseReceitaFederal + paginaValidacao);
request.KeepAlive = false;
var postData = new Dictionary<string, string>();
postData.Add("TxtCPF", cpf.FormataCPF());
postData.Add("txtDataNascimento", dataNascimento.ToShortDateString());
postData.Add("txtToken_captcha_serpro_gov_br", "");
postData.Add("txtTexto_captcha_serpro_gov_br", captcha);
postData.Add("Enviar", "Consultar");
var retorno = request.SendPost(postData, Encoding.UTF8);
Guard.Against<ACBrCaptchaException>(retorno.Contains("Os caracteres da imagem n�o foram preenchidos corretamente."), "Os caracteres da imagem n�o foram preenchidos corretamente.");
Guard.Against<ACBrException>(retorno.Contains("O n�mero do CPF n�o � v�lido."), "EO n�mero do CPF n�o � v�lido. Verifique se o mesmo foi digitado corretamente.");
Guard.Against<ACBrException>(retorno.Contains("N�o existe no Cadastro de Pessoas Jur�dicas o n�mero de CPF informado."), $"N�o existe no Cadastro de Pessoas Jur�dicas o n�mero de CPF informado.{Environment.NewLine}Verifique se o mesmo foi digitado corretamente.");
Guard.Against<ACBrException>(retorno.Contains("a. No momento n�o podemos atender a sua solicita��o. Por favor tente mais tarde."), "Erro no site da receita federal. Tente mais tarde.");
return new ACBrPessoa(retorno);
}
19
View Source File : ConsultaSintegraDF.cs
License : MIT License
Project Creator : ACBrNet
License : MIT License
Project Creator : ACBrNet
public override ACBrEmpresa Consulta(string cnpj, string ie, string captcha)
{
var request = GetClient(URL_CONSULTA);
request.Referer = URL_REFERER1;
var postData = new Dictionary<string, string>
{
{ "sefp", "1" },
{ "estado", "DF" }
};
if (cnpj.IsEmpty())
{
postData.Add("identificador", "3");
postData.Add("argumento", ie);
}
else
{
postData.Add("identificador", "2");
postData.Add("argumento", cnpj);
}
var retorno = request.SendPost(postData, Encoding.UTF8);
var dadosRetorno = new List<string>();
dadosRetorno.AddText(WebUtility.HtmlDecode(retorno.StripHtml().Replace(" ", Environment.NewLine)));
dadosRetorno.RemoveEmptyLines();
var cfdf = LerCampo(dadosRetorno, "SITUAÇÃO");
if (cfdf != string.Empty)
{
request = GetClient(URL_CONSULTA_DET);
request.Referer = URL_CONSULTA;
postData.Clear();
postData.Add("cCFDF", cfdf);
retorno = request.SendPost(postData, Encoding.UTF8);
}
Guard.Against<ACBrException>(retorno.Contains("Nenhum resultado encontrado"), $"Não existe no Cadastro do sintegra o número de CNPJ/IE informado.{Environment.NewLine}Verifique se o mesmo foi digitado corretamente.");
Guard.Against<ACBrException>(retorno.Contains("a. No momento não podemos atender a sua solicitação. Por favor tente mais tarde."), "Erro no site do sintegra. Tente mais tarde.");
Guard.Against<ACBrException>(retorno.Contains("Atenção"), "Erro ao fazer a consulta");
return ProcessResponse(retorno);
}
19
View Source File : ConsultaSintegraGO.cs
License : MIT License
Project Creator : ACBrNet
License : MIT License
Project Creator : ACBrNet
public override ACBrEmpresa Consulta(string cnpj, string ie, string captcha)
{
var request = GetClient(URL_CONSULTA);
var postData = new Dictionary<string, string>();
if (cnpj.IsEmpty())
{
postData.Add("rTipoDoc", "1");
postData.Add("tDoc", ie.Replace(",", "."));
postData.Add("tCCE", ie.Replace(",", "."));
postData.Add("tCNPJ", "&tCPF=&btCGC=Consultar&zion.SystemAction=consultarSintegra%28%29&zion.OnSubmited=&zion.FormElementPosted=zionFormID_1&zionPostMethod=&zionRichValidator=true");
}
else
{
postData.Add("rTipoDoc", "2");
postData.Add("tDoc=", cnpj.Replace(",", "."));
postData.Add("tCCE=&tCNPJ", cnpj.Replace(",", "."));
postData.Add("tCPF", "&btCGC=Consultar&zion.SystemAction=consultarSintegra%28%29&zion.OnSubmited=&zion.FormElementPosted=zionFormID_1&zionPostMethod=&zionRichValidator=true");
}
var retorno = request.SendPost(postData);
Guard.Against<ACBrException>(retorno.Contains("Nenhum resultado encontrado"), $"Não existe no Cadastro do sintegra o número de CNPJ/IE informado.{Environment.NewLine}Verifique se o mesmo foi digitado corretamente.");
Guard.Against<ACBrException>(retorno.Contains("a. No momento não podemos atender a sua solicitação. Por favor tente mais tarde."), "Erro no site do sintegra. Tente mais tarde.");
Guard.Against<ACBrException>(retorno.Contains("Atenção"), "Erro ao fazer a consulta");
return ProcessResponse(retorno);
}
19
View Source File : ConsultaSintegraMT.cs
License : MIT License
Project Creator : ACBrNet
License : MIT License
Project Creator : ACBrNet
public override ACBrEmpresa Consulta(string cnpj, string ie, string captcha)
{
var request = GetClient(URL_CONSULTA);
var postData = new Dictionary<string, string>();
if (!cnpj.IsEmpty())
{
postData.Add("opcao", "2");
postData.Add("numero", cnpj.OnlyNumbers());
}
else
{
postData.Add("opcao", "1");
postData.Add("numero", ie.OnlyNumbers());
}
postData.Add("captchaDigitado", captcha);
postData.Add("pagn", "resultado");
postData.Add("captcha", "telaComCaptcha");
var retorno = request.SendPost(postData);
Guard.Against<ACBrCaptchaException>(retorno.Contains("C�digo de caracteres inv�lido!"), "O Texto digitado n�o confere com a Imagem.");
Guard.Against<ACBrException>(retorno.Contains("Nenhum resultado encontrado"), $"N�o existe no Cadastro do sintegra o n�mero de CNPJ/IE informado.{Environment.NewLine}Verifique se o mesmo foi digitado corretamente.");
Guard.Against<ACBrException>(retorno.Contains("a. No momento n�o podemos atender a sua solicita��o. Por favor tente mais tarde."), "Erro no site do sintegra. Tente mais tarde.");
Guard.Against<ACBrException>(retorno.Contains("Aten��o"), "Erro ao fazer a consulta");
return ProcessResponse(retorno);
}
19
View Source File : ConsultaSintegraSP.cs
License : MIT License
Project Creator : ACBrNet
License : MIT License
Project Creator : ACBrNet
public override ACBrEmpresa Consulta(string cnpj, string ie, string captcha)
{
var request = GetClient(URL_CONSULTA);
var postData = new Dictionary<string, string>(urlParams);
if (cnpj.IsEmpty())
{
postData.Add("servico", "ie");
postData.Add("Key", captcha);
postData.Add("cnpj", "");
postData.Add("ie", ie.IsEmpty() ? string.Empty : ie.OnlyNumbers());
postData.Add("botao", "Consulta+por+IE");
}
else
{
postData.Add("servico", "cnpj");
postData.Add("Key", captcha);
postData.Add("cnpj", cnpj.IsEmpty() ? string.Empty : cnpj.OnlyNumbers());
postData.Add("botao", "Consulta+por+CNPJ&ie=");
}
var retorno = request.SendPost(postData);
Guard.Against<ACBrCaptchaException>(retorno.Contains("O valor da imagem esta incorreto ou expirou"), "O Texto digitado n�o confere com a Imagem.");
Guard.Against<ACBrException>(retorno.Contains("Nenhum resultado encontrado"), $"N�o existe no Cadastro do sintegra o n�mero de CNPJ/IE informado.{Environment.NewLine}Verifique se o mesmo foi digitado corretamente.");
Guard.Against<ACBrException>(retorno.Contains("Servi�o indispon�vel!"), "Site do sintegra indispon�vel. Tente mais tarde.");
Guard.Against<ACBrException>(retorno.Contains("a. No momento n�o podemos atender a sua solicita��o. Por favor tente mais tarde."), "Erro no site do sintegra. Tente mais tarde.");
Guard.Against<ACBrException>(retorno.Contains("Aten��o"), "Erro ao fazer a consulta");
return ProcessResponse(retorno);
}
19
View Source File : ArgParser.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
public TArgs Parse(string[] args)
{
var result = new TArgs();
var argDictionary = new Dictionary<string, string>();
for (int i = 0; i < args.Length; i++)
{
if (args[i].StartsWith(ArgNamePrefix))
{
argDictionary.Add(
args[i].Replace(ArgNamePrefix, string.Empty),
i + 1 < args.Length && !args[i + 1].StartsWith(ArgNamePrefix)
? args[++i]
: StringTrue);
}
}
foreach (var arg in argDictionary)
{
if (_parsers.TryGetValue(arg.Key, out var parser))
{
parser(result, arg.Value);
}
}
return result;
}
19
View Source File : ChatPoseTable.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator
public override void Unpack(BinaryReader reader)
{
Id = reader.ReadUInt32();
var totalObjects = reader.ReadUInt16();
reader.ReadUInt16(); // var bucketSize
for (int i = 0; i < totalObjects; i++)
{
string key = reader.ReadPString(); reader.AlignBoundary();
string value = reader.ReadPString(); reader.AlignBoundary();
ChatPoseHash.Add(key, value);
}
var totalEmoteObjects = reader.ReadUInt16();
reader.ReadUInt16();// var bucketSize
for (int i = 0; i < totalEmoteObjects; i++)
{
string key = reader.ReadPString(); reader.AlignBoundary();
ChatEmoteData value = new ChatEmoteData();
value.Unpack(reader);
ChatEmoteHash.Add(key, value);
}
}
19
View Source File : SpConverter.cs
License : Microsoft Public License
Project Creator : achimismaili
License : Microsoft Public License
Project Creator : achimismaili
public static Dictionary<string, string> ToProperties(this SPFeaturePropertyCollection featureProperties)
{
var properties = new Dictionary<string, string>();
foreach (SPFeatureProperty p in featureProperties)
{
properties.Add(p.Name, p.Value);
}
return properties;
}
19
View Source File : SpellChecker.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public void AddToAutoReplacementList(string word, string replacement)
{
if (autoReplacementList.ContainsKey(word)) {
return;
}
autoReplacementList.Add(word, replacement);
}
19
View Source File : Utilities.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public static Dictionary<string, string> GetFieldDelimiters()
{
var result = new Dictionary<string, string>();
result.Add("Comma", ",");
result.Add("Semi-Colon", ";");
result.Add("Tab", "\t");
result.Add("Sapce", " ");
return result;
}
19
View Source File : Utilities.cs
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
License : GNU Lesser General Public License v3.0
Project Creator : acnicholas
public static Dictionary<string, string> GetFieldTextQualifiers()
{
var result = new Dictionary<string, string>();
result.Add("Double Quote (\")", "\"");
result.Add("Quote) (\')", "\'");
result.Add("None", string.Empty);
return result;
}
19
View Source File : CommandLineParser.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public void Parse(string[] args)
{
_trace.Info(nameof(Parse));
ArgUtil.NotNull(args, nameof(args));
_trace.Info("Parsing {0} args", args.Length);
string argScope = null;
foreach (string arg in args)
{
_trace.Info("parsing argument");
HasArgs = HasArgs || arg.StartsWith("--");
_trace.Info("HasArgs: {0}", HasArgs);
if (string.Equals(arg, "/?", StringComparison.Ordinal))
{
Flags.Add("help");
}
else if (!HasArgs)
{
_trace.Info("Adding Command: {0}", arg);
Commands.Add(arg.Trim());
}
else
{
// it's either an arg, an arg value or a flag
if (arg.StartsWith("--") && arg.Length > 2)
{
string argVal = arg.Substring(2);
_trace.Info("arg: {0}", argVal);
// this means two --args in a row which means previous was a flag
if (argScope != null)
{
_trace.Info("Adding flag: {0}", argScope);
Flags.Add(argScope.Trim());
}
argScope = argVal;
}
else if (!arg.StartsWith("-"))
{
// we found a value - check if we're in scope of an arg
if (argScope != null && !Args.ContainsKey(argScope = argScope.Trim()))
{
if (SecretArgNames.Contains(argScope))
{
_secretMasker.AddValue(arg);
}
_trace.Info("Adding option '{0}': '{1}'", argScope, arg);
// ignore duplicates - first wins - below will be val1
// --arg1 val1 --arg1 val1
Args.Add(argScope, arg);
argScope = null;
}
}
else
{
//
// ignoring the second value for an arg (val2 below)
// --arg val1 val2
// ignoring invalid things like empty - and --
// --arg val1 -- --flag
_trace.Info("Ignoring arg");
}
}
}
_trace.Verbose("done parsing arguments");
// handle last arg being a flag
if (argScope != null)
{
Flags.Add(argScope);
}
_trace.Verbose("Exiting parse");
}
19
View Source File : PublishArtifact.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
public async Task RunAsync(
RunnerActionPluginExecutionContext context,
CancellationToken token)
{
string artifactName = context.GetInput(PublishArtifactInputNames.ArtifactName, required: false); // Back compat since we rename input `artifactName` to `name`
if (string.IsNullOrEmpty(artifactName))
{
artifactName = context.GetInput(PublishArtifactInputNames.Name, required: true);
}
string targetPath = context.GetInput(PublishArtifactInputNames.Path, required: true);
string defaultWorkingDirectory = context.GetGitHubContext("workspace");
targetPath = Path.IsPathFullyQualified(targetPath) ? targetPath : Path.GetFullPath(Path.Combine(defaultWorkingDirectory, targetPath));
if (String.IsNullOrWhiteSpace(artifactName))
{
throw new ArgumentException($"Artifact name can not be empty string");
}
if (Path.GetInvalidFileNameChars().Any(x => artifactName.Contains(x)))
{
throw new ArgumentException($"Artifact name is not valid: {artifactName}. It cannot contain '\\', '/', \"', ':', '<', '>', '|', '*', and '?'");
}
// Build ID
string buildIdStr = context.Variables.GetValueOrDefault(SdkConstants.Variables.Build.BuildId)?.Value ?? string.Empty;
if (!int.TryParse(buildIdStr, out int buildId))
{
throw new ArgumentException($"Run Id is not an Int32: {buildIdStr}");
}
string fullPath = Path.GetFullPath(targetPath);
bool isFile = File.Exists(fullPath);
bool isDir = Directory.Exists(fullPath);
if (!isFile && !isDir)
{
// if local path is neither file nor folder
throw new FileNotFoundException($"Path does not exist {targetPath}");
}
// Container ID
string containerIdStr = context.Variables.GetValueOrDefault(SdkConstants.Variables.Build.ContainerId)?.Value ?? string.Empty;
if (!long.TryParse(containerIdStr, out long containerId))
{
throw new ArgumentException($"Container Id is not an Int64: {containerIdStr}");
}
context.Output($"Uploading artifact '{artifactName}' from '{fullPath}' for run #{buildId}");
FileContainerServer fileContainerHelper = new FileContainerServer(context.VssConnection, projectId: Guid.Empty, containerId, artifactName);
var propertiesDictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
long size = 0;
try
{
size = await fileContainerHelper.CopyToContainerAsync(context, fullPath, token);
propertiesDictionary.Add("artifactsize", size.ToString());
context.Output($"Uploaded '{size}' bytes from '{fullPath}' to server");
}
// if any of the results were successful, make sure to attach them to the build
finally
{
// Definition ID is a dummy value only used by HTTP client routing purposes
int definitionId = 1;
PipelinesServer pipelinesHelper = new PipelinesServer(context.VssConnection);
var artifact = await pipelinesHelper.replacedociateActionsStorageArtifactAsync(
definitionId,
buildId,
containerId,
artifactName,
size,
token);
context.Output($"replacedociated artifact {artifactName} ({artifact.ContainerId}) with run #{buildId}");
}
}
19
View Source File : PipelineTemplateConverter.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
internal static JobContainer ConvertToJobContainer(
TemplateContext context,
TemplateToken value,
bool allowExpressions = false)
{
var result = new JobContainer();
if (allowExpressions && value.Traverse().Any(x => x is ExpressionToken))
{
return result;
}
if (value is StringToken containerLiteral)
{
if (String.IsNullOrEmpty(containerLiteral.Value))
{
return null;
}
result.Image = containerLiteral.Value;
}
else
{
var containerMapping = value.replacedertMapping($"{PipelineTemplateConstants.Container}");
foreach (var containerPropertyPair in containerMapping)
{
var propertyName = containerPropertyPair.Key.replacedertString($"{PipelineTemplateConstants.Container} key");
switch (propertyName.Value)
{
case PipelineTemplateConstants.Image:
result.Image = containerPropertyPair.Value.replacedertString($"{PipelineTemplateConstants.Container} {propertyName}").Value;
break;
case PipelineTemplateConstants.Env:
var env = containerPropertyPair.Value.replacedertMapping($"{PipelineTemplateConstants.Container} {propertyName}");
var envDict = new Dictionary<String, String>(env.Count);
foreach (var envPair in env)
{
var envKey = envPair.Key.ToString();
var envValue = envPair.Value.replacedertString($"{PipelineTemplateConstants.Container} {propertyName} {envPair.Key.ToString()}").Value;
envDict.Add(envKey, envValue);
}
result.Environment = envDict;
break;
case PipelineTemplateConstants.Options:
result.Options = containerPropertyPair.Value.replacedertString($"{PipelineTemplateConstants.Container} {propertyName}").Value;
break;
case PipelineTemplateConstants.Ports:
var ports = containerPropertyPair.Value.replacedertSequence($"{PipelineTemplateConstants.Container} {propertyName}");
var portList = new List<String>(ports.Count);
foreach (var porreplacedem in ports)
{
var portString = porreplacedem.replacedertString($"{PipelineTemplateConstants.Container} {propertyName} {porreplacedem.ToString()}").Value;
portList.Add(portString);
}
result.Ports = portList;
break;
case PipelineTemplateConstants.Volumes:
var volumes = containerPropertyPair.Value.replacedertSequence($"{PipelineTemplateConstants.Container} {propertyName}");
var volumeList = new List<String>(volumes.Count);
foreach (var volumeItem in volumes)
{
var volumeString = volumeItem.replacedertString($"{PipelineTemplateConstants.Container} {propertyName} {volumeItem.ToString()}").Value;
volumeList.Add(volumeString);
}
result.Volumes = volumeList;
break;
case PipelineTemplateConstants.Credentials:
result.Credentials = ConvertToContainerCredentials(containerPropertyPair.Value);
break;
default:
propertyName.replacedertUnexpectedValue($"{PipelineTemplateConstants.Container} key");
break;
}
}
}
if (result.Image.StartsWith("docker://", StringComparison.Ordinal))
{
result.Image = result.Image.Substring("docker://".Length);
}
if (String.IsNullOrEmpty(result.Image))
{
context.Error(value, "Container image cannot be empty");
}
return result;
}
See More Examples