public void OnRespuesta(Socket socket, Packet packet, params object[] args)
    {
        json          js   = new json();
        List <object> list = js.Decode(packet.ToString());

        gj.escucharRespuesta(list);
    }
Beispiel #2
0
        public UserDynamic(API api, json.UserCall userCall)
        {
            this.api = api;

            if (userCall.error != 0)
            {
                return;
            }

            balances = new Dictionary<string, Balance>();
            orders = new Order[userCall.orders.Length];

            logID = userCall.logid;
            chatKey = userCall.chatkey;
            chatExpiry = Utils.UnixTimeStampToDateTime(userCall.chatexp);

            for (int i = 0; i < userCall.orders.Length; i++)
            {
                orders[i] = new Order(api, userCall.orders[i]);
            }

            for (int i = 0; i < userCall.balances.Length; i++)
            {
                balances[userCall.balances[i].tla] = new Balance(api, userCall.balances[i]);
            }
        }
		private async Task<dynamic> callApi(string method, string api, string parameters, json.Value postData = null)
		{
			HttpClient client = new HttpClient();
			client.BaseAddress = new Uri("http://192.168.2.205:5000/webapi/" + api);
			client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
			// List data response.
			HttpResponseMessage response = null;
			if (method == "POST")
			{
				Dictionary<string, string> postFields = new Dictionary<string, string>();
				foreach (var a in postData)
					postFields[a.Key] = a.Value.asString();
				response = client.PostAsync(parameters, new FormUrlEncodedContent(postFields)).Result;  // Blocking call!
																																			//response = client.PostAsync(parameters, new StringContent(postData.ToString(), Encoding.UTF8, "application/json")).Result;  // Blocking call!
			}
			else
				response = client.GetAsync(parameters).Result;  // Blocking call!
			if (response.IsSuccessStatusCode)
			{
				var data = Encoding.UTF8.GetString(await response.Content.ReadAsByteArrayAsync());
				//	Console.WriteLine("API OK: " + data);
				//return json.Value.fromString(data);
				return JsonConvert.DeserializeObject<dynamic>(data);
			}
			else
			{
				Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
			}
			return null;
		}
Beispiel #4
0
 public Currency(json.CurrencyCall.Currency jsonCurrency)
 {
     tla = jsonCurrency.tla;
     name = jsonCurrency.name;
     description = jsonCurrency.desc;
     link = jsonCurrency.link;
     decimals = jsonCurrency.decimals;
     decimalsInternal = jsonCurrency.decimals_internal;
     confirmations = jsonCurrency.confirms;
     minimumDeposit = new Amount(jsonCurrency.mindeposit, jsonCurrency.decimals_internal);
     withdrawalFee = new Amount(jsonCurrency.withdrawfee, jsonCurrency.decimals_internal);
     feesGenerated = new Amount(jsonCurrency.feesgenned, jsonCurrency.decimals_internal);
     totalDeposited = new Amount(jsonCurrency.deposited, jsonCurrency.decimals_internal);
 }
Beispiel #5
0
        public MarketPair(API api, json.MarketCall.Pair jsonMarketPair)
        {
            this.api = api;

            @base = api.GetCurrency(jsonMarketPair.@base);
            other = api.GetCurrency(jsonMarketPair.other);
            volume = new Amount(jsonMarketPair.volume, @base.DecimalsInternal);
            lastPrice = new Amount(jsonMarketPair.lastprice, @base.DecimalsInternal);
            bestAsk = new Amount(jsonMarketPair.bestask, @base.DecimalsInternal);
            bestBid = new Amount(jsonMarketPair.bestbid, @base.DecimalsInternal);
            depthAsk = new Amount(jsonMarketPair.depthask, other.DecimalsInternal);
            depthBid = new Amount(jsonMarketPair.depthbid, @base.DecimalsInternal);
            feeBase = int.Parse(jsonMarketPair.feebase, System.Globalization.NumberStyles.HexNumber) / 100;
            feeOther = int.Parse(jsonMarketPair.feeother, System.Globalization.NumberStyles.HexNumber) / 100;
            decimalsOrder = jsonMarketPair.decimals_order;
            minimumBase = new Amount(jsonMarketPair.minbase, @base.DecimalsInternal);
            minimumOther = new Amount(jsonMarketPair.minother, other.DecimalsInternal);
        }
 request.Content = new StringContent(json, Encoding.UTF8, "application/json");
Beispiel #7
0
 select (TryGetInt(json["x"], out var x) // 式の中で変数宣言できるように(宣言式)
     && TryGetInt(json["y"], out var y))
Beispiel #8
0
 select (TryGetInt(json["x"], out var x) // 式の中で変数宣言できるように(宣言式)
Beispiel #9
0
 => ValidateParams(json, ValidationMode.Required, predicates);
Beispiel #10
0
 var(json, expectedDate) = theCase;
Beispiel #11
0
            public Order(API api, json.UserCall.Order userOrder)
            {
                this.api = api;

                id = userOrder.id;
                marketPair = api.GetMarketPair(userOrder.pair);
                time = Utils.UnixTimeStampToDateTime(userOrder.time);
                amount = new Amount(userOrder.amount, api.GetCurrency(userOrder.side).DecimalsInternal);
                price = new Amount(userOrder.price, marketPair.Base.DecimalsInternal);
                bid = userOrder.side == marketPair.Base.TLA;
            }
Beispiel #12
0
            public Balance(API api, json.UserCall.Balance userBalance)
            {
                this.api = api;

                currency = api.GetCurrency(userBalance.tla);
                total = new Amount(userBalance.total, currency.DecimalsInternal);
                available = new Amount(userBalance.avail, currency.DecimalsInternal);
                address = userBalance.address;
            }
Beispiel #13
0
 internal static void CreateInterface(string Directory, string Domain, string Namespace, IList List, Func<string, string> WriteFunc = null)
 {
     json arr = new json(Post(Domain, EncryptString(new json(new { Name = "interface_info", List = List }).ToString(), Interface_Data_Key)));
     if (arr.GetType() == "array")
     {
         for (int i = 0; i < arr.length; i++)
         {
             _ClassInfo info = (_ClassInfo)arr[i];
             string sNamespace = info.Namespace;
             string ClassName = info.ClassName;
             string FileName = ClassName + ".cs";
             IList<_MethodInfo> Methods = info.Methods;
             if (WriteFunc != null) FileName = WriteFunc(FileName);
             using (FileStream fs = File.Open(Directory + FileName, FileMode.Create, FileAccess.Write, FileShare.Read))
             using (StreamWriter sw = new StreamWriter(fs))
             {
                 sw.WriteLine("//Domain");
                 sw.WriteLine("//" + Domain);
                 sw.WriteLine("//Namespace");
                 sw.WriteLine("//" + Namespace);
                 sw.WriteLine("//ClassName");
                 sw.WriteLine("//" + sNamespace + "." + ClassName);
                 sw.WriteLine("//请勿修改上述接口信息");
                 sw.WriteLine("namespace " + Namespace);
                 sw.WriteLine("{");
                 sw.WriteLine("    public class " + ClassName + " : wnxd.Web.InterfaceBase");
                 sw.WriteLine("    {");
                 sw.WriteLine("        public " + ClassName + "()");
                 sw.WriteLine("        {");
                 sw.WriteLine("            this.Domain = \"" + Domain + "\";");
                 sw.WriteLine("            this.Namespace = \"" + sNamespace + "\";");
                 sw.WriteLine("            this.ClassName = \"" + ClassName + "\";");
                 sw.WriteLine("        }");
                 for (int n = 0; n < Methods.Count; n++)
                 {
                     _MethodInfo MethodInfo = Methods[n];
                     string MethodToken = MethodInfo.MethodToken;
                     string MethodName = MethodInfo.MethodName;
                     string ReturnType = MethodInfo.ReturnType;
                     IList<_ParameterInfo> Parameters = MethodInfo.Parameters;
                     string summary = MethodInfo.Summary;
                     if (!string.IsNullOrEmpty(summary))
                     {
                         sw.WriteLine("        /// <summary>");
                         sw.WriteLine("        /// " + summary);
                         sw.WriteLine("        /// </summary>");
                     }
                     bool isvoid = false;
                     if (ReturnType == "System.Void") isvoid = true;
                     string args = string.Empty;
                     sw.Write("        public " + (isvoid ? "void" : ReturnType) + " " + MethodName + "(");
                     IDictionary<string, string> outparams = new Dictionary<string, string>();
                     for (int x = 0; x < Parameters.Count; x++)
                     {
                         _ParameterInfo ParameterInfo = Parameters[x];
                         string ParameterName = ParameterInfo.ParameterName;
                         _ParameterType Type = ParameterInfo.Type;
                         bool IsOptional = ParameterInfo.IsOptional;
                         string ParameterType = ParameterInfo.ParameterType;
                         if (x > 0) sw.Write(", ");
                         switch (Type)
                         {
                             case _ParameterType.In:
                                 args += ", " + ParameterName;
                                 break;
                             case _ParameterType.Out:
                                 sw.Write("out ");
                                 outparams.Add(ParameterName, ParameterType);
                                 args += ", null";
                                 break;
                             case _ParameterType.Retval:
                                 sw.Write("ref ");
                                 outparams.Add(ParameterName, ParameterType);
                                 args += ", " + ParameterName;
                                 break;
                         }
                         sw.Write(ParameterType + " " + ParameterName);
                         if (IsOptional) sw.Write(" = " + ParameterInfo.DefaultValue.ToString());
                     }
                     sw.WriteLine(")");
                     sw.WriteLine("        {");
                     sw.Write("            wnxd.javascript.json r = this.");
                     if (MethodInfo.CacheTime == null) sw.Write("Run(");
                     else sw.Write("GetCache(" + MethodInfo.CacheTime.Value + ", ");
                     sw.WriteLine("\"" + (string.IsNullOrEmpty(MethodToken) ? MethodName : MethodToken) + "\"" + args + ");");
                     if (outparams.Count > 0)
                     {
                         sw.WriteLine("            wnxd.javascript.json outparams = r[\"OutParams\"];");
                         sw.WriteLine("            r = r[\"Data\"];");
                         int y = 0;
                         foreach (KeyValuePair<string, string> item in outparams)
                         {
                             sw.WriteLine("            " + item.Key + " = " + "(" + item.Value + ")outparams[" + y + "]" + ".TryConvert(typeof(" + item.Value + "));");
                             y++;
                         }
                     }
                     if (!isvoid)
                     {
                         if (ReturnType == "wnxd.javascript.json") sw.WriteLine("            return r;");
                         else sw.WriteLine("            return (" + ReturnType + ")r.TryConvert(typeof(" + ReturnType + "));");
                     }
                     sw.WriteLine("        }");
                 }
                 sw.WriteLine("    }");
                 sw.Write("}");
                 sw.Flush();
             }
         }
     }
 }
Beispiel #14
0
        private void query_Click(object sender, RoutedEventArgs e)
        {
            this.list.Items.Clear();
            if (string.IsNullOrEmpty(this.textbox.Text))
            {

            }
            else
            {
                if (this.textbox.Text.Substring(0, 4) != "http") this.textbox.Text = "http://" + this.textbox.Text;
                if (this.textbox.Text.Last() != '/') this.textbox.Text += "/";
                json arr = new json(Post(this.textbox.Text, interface_name));
                if (arr.GetType() == "array") for (int i = 0; i < arr.length; i++) this.list.Items.Add((string)arr[i]);
            }
        }
Beispiel #15
0
 ? RenderJsonColumn(json, renderAlias)
 : base.RenderColumn(column, renderAlias);
Beispiel #16
0
 public ConfigurationData(JToken json, IProtectionService ps) => LoadValuesFromJson(json, ps);
Beispiel #17
0
 var(json, source) = item;
Beispiel #18
0
 var(json, closed) = await client.ReceiveTextAsync(cancellationToken);