int.ToString()

Here are the examples of the csharp api int.ToString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

18927 Examples 7

19 View Source File : HttpDeleteController.cs
License : MIT License
Project Creator : 188867052

[HttpDelete("{id?}")]
        public Dictionary<string, string> Delete_1_Nullable_Constraint(int? id)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>
            {
                { "id", id.HasValue ? id.ToString() : null },
                { "url",  nameof(this.Delete_1_Nullable_Constraint) },
            };

            return dictionary;
        }

19 View Source File : NailsMap.cs
License : MIT License
Project Creator : 1upD

public NailsCube GetCube(int x, int y, int z)
        {
            // Return value
            NailsCube cube = null;
            
            // Use Linq to query the list
            var cubesList = NailsCubes.Where(i => i.X == x && i.Y == y && i.Z == z).ToList();

            // If there is a cube at this location, return it
            if (cubesList != null && cubesList.Count > 0)
            {
                cube = cubesList[0];
            }

            // If more than one cube is found, log an error
            if (cubesList.Count > 1)
            {
                log.Error(string.Format("NailsCube.GetCube(): Multiple cubes found at one location: x {0} y {1} z {2}", x.ToString(), y.ToString(), z.ToString()));
            }

            // If there is no cube at this location, return null
            return cube;
        }

19 View Source File : TableColumn.Types.cs
License : MIT License
Project Creator : 0x1000000

public override string? Readreplacedtring(ISqDataRecordReader recordReader) => this.Read(recordReader)?.ToString();

19 View Source File : MetroColorPicker.xaml.cs
License : MIT License
Project Creator : 1217950746

private void ApplyColor(HsbaColor hsba)
        {
            currentColor = hsba;
            currentRgbaColor = currentColor.RgbaColor;

            if (!rgbaR.IsSelectionActive) { rgbaR.Text = currentRgbaColor.R.ToString(); }
            if (!rgbaG.IsSelectionActive) { rgbaG.Text = currentRgbaColor.G.ToString(); }
            if (!rgbaB.IsSelectionActive) { rgbaB.Text = currentRgbaColor.B.ToString(); }
            if (!rgbaA.IsSelectionActive) { rgbaA.Text = currentRgbaColor.A.ToString(); }

            if (!hsbaH.IsSelectionActive) { hsbaH.Text = ((int)(currentColor.H / 3.6)).ToString(); }
            if (!hsbaS.IsSelectionActive) { hsbaS.Text = ((int)(currentColor.S * 100)).ToString(); }
            if (!hsbaB.IsSelectionActive) { hsbaB.Text = ((int)(currentColor.B * 100)).ToString(); }
            if (!hsbaA.IsSelectionActive) { hsbaA.Text = ((int)(currentColor.A * 100)).ToString(); }

            if (!hex.IsSelectionActive) { if (canTransparent) { hex.Text = currentColor.HexString; } else { hex.Text = string.Format("#{0:X2}{1:X2}{2:X2}", currentRgbaColor.R, currentRgbaColor.G, currentRgbaColor.B); } }

            if (!thumbH.IsDragging) { thumbH.YPercent = currentColor.H / 360.0; }
            if (!thumbSB.IsDragging) { thumbSB.XPercent = currentColor.S; thumbSB.YPercent = 1 - currentColor.B; }
            if (!thumbA.IsDragging) { thumbA.YPercent = Math.Abs(1 - currentColor.A); }

            selectColor.H = currentColor.H;
            selectColor.A = currentColor.A;
            viewSelectColor.Fill = selectColor.OpaqueSolidColorBrush;
            if (canTransparent)
            {
                viewSelectColor.Opacity = viewSelectColor1.Opacity = viewSelectColor2.Opacity = 1 - thumbA.YPercent;
            }
            viewAlpha.Color = selectColor.OpaqueColor;
            if (canTransparent)
            {
                Background = currentColor.SolidColorBrush;
            }
            else
            {
                Background = currentColor.OpaqueSolidColorBrush;
            }

            ColorChange?.Invoke(this, null);
        }

19 View Source File : TableColumnsTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public void TestNullableInt16()
        {
            replacedert.AreEqual(SqQueryBuilder.SqlType.Int16, this.Table.ColNullableInt16.SqlType);
            replacedert.AreEqual("[AT].[ColNullableInt16]", this.Table.ColNullableInt16.ToSql());
            replacedert.IsTrue(this.Table.ColNullableInt16.IsNullable);

            DerivedTable dt = new DerivedTable();
            var customColumn = this.Table.ColNullableInt16.AddToDerivedTable(dt);
            replacedert.AreEqual(this.Table.ColNullableInt16.ColumnName, customColumn.ColumnName);
            replacedert.IsTrue(dt.Columns.Contains(customColumn));

            var customColumn2 = this.Table.ColNullableInt16.ToCustomColumn(this.NewSource);
            replacedert.AreEqual(this.Table.ColNullableInt16.ColumnName, customColumn2.ColumnName);

            var reader = new Mock<ISqDataRecordReader>();

            this.Table.ColNullableInt16.Read(reader.Object);
            customColumn.Read(reader.Object);

            reader.Verify(r => r.GetNullableInt16(It.Is<string>(name => name == customColumn.ColumnName.Name)), Times.Exactly(2));

            replacedert.IsNull(this.Table.ColNullableInt16.Readreplacedtring(reader.Object));
            reader.Setup(r => r.GetNullableInt16(It.Is<string>(name => name == customColumn.ColumnName.Name))).Returns(255);
            replacedert.AreEqual(255.ToString(), this.Table.ColNullableInt16.Readreplacedtring(reader.Object));

            replacedert.AreEqual("255", this.Table.ColNullableInt16.FromString("255").ToSql());
            replacedert.AreEqual("NULL", this.Table.ColNullableInt16.FromString(null).ToSql());
        }

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

public void ProcessGroupMessage(GroupMessageReceivedContext context)
        {
            String message = context.Message;
            message = message.Trim();
            if (message == "" || message.Length == 0 || message == null)
            {
                return;
            }
            String myQQ = _mahuaApi.GetLoginQq();
            String aiteQQ = "[CQ:at,qq=" + myQQ + "]";
            if (message.Contains(aiteQQ)) {
                String sendMessage = "[CQ:at,qq=" + context.FromQq + "]\n";
                message = message.Replace(aiteQQ, "").Replace("\"\"","").Replace("“","").Replace("”","").Trim();
                IDatabase redis = RedisHelper.getRedis();
                if (redis.StringGet(context.FromQq).IsNull == false)
                {
                    string tmpStr = "为防止造成刷屏,您每次使用机器人的时间间隔" + Constants.sleepTime + "秒哦!";
                    sendMessage += tmpStr;
                    _mahuaApi.SendGroupMessage(context.FromGroup, sendMessage);
                }
                else
                {
                    redis.StringSet(context.FromQq, "flag");
                    redis.KeyExpire(context.FromQq, new TimeSpan(10000000 * Convert.ToInt16(Constants.sleepTime)));
                    MessageModel messageModel = MessageController.main(message, context.FromQq);
                    // 发送消息
                    string tmpStr = messageModel.SendMessage;
                    if (messageModel.IsAdmin)
                    {
                        // 群数量
                        if (MessageConstant.QUN_TOTAL.Equals(messageModel.Code))
                        {
                            ModelWithSourceString<IEnumerable<GroupInfo>> modelWithSourceString = _mahuaApi.GetGroupsWithModel();
                            IEnumerable<GroupInfo> groupInfo = modelWithSourceString.Model;
                            int count = 0;
                            foreach (var item in groupInfo)
                            {
                                count++;
                            }
                            _mahuaApi.SendGroupMessage(context.FromGroup, "群数量:" + count.ToString());
                        }
                        else
                        {
                            if (tmpStr != "" && tmpStr.Length > 0)
                            {
                                sendMessage += tmpStr;
                                _mahuaApi.SendGroupMessage(context.FromGroup, sendMessage);
                            }
                        }
                    }
                    else
                    {
                        if (tmpStr != "" && tmpStr.Length > 0)
                        {
                            sendMessage += tmpStr;
                            _mahuaApi.SendGroupMessage(context.FromGroup, sendMessage);
                        }
                    }
                }
            }
        }

19 View Source File : HttpGetController.cs
License : MIT License
Project Creator : 188867052

[HttpGet]
        public Dictionary<string, string> Get_1_Nullable_Parameter(int? id)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>
            {
                { "id", id.HasValue ? id.ToString() : null },
                { "url",  nameof(this.Get_1_Nullable_Constraint) },
            };

            return dictionary;
        }

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

public static ViewQueryResult FetchEntriesOfBaslik(string baslik, int baslikId, int pageNumber)
        {
            SqlServerIo sql;
            string query;
            ViewQueryResult resultSet;

            query = BuildEntryFetchSQL(baslik, baslikId, pageNumber);

            
            if (!CacheManager.TryGetCachedQueryResult<ViewQueryResult>(query, out resultSet))
            {
                sql = SqlServerIo.Create();

                if (!sql.Execute(false, query))
                {
                    SqlServerIo.Release(sql);
                    return new ViewQueryResult();
                }

                resultSet = new ViewQueryResult();

                while (sql.Read())
                {
                    if (resultSet.TotalRecordCount == 0)
                    {
                        resultSet.TotalRecordCount = sql.GetValueOfColumn<int>("TotalRecord");
                        resultSet.BaslikId = sql.GetValueOfColumn<int>("Id");
                    }

                    Entry e = new Entry(
                        sql.GetValueOfColumn<string>("Baslik"),
                        sql.GetValueOfColumn<string>("Suser"),
                        sql.GetValueOfColumn<DateTime>("SubmitDate").ToString(),
                        sql.GetValueOfColumn<string>("Entry"));

                    resultSet.Entries.Add(e);
                    resultSet.PhysicalRecordCount++;

                }

                SqlServerIo.Release(sql);

                //Dont cache for empty recordset for baslik
                if (!resultSet.HasEntry)
                    return resultSet;

                resultSet.LogicalRecordCount = resultSet.PhysicalRecordCount;

                CacheManager.CacheObject(KeysetId.Baslik(resultSet.BaslikId), true, query, resultSet);

                BaslikBasicInfo bbi = new BaslikBasicInfo()
                {
                    TotalEntries = resultSet.TotalRecordCount
                };

                CacheManager.CacheObject("BBI_" + resultSet.BaslikId.ToString(),
                    bbi,
                    TimeSpan.FromMinutes(10));


                //if this request initial fetch using the baslik string.
                //rebuild sql with baslikid and cache the result with its hashkey
                if (baslikId == 0)
                {
                    query = BuildEntryFetchSQL(null, resultSet.BaslikId, pageNumber);
                    CacheManager.CacheObject(KeysetId.Baslik(resultSet.BaslikId),true, query, resultSet);
                }
            }

            return resultSet;
        }

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

void DrawQuickStart()
    {
        GUILayout.BeginVertical();

        GUILayout.Label("Quick Start", EditorStyles.boldLabel);

        var entryCount = quickstartData.clientCount + 1;
        // Make sure we have enough entries
        var minEntryCount = Math.Max(entryCount, 2);
        while (minEntryCount > quickstartData.entries.Count())
            quickstartData.entries.Add(new QuickstartEntry());

        string str = "Starting Game - Server (Headless) & " + quickstartData.clientCount.ToString() + " clients";
        GUILayout.Label(str, EditorStyles.boldLabel);

        Color defaultGUIBackgrounColor = GUI.backgroundColor;
        // Quick start buttons
        GUILayout.BeginHorizontal();
        {
            GUI.backgroundColor = Color.green;
            if (GUILayout.Button("Start"))
            {
                for (int i = 0; i < entryCount; i++)
                {
                    if (quickstartData.entries[i].runInEditor)
                        continue;
                        //EditorLevelManager.StartGameInEditor();
                    else
                    {
                        RunBuild(quickstartData.entries[i].gameLoopMode);
                    }
                }
            }
            GUI.backgroundColor = defaultGUIBackgrounColor;

            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Stop All"))
            {
                StopAll();
            }
            GUI.backgroundColor = defaultGUIBackgrounColor;
        }
        GUILayout.EndHorizontal();

        // Settings
        EditorGUI.BeginChangeCheck();

        quickstartData.clientCount = EditorGUILayout.IntField("Clients", quickstartData.clientCount);

        quickstartData.editorRole = (EditorRole)EditorGUILayout.EnumPopup("Use Editor as", quickstartData.editorRole);

        quickstartData.entries[0].gameLoopMode = GameLoopMode.Server;
        quickstartData.entries[0].headless = quickstartData.headlessServer;

        quickstartData.entries[0].runInEditor = quickstartData.editorRole == EditorRole.Server;
        quickstartData.entries[1].runInEditor = quickstartData.editorRole == EditorRole.Client;

        for (var i = 1; i < entryCount; i++)
        {
            quickstartData.entries[i].gameLoopMode = GameLoopMode.Client;
            quickstartData.entries[i].headless = false;
        }

        // Draw entries
        GUILayout.Label("Started processes:");
        for (var i = 0; i < entryCount; i++)
        {
            var entry = quickstartData.entries[i];
            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);

                    GUILayout.Label("- Stand Alone Build", GUILayout.Width(130));

                    EditorGUILayout.SelectableLabel(entry.gameLoopMode.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }

        GUILayout.EndVertical();
    }

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 : FProgressBar.cs
License : MIT License
Project Creator : 0xLaileb

private void Draw_Text(Graphics graphics)
        {
            graphics.DrawString(
                ((Value / (Maximum / 100))).ToString() + "%",
                Font,
                new SolidBrush(ForeColor),
                new Rectangle(rectangle_region.X, rectangle_region.Y, rectangle_region.Width, rectangle_region.Height),
                stringFormat);
        }

19 View Source File : TableColumnsTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public void TestNullableInt32()
        {
            replacedert.AreEqual(SqQueryBuilder.SqlType.Int32, this.Table.ColNullableInt32.SqlType);
            replacedert.AreEqual("[AT].[ColNullableInt32]", this.Table.ColNullableInt32.ToSql());
            replacedert.IsTrue(this.Table.ColNullableInt32.IsNullable);

            DerivedTable dt = new DerivedTable();
            var customColumn = this.Table.ColNullableInt32.AddToDerivedTable(dt);
            replacedert.AreEqual(this.Table.ColNullableInt32.ColumnName, customColumn.ColumnName);
            replacedert.IsTrue(dt.Columns.Contains(customColumn));

            var customColumn2 = this.Table.ColNullableInt32.ToCustomColumn(this.NewSource);
            replacedert.AreEqual(this.Table.ColNullableInt32.ColumnName, customColumn2.ColumnName);

            var reader = new Mock<ISqDataRecordReader>();

            this.Table.ColNullableInt32.Read(reader.Object);
            customColumn.Read(reader.Object);

            reader.Verify(r => r.GetNullableInt32(It.Is<string>(name => name == customColumn.ColumnName.Name)), Times.Exactly(2));

            replacedert.IsNull(this.Table.ColNullableInt32.Readreplacedtring(reader.Object));
            reader.Setup(r => r.GetNullableInt32(It.Is<string>(name => name == customColumn.ColumnName.Name))).Returns(Int32.MaxValue);
            replacedert.AreEqual(Int32.MaxValue.ToString(), this.Table.ColNullableInt32.Readreplacedtring(reader.Object));

            replacedert.AreEqual(Int32.MinValue.ToString(), this.Table.ColNullableInt32.FromString(Int32.MinValue.ToString()).ToSql());
            replacedert.AreEqual("NULL", this.Table.ColNullableInt32.FromString(null).ToSql());
        }

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

public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            string message = context.Message;
            if (message == "" || message.Length == 0 || message == null)
            {
                return;
            }
            IDatabase redis = RedisHelper.getRedis();
            // 判断用户是否在缓冲中
            if (redis.StringGet(context.FromQq).IsNull)
            {
                redis.StringSet(context.FromQq, "flag");
                redis.KeyExpire(context.FromQq, new TimeSpan(10000000 * Convert.ToInt16(Constants.sleepTime)));
            }
            else
            {
                string tmpStr = "为防止造成刷屏,您每次使用机器人的时间间隔"+ Constants.sleepTime + "秒哦!";
                _mahuaApi.SendPrivateMessage(context.FromQq, tmpStr);
                return;
            };
            if (message == null || message == "" || message.Length == 0)
            {
                //
            }
            else
            {
                MessageModel messageModel = MessageController.main(message, context.FromQq);
                string tmpStr = messageModel.SendMessage;
                bool isAdmin = messageModel.IsAdmin;
                if (isAdmin)
                {
                    // 判断是否为 公告指令
                    if (MessageConstant.GONG_GAO.Equals(messageModel.Code))
                    {
                        // 获取所有群信息
                        ModelWithSourceString<IEnumerable<GroupInfo>> modelWithSourceString = _mahuaApi.GetGroupsWithModel();
                        IEnumerable<GroupInfo> groupInfo = modelWithSourceString.Model;
                        foreach (var item in groupInfo)
                        {
                            _mahuaApi.SendGroupMessage(item.Group, tmpStr);
                            _mahuaApi.SendPrivateMessage(context.FromQq, "【" + item.Name + "】 " + item.Group + " 推送成功!");
                        }
                    }
                    // 判断是否为全体成员处理
                    else if (MessageConstant.AITE_ALL.Equals(messageModel.Code))
                    {
                        // 获取所有群信息
                        ModelWithSourceString<IEnumerable<GroupInfo>> modelWithSourceString = _mahuaApi.GetGroupsWithModel();
                        IEnumerable<GroupInfo> groupInfo = modelWithSourceString.Model;
                        tmpStr = "[CQ:at,qq=all]\n" + tmpStr;
                        foreach (var item in groupInfo)
                        {
                            _mahuaApi.SendGroupMessage(item.Group, tmpStr);
                            _mahuaApi.SendPrivateMessage(context.FromQq, "【" + item.Name + "】 " + item.Group + " 推送成功!");
                        }
                    }
                    // 更新金额
                    else if(MessageConstant.UPDATE_MONEY.Equals(messageModel.Code))
                    {
                        _mahuaApi.SendPrivateMessage(context.FromQq, messageModel.SendMessage);
                    }
                    // 群数量
                    else if (MessageConstant.QUN_TOTAL.Equals(messageModel.Code))
                    {
                        ModelWithSourceString<IEnumerable<GroupInfo>> modelWithSourceString = _mahuaApi.GetGroupsWithModel();
                        IEnumerable<GroupInfo> groupInfo = modelWithSourceString.Model;
                        int count = 0;
                        foreach (var item in groupInfo)
                        {
                            count++;
                        }
                        _mahuaApi.SendPrivateMessage(context.FromQq, "群数量:"+count.ToString());
                    }
                    else
                    {
                        if (tmpStr != "" && tmpStr.Length > 0)
                        {
                            _mahuaApi.SendPrivateMessage(context.FromQq, tmpStr);
                        }
                    }
                }
                else
                {
                    if (tmpStr != "" && tmpStr.Length > 0)
                    {
                        _mahuaApi.SendPrivateMessage(context.FromQq, tmpStr);
                    }
                }
            }
        }

19 View Source File : Inline_Hook.cs
License : Apache License 2.0
Project Creator : 1694439208

public static IntPtr InlineHook(int HookAddress, int Hooklen,
            byte[] HookBytes0, int Callback, int CallbackOffset,string name, Action<Methods.Register> func)
        {

            WeChetHook.DllcallBack dllcallBack = new WeChetHook.DllcallBack((de1, de2, ECX1, EAX1, EDX1, EBX1, ESP1, EBP1, ESI1, EDI1) => {
                //int ECX, int EAX, int EDX, int EBX, int ESP, int EBP, int ESI, int EDI
                func(new Register
                {
                    EAX = EAX1,
                    EBP = EBP1,
                    EBX = EBX1,
                    ECX = ECX1,
                    EDI = EDI1,
                    EDX = EDX1,
                    ESI = ESI1,
                    ESP = ESP1
                });
            });
            int CallHandle = ComputeHash(name);
            System.Windows.Forms.MessageBox.Show("CallHandle:" + CallHandle.ToString());
            Methods.callBacks.Add(CallHandle, dllcallBack);

            List<byte> byteSource1 = new List<byte>();
            byteSource1.AddRange(new byte[] { 199, 134, 240, 2, 0, 0 });
            byteSource1.AddRange(BitConverter.GetBytes(CallHandle));//把标识指针绑定到寄存器我觉得不靠谱但是目前没啥问题
            byteSource1.AddRange(HookBytes0);

            byte[] hookbytes = byteSource1.ToArray();


            List<byte> byteSource = new List<byte>();
            IntPtr ptr = NativeAPI.VirtualAlloc(0, 128, 4096, 64);
            NativeAPI.WriteProcessMemory(-1, ptr, hookbytes, hookbytes.Length, 0);
            NativeAPI.WriteProcessMemory(-1, ptr + CallbackOffset, Inline_GetBuf(ptr + CallbackOffset - 1, Callback), 4, 0);
            NativeAPI.WriteProcessMemory(-1, ptr + hookbytes.Length, Add(new byte[] { 233 }, Inline_GetBuf(ptr + hookbytes.Length, HookAddress+ Hooklen)), 5, 0);

            NativeAPI.WriteProcessMemory(-1, new IntPtr(HookAddress), Add(new byte[] { 233 }, Inline_GetBuf(HookAddress, ptr.ToInt32())), 5, 0);
            for (int i = 0; i < Hooklen - 5; i++)
            {
                byteSource.Add(144);
            }
            byte[] ByteFill = byteSource.ToArray();
            NativeAPI.WriteProcessMemory(-1, new IntPtr(HookAddress + 5), ByteFill, ByteFill.Length, 0);
            return ptr;
        }

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

private static string BuildEntryFetchSQL(string baslik, int baslikId, int pageNumber)
        {
            int rowBegin, rowEnd;
            string query, searchCondition;
            rowBegin = (pageNumber * RecordsPerPage) + 1;
            rowEnd = rowBegin + RecordsPerPage - 1;

            if (baslikId > 0)
                searchCondition = "Basliks.Id = " + baslikId.ToString();
            else
                searchCondition = string.Format("Basliks.Baslik = '{0}'", baslik);

            query = GET_ENTRIES_OF_BASLIK_SQL_BASE.Replace("%%BASLIK_SEARCH_CONDITION%%", searchCondition);


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

            return query;
        }

19 View Source File : HttpDeleteController.cs
License : MIT License
Project Creator : 188867052

[Route("~/api/Values/constraint/{id:range(1,10)}")]
        public string DeleteById(int id)
        {
            return "value:" + id.ToString();
        }

19 View Source File : RansomNote.cs
License : GNU General Public License v3.0
Project Creator : 0x00000FF

private void Detect()
        {
            while (true)
            {
                if (!flag)
                {
                    var Procs = Process.GetProcessesByName("th12");

                    if (Procs.Length > 0)
                    {
                        // Open TH12.exe with PROCESS_VM_READ (0x0010).
                        _handle = OpenProcess(0x10, false, Procs.FirstOrDefault().Id);

                        if (_handle != null)
                            processStatus = true;
                    }
                }
                else
                {
                    if (IsScoreReached)
                    {
                        break;
                    }
                    
                    int bytesRead = 0;
                    byte[] _buffer = new byte[4]; // Will read 4 bytes of memory

                    /*
                     * Read Level
                     * 
                     * In TH12 ~ Undefined Fantastic Object, Level is stored in
                     * [base address] + 0xAEBD0, as 4bytes int value.
                     * 
                     */ 
                    var readLevel = ReadProcessMemory((int)_handle, 0x004AEBD0, _buffer, 2, ref bytesRead);
                    if (!readLevel)
                    {
                        flag = false;
                        continue;
                    }

                    /*
                     * Level Codes
                     * 0 - Easy; 1 - Normal; 2 - Hard; 3 - Lunatic; ? - Extra
                     * 
                     */
                    if (BitConverter.ToInt16(_buffer, 0) != 3)
                    {
                        ProcStatus.Invoke(new MethodInvoker(() => {
                            ProcStatus.Text = "NOT LUNATIC LEVEL!";
                        }));
                        continue;
                    }
                    else
                    {
                        ProcStatus.Invoke(new MethodInvoker(() => {
                            ProcStatus.Text = "Process Working";
                        }));
                    }

                    /*
                     * Read Score
                     * 
                     * Once level is detected as LUNATIC, 
                     * rensenWare reads score from process.
                     * 
                     * Score is stored in
                     * [base address] + 0xB0C44, as 4bytes int value.
                     * 
                     */
                    var readScore = ReadProcessMemory((int)_handle, 0x004B0C44, _buffer, 4, ref bytesRead);
                    if (!readScore)
                    {
                        flag = false;
                        continue;
                    }

                    ScoreStatus.Invoke(new MethodInvoker(() =>
                    {
                        ScoreStatus.Text = (BitConverter.ToInt32(_buffer, 0) * 10).ToString();
                    }));

                    /*
                     * One interesting thing,
                     * internally, touhou project process prints score as 10 times of original value.
                     * I don't know why it is.
                     */ 
                    if (BitConverter.ToInt32(_buffer, 0) > 20000000) // It is 20,000,000
                        IsScoreReached = true;
                    else
                        _buffer = null;
                }

                // Let CPU rest
                Thread.Sleep(100);
            }

            // Create Random Key/IV File in Desktop of Current User.
            File.WriteAllBytes(Program.KeyFilePath, Program.randomKey);
            File.WriteAllBytes(Program.IVFilePath, Program.randomIV);

            decryptProgress.Maximum = Program.encryptedFiles.Count;

            foreach (var path in Program.encryptedFiles)
            {
                try
                {
                    DecryptStatus.Invoke(new MethodInvoker(() =>
                    {
                        DecryptStatus.Text = Path.GetFileName(path);
                    }));

                    // Do Decrypt

                    decryptProgress.Value++;
                }
                catch
                {
                    continue;
                }
            }

            this.Invoke(new MethodInvoker(() => {
                MessageBox.Show("Decryption Complete!\nIf there are encrypted files exists, use manual decrypter with key/IV files saved in desktop!");
                
                ButtonManualDecrypt.Visible = true;
                ButtonExit.Visible = true;
            }));            
        }

19 View Source File : StringInputDataSource.cs
License : MIT License
Project Creator : 1996v

public string GetCurrentSegmentString()
        {
            if (curIsMapKey)
            {
                return _str.Substring(mapKeyIndex, mapKeyLength);
            }
            else
            {
                return "$" + aryIndexNumber.ToString();
            }
        }

19 View Source File : GaugeTimerTracker.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public string GetText() => ((int)Math.Round(TimeLeft)).ToString();

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

public static string ToStringNonAlloc(this int value)
        {
            if (value < 0 && -value < negativeBuffer.Length)
            {
                return negativeBuffer[-value];
            }

            if (value >= 0 && value < positiveBuffer.Length)
            {
                return positiveBuffer[value];
            }

            return value.ToString();
        }

19 View Source File : TableColumnsTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public void TestNullableByte()
        {
            replacedert.AreEqual(SqQueryBuilder.SqlType.Byte, this.Table.ColNullableByte.SqlType);
            replacedert.AreEqual("[AT].[ColNullableByte]", this.Table.ColNullableByte.ToSql());
            replacedert.IsTrue(this.Table.ColNullableByte.IsNullable);

            DerivedTable dt = new DerivedTable();
            var customColumn = this.Table.ColNullableByte.AddToDerivedTable(dt);
            replacedert.AreEqual(this.Table.ColNullableByte.ColumnName, customColumn.ColumnName);
            replacedert.IsTrue(dt.Columns.Contains(customColumn));

            var customColumn2 = this.Table.ColNullableByte.ToCustomColumn(this.NewSource);
            replacedert.AreEqual(this.Table.ColNullableByte.ColumnName, customColumn2.ColumnName);

            var reader = new Mock<ISqDataRecordReader>();

            this.Table.ColNullableByte.Read(reader.Object);
            customColumn.Read(reader.Object);

            reader.Verify(r => r.GetNullableByte(It.Is<string>(name => name == customColumn.ColumnName.Name)), Times.Exactly(2));

            replacedert.IsNull(this.Table.ColNullableByte.Readreplacedtring(reader.Object));
            reader.Setup(r => r.GetNullableByte(It.Is<string>(name => name == customColumn.ColumnName.Name))).Returns(255);
            replacedert.AreEqual(255.ToString(), this.Table.ColNullableByte.Readreplacedtring(reader.Object));

            replacedert.AreEqual("255", this.Table.ColNullableByte.FromString("255").ToSql());
            replacedert.AreEqual("NULL", this.Table.ColNullableByte.FromString(null).ToSql());
        }

19 View Source File : TableColumnsTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public void TestInt16()
        {
            replacedert.AreEqual(SqQueryBuilder.SqlType.Int16, this.Table.ColInt16.SqlType);
            replacedert.AreEqual("[AT].[ColInt16]", this.Table.ColInt16.ToSql());
            replacedert.IsFalse(this.Table.ColInt16.IsNullable);

            DerivedTable dt = new DerivedTable();
            var customColumn = this.Table.ColInt16.AddToDerivedTable(dt);
            replacedert.AreEqual(this.Table.ColInt16.ColumnName, customColumn.ColumnName);
            replacedert.IsTrue(dt.Columns.Contains(customColumn));

            var customColumn2 = this.Table.ColInt16.ToCustomColumn(this.NewSource);
            replacedert.AreEqual(this.Table.ColInt16.ColumnName, customColumn2.ColumnName);

            var reader = new Mock<ISqDataRecordReader>();

            this.Table.ColInt16.Read(reader.Object);
            customColumn.Read(reader.Object);

            reader.Verify(r => r.GetInt16(It.Is<string>(name => name == customColumn.ColumnName.Name)), Times.Exactly(2));

            replacedert.Throws<SqExpressException>(() => this.Table.ColInt16.Readreplacedtring(reader.Object));
            reader.Setup(r => r.GetNullableInt16(It.Is<string>(name => name == customColumn.ColumnName.Name))).Returns(10000);
            replacedert.AreEqual(10000.ToString(), this.Table.ColInt16.Readreplacedtring(reader.Object));

            replacedert.AreEqual("10000", this.Table.ColInt16.FromString("10000").ToSql());
            replacedert.Throws<SqExpressException>(() => this.Table.ColInt16.FromString(null));
        }

19 View Source File : UIIconBuff.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public override void SetProgress(float current, float max) {
            if (State != IconState.BuffRunning) {
                State = IconState.BuffRunning;
                UIHelper.Hide(OriginalOverlay);
                UIHelper.Show(BigText);
                UIHelper.Show(Combo);
            }
            BigText->SetText(((int)Math.Round(current)).ToString());
        }

19 View Source File : TableColumnsTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public void TestInt32()
        {
            replacedert.AreEqual(SqQueryBuilder.SqlType.Int32, this.Table.ColInt32.SqlType);
            replacedert.AreEqual("[AT].[ColInt32]", this.Table.ColInt32.ToSql());
            replacedert.IsFalse(this.Table.ColInt32.IsNullable);

            DerivedTable dt = new DerivedTable();
            var customColumn = this.Table.ColInt32.AddToDerivedTable(dt);
            replacedert.AreEqual(this.Table.ColInt32.ColumnName, customColumn.ColumnName);
            replacedert.IsTrue(dt.Columns.Contains(customColumn));

            var customColumn2 = this.Table.ColInt32.ToCustomColumn(this.NewSource);
            replacedert.AreEqual(this.Table.ColInt32.ColumnName, customColumn2.ColumnName);

            var reader = new Mock<ISqDataRecordReader>();

            this.Table.ColInt32.Read(reader.Object);
            customColumn.Read(reader.Object);

            reader.Verify(r => r.GetInt32(It.Is<string>(name => name == customColumn.ColumnName.Name)), Times.Exactly(2));

            replacedert.Throws<SqExpressException>(() => this.Table.ColInt32.Readreplacedtring(reader.Object));
            reader.Setup(r => r.GetNullableInt32(It.Is<string>(name => name == customColumn.ColumnName.Name))).Returns(Int32.MaxValue);
            replacedert.AreEqual(Int32.MaxValue.ToString(), this.Table.ColInt32.Readreplacedtring(reader.Object));

            replacedert.AreEqual(Int32.MinValue.ToString(), this.Table.ColInt32.FromString(Int32.MinValue.ToString()).ToSql());
            replacedert.Throws<SqExpressException>(() => this.Table.ColInt32.FromString(null));
        }

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

public static Hashtable getThisWeek()
        {
            string sql = "select user_qq,DATE_FORMAT(create_date,'%Y-%m-%d') as date from ichunqiu_user where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(create_date) GROUP BY user_qq,DATE_FORMAT(create_date,'%Y-%m-%d');";
            Hashtable hashtable = new Hashtable();
            MySqlConnection connection = new MySqlConnection(Constants.connectionStr);
            try
            {
                connection.Open();
                MySqlCommand mySqlCommand = new MySqlCommand(sql, connection);
                // 提取数据
                MySqlDataReader myDataReader = mySqlCommand.ExecuteReader();
                while (myDataReader.Read() == true)
                {
                    string date = myDataReader["date"].ToString();
                    if (hashtable.Contains(date))
                    {
                        hashtable[date] = (Convert.ToInt16(hashtable[date]) + 1).ToString();
                    }
                    else
                    {
                        hashtable.Add(date, "1");
                    }
                }
                myDataReader.Close();
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                connection.Close();
            }
            return hashtable;
        }

19 View Source File : FilenameProvider.cs
License : MIT License
Project Creator : 0xd4d

public string GetFilename(uint token, string name) {
			string candidate;
			switch (filenameFormat) {
			case FilenameFormat.MemberName:
				candidate = name;
				break;

			case FilenameFormat.TokenMemberName:
				candidate = token.ToString("X8") + "_" + name;
				break;

			case FilenameFormat.Token:
				candidate = token.ToString("X8");
				break;

			default:
				throw new ArgumentOutOfRangeException(nameof(filenameFormat));
			}

			if (candidate == string.Empty)
				candidate = "<UNKNOWN>";
			candidate = ReplaceInvalidFilenameChars(candidate);
			if (candidate.Length > MAX_NAME_LEN)
				candidate = candidate.Substring(0, MAX_NAME_LEN) + "-";
			if (!usedFilenames.Add(candidate)) {
				for (int i = 1; i < int.MaxValue; i++) {
					var newCand = candidate + "_" + i.ToString();
					if (usedFilenames.Add(newCand)) {
						candidate = newCand;
						break;
					}
				}
			}
			return Path.Combine(outputDir, candidate + extension);
		}

19 View Source File : IntegrationTest.cs
License : MIT License
Project Creator : 0x1000000

public static async Task<string> Get3Str()
        {
            await Task.Delay(TimeSlotMs);
            return 3.ToString();
        }

19 View Source File : GaugeGCDTracker.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public string GetText() => Value.ToString();

19 View Source File : Disassembler.cs
License : MIT License
Project Creator : 0xd4d

public void Disreplacedemble(Formatter formatter, TextWriter output, DisasmInfo method) {
			formatterOutput.writer = output;
			targets.Clear();
			sortedTargets.Clear();

			bool uppercaseHex = formatter.Options.UppercaseHex;

			output.Write(commentPrefix);
			output.WriteLine("================================================================================");
			output.Write(commentPrefix);
			output.WriteLine(method.MethodFullName);
			uint codeSize = 0;
			foreach (var info in method.Code)
				codeSize += (uint)info.Code.Length;
			var codeSizeHexText = codeSize.ToString(uppercaseHex ? "X" : "x");
			output.WriteLine($"{commentPrefix}{codeSize} (0x{codeSizeHexText}) bytes");
			var instrCount = method.Instructions.Count;
			var instrCountHexText = instrCount.ToString(uppercaseHex ? "X" : "x");
			output.WriteLine($"{commentPrefix}{instrCount} (0x{instrCountHexText}) instructions");

			void Add(ulong address, TargetKind kind) {
				if (!targets.TryGetValue(address, out var addrInfo))
					targets[address] = new AddressInfo(kind);
				else if (addrInfo.Kind < kind)
					addrInfo.Kind = kind;
			}
			if (method.Instructions.Count > 0)
				Add(method.Instructions[0].IP, TargetKind.Unknown);
			foreach (ref var instr in method.Instructions) {
				switch (instr.FlowControl) {
				case FlowControl.Next:
				case FlowControl.Interrupt:
					break;

				case FlowControl.UnconditionalBranch:
					Add(instr.NextIP, TargetKind.Unknown);
					if (instr.Op0Kind == OpKind.NearBranch16 || instr.Op0Kind == OpKind.NearBranch32 || instr.Op0Kind == OpKind.NearBranch64)
						Add(instr.NearBranchTarget, TargetKind.Branch);
					break;

				case FlowControl.ConditionalBranch:
				case FlowControl.XbeginXabortXend:
					if (instr.Op0Kind == OpKind.NearBranch16 || instr.Op0Kind == OpKind.NearBranch32 || instr.Op0Kind == OpKind.NearBranch64)
						Add(instr.NearBranchTarget, TargetKind.Branch);
					break;

				case FlowControl.Call:
					if (instr.Op0Kind == OpKind.NearBranch16 || instr.Op0Kind == OpKind.NearBranch32 || instr.Op0Kind == OpKind.NearBranch64)
						Add(instr.NearBranchTarget, TargetKind.Call);
					break;

				case FlowControl.IndirectBranch:
					Add(instr.NextIP, TargetKind.Unknown);
					// Unknown target
					break;

				case FlowControl.IndirectCall:
					// Unknown target
					break;

				case FlowControl.Return:
				case FlowControl.Exception:
					Add(instr.NextIP, TargetKind.Unknown);
					break;

				default:
					Debug.Fail($"Unknown flow control: {instr.FlowControl}");
					break;
				}

				var baseReg = instr.MemoryBase;
				if (baseReg == Register.RIP || baseReg == Register.EIP) {
					int opCount = instr.OpCount;
					for (int i = 0; i < opCount; i++) {
						if (instr.GetOpKind(i) == OpKind.Memory) {
							if (method.Contains(instr.IPRelativeMemoryAddress))
								Add(instr.IPRelativeMemoryAddress, TargetKind.Branch);
							break;
						}
					}
				}
				else if (instr.MemoryDisplSize >= 2) {
					ulong displ;
					switch (instr.MemoryDisplSize) {
					case 2:
					case 4: displ = instr.MemoryDisplacement; break;
					case 8: displ = (ulong)(int)instr.MemoryDisplacement; break;
					default:
						Debug.Fail($"Unknown mem displ size: {instr.MemoryDisplSize}");
						goto case 8;
					}
					if (method.Contains(displ))
						Add(displ, TargetKind.Branch);
				}
			}
			foreach (var map in method.ILMap) {
				if (targets.TryGetValue(map.nativeStartAddress, out var info)) {
					if (info.Kind < TargetKind.BlockStart && info.Kind != TargetKind.Unknown)
						info.Kind = TargetKind.BlockStart;
				}
				else
					targets.Add(map.nativeStartAddress, info = new AddressInfo(TargetKind.Unknown));
				if (info.ILOffset < 0)
					info.ILOffset = map.ilOffset;
			}

			int labelIndex = 0, methodIndex = 0;
			string GetLabel(int index) => LABEL_PREFIX + index.ToString();
			string GetFunc(int index) => FUNC_PREFIX + index.ToString();
			foreach (var kv in targets) {
				if (method.Contains(kv.Key))
					sortedTargets.Add(kv);
			}
			sortedTargets.Sort((a, b) => a.Key.CompareTo(b.Key));
			foreach (var kv in sortedTargets) {
				var address = kv.Key;
				var info = kv.Value;

				switch (info.Kind) {
				case TargetKind.Unknown:
					info.Name = null;
					break;

				case TargetKind.Data:
					info.Name = GetLabel(labelIndex++);
					break;

				case TargetKind.BlockStart:
				case TargetKind.Branch:
					info.Name = GetLabel(labelIndex++);
					break;

				case TargetKind.Call:
					info.Name = GetFunc(methodIndex++);
					break;

				default:
					throw new InvalidOperationException();
				}
			}

			foreach (ref var instr in method.Instructions) {
				ulong ip = instr.IP;
				if (targets.TryGetValue(ip, out var lblInfo)) {
					output.WriteLine();
					if (!(lblInfo.Name is null)) {
						output.Write(lblInfo.Name);
						output.Write(':');
						output.WriteLine();
					}
					if (lblInfo.ILOffset >= 0) {
						if (ShowSourceCode) {
							foreach (var info in sourceCodeProvider.GetStatementLines(method, lblInfo.ILOffset)) {
								output.Write(commentPrefix);
								var line = info.Line;
								int column = commentPrefix.Length;
								WriteWithTabs(output, line, 0, line.Length, '\0', ref column);
								output.WriteLine();
								if (info.Partial) {
									output.Write(commentPrefix);
									column = commentPrefix.Length;
									WriteWithTabs(output, line, 0, info.Span.Start, ' ', ref column);
									output.WriteLine(new string('^', info.Span.Length));
								}
							}
						}
					}
				}

				if (ShowAddresses) {
					var address = FormatAddress(bitness, ip, uppercaseHex);
					output.Write(address);
					output.Write(" ");
				}
				else
					output.Write(formatter.Options.TabSize > 0 ? "\t\t" : "        ");

				if (ShowHexBytes) {
					if (!method.TryGetCode(ip, out var nativeCode))
						throw new InvalidOperationException();
					var codeBytes = nativeCode.Code;
					int index = (int)(ip - nativeCode.IP);
					int instrLen = instr.Length;
					for (int i = 0; i < instrLen; i++) {
						byte b = codeBytes[index + i];
						output.Write(b.ToString(uppercaseHex ? "X2" : "x2"));
					}
					int missingBytes = HEXBYTES_COLUMN_BYTE_LENGTH - instrLen;
					for (int i = 0; i < missingBytes; i++)
						output.Write("  ");
					output.Write(" ");
				}

				formatter.Format(instr, formatterOutput);
				output.WriteLine();
			}
		}

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

private bool RecoverMemcachedAndPreplacedNewMemcachedToBackend()
        {
            if (this.procType != ProcessType.MemcachedProcess)
                return false;

            if (!RestartProcessWithExistedInfo(null))
                return false;

            Log.Info("Created new memcached instance");

            var data = Program.talk.CreateTalkData();
            
            data.Add("Type", "AttachMemcached");
            data.Add("mpid", pid.ToString());
            data.Add("mport", "11211");

            Log.Info("Sending to the backend pid: {0}", pid);

            Program.talk.SendTalkData(data);
            Program.talk.DisposeTalkData(ref data);

            return true;
        }

19 View Source File : IrdClient.cs
License : MIT License
Project Creator : 13xforever

public async Task<SearchResult> SearchAsync(string query, CancellationToken cancellationToken)
        {
            try
            {
                var requestUri = new Uri(BaseUrl + "/data.php").SetQueryParameters(new Dictionary<string, string>
                    {
                        ["draw"] = query.Length.ToString(),

                        ["columns[0][data]"] = "id",
                        ["columns[0][name]"] = "",
                        ["columns[0][searchable]"] = "true",
                        ["columns[0][orderable]"] = "true",
                        ["columns[0][search][value]"] = "",
                        ["columns[0][search][regex]"] = "false",

                        ["columns[1][data]"] = "replacedle",
                        ["columns[1][name]"] = "",
                        ["columns[1][searchable]"] = "true",
                        ["columns[1][orderable]"] = "true",
                        ["columns[1][search][value]"] = "",
                        ["columns[1][search][regex]"] = "false",

                        ["order[0][column]"] = "0",
                        ["order[0][dir]"] = "asc",

                        ["start"] = "0",
                        ["length"] = "10",

                        ["search[value]"] = query.Trim(100),

                        ["_"] = DateTime.UtcNow.Ticks.ToString(),
                    });
                    try
                    {
                        var responseBytes = await client.GetByteArrayAsync(requestUri).ConfigureAwait(false);
                        var result = Deserialize(responseBytes);
                        result.Data = result.Data ?? new List<SearchResulreplacedem>(0);
                        foreach (var item in result.Data)
                        {
                            item.Filename = GetIrdFilename(item.Filename);
                            item.replacedle = Getreplacedle(item.replacedle);
                        }
                        return result;
                    }
                    catch (Exception e)
                    {
                        Log.Error(e, "Failed to make API call to IRD Library");
                        return null;
                    }
            }
            catch (Exception e)
            {
                Log.Error(e);
                return null;
            }
        }

19 View Source File : PlayingFieldUI.cs
License : MIT License
Project Creator : 0thElement

private void UpdateScoring()
        {
            float scorePerNote = 1000000 / PhiChartFileReader.Instance.CurrentChart.numOfNotes;
            int combo = GetCombo();
            ComboCounter.text = combo.ToString();
            ScoreCounter.text = Mathf.RoundToInt(combo * scorePerNote).ToString("D7");
       }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

private static void ResolveInForGeneric(StringBuilder sqlBuilder, string columnName, Expression exp, Type valueType, bool notContainer = false)
    {
        var value = ResolveDynamicInvoke(exp);
        var isValueType = false;
        var list = new List<string>();
        if (valueType.IsEnum)
        {
            isValueType = true;
            var valueList = (IEnumerable)value;
            if (valueList != null)
            {
                foreach (var c in valueList)
                {
                    list.Add(Enum.Parse(valueType, c.ToString()!).ToInt().ToString());
                }
            }
        }
        else
        {
            var typeName = valueType.Name;
            switch (typeName)
            {
                case "Guid":
                    if (value is IEnumerable<Guid> guidValues)
                    {
                        foreach (var c in guidValues)
                        {
                            list.Add(c.ToString());
                        }
                    }
                    break;
                case "DateTime":
                    if (value is IEnumerable<DateTime> dateTimeValues)
                    {
                        foreach (var c in dateTimeValues)
                        {
                            list.Add(c.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                    }
                    break;
                case "Byte":
                    isValueType = true;
                    if (value is IEnumerable<byte> byteValues)
                    {
                        foreach (var c in byteValues)
                        {
                            list.Add(c.ToString(CultureInfo.InvariantCulture));
                        }
                    }
                    break;
                case "Char":
                    if (value is IEnumerable<char> charValues)
                    {
                        foreach (var c in charValues)
                        {
                            list.Add(c.ToString());
                        }
                    }
                    break;
                case "Int16":
                    isValueType = true;
                    if (value is IEnumerable<short> shortValues)
                    {
                        foreach (var c in shortValues)
                        {
                            list.Add(c.ToString());
                        }
                    }
                    break;
                case "Int32":
                    isValueType = true;
                    if (value is IEnumerable<int> intValues)
                    {
                        foreach (var c in intValues)
                        {
                            list.Add(c.ToString());
                        }
                    }
                    break;
                case "Int64":
                    isValueType = true;
                    if (value is IEnumerable<long> longValues)
                    {
                        foreach (var c in longValues)
                        {
                            list.Add(c.ToString());
                        }
                    }
                    break;
                case "Double":
                    isValueType = true;
                    if (value is IEnumerable<double> doubleValues)
                    {
                        foreach (var c in doubleValues)
                        {
                            list.Add(c.ToString(CultureInfo.InvariantCulture));
                        }
                    }
                    break;
                case "Single":
                    isValueType = true;
                    if (value is IEnumerable<float> floatValues)
                    {
                        foreach (var c in floatValues)
                        {
                            list.Add(c.ToString(CultureInfo.InvariantCulture));
                        }
                    }
                    break;
                case "Decimal":
                    isValueType = true;
                    if (value is IEnumerable<decimal> decimalValues)
                    {
                        foreach (var c in decimalValues)
                        {
                            list.Add(c.ToString(CultureInfo.InvariantCulture));
                        }
                    }
                    break;
            }
        }

        if (list!.Count < 1)
            return;

        sqlBuilder.Append(columnName);
        sqlBuilder.Append(notContainer ? " NOT IN (" : " IN (");

        //值类型不带引号
        if (isValueType)
        {
            for (var i = 0; i < list.Count; i++)
            {
                sqlBuilder.AppendFormat("{0}", list[i]);
                if (i != list.Count - 1)
                {
                    sqlBuilder.Append(",");
                }
            }
        }
        else
        {
            for (var i = 0; i < list.Count; i++)
            {
                sqlBuilder.AppendFormat("'{0}'", list[i].Replace("'", "''"));
                if (i != list.Count - 1)
                {
                    sqlBuilder.Append(",");
                }
            }
        }

        sqlBuilder.Append(")");
    }

19 View Source File : GaugeProcsTracker.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public string GetDiamondText(int idx) {
            var proc = Procs[idx];
            return proc.RemainingTime >= 0 ? ((int)Math.Round(proc.RemainingTime)).ToString() : "";
        }

19 View Source File : HttpDeleteController.cs
License : MIT License
Project Creator : 188867052

[HttpDelete]
        public Dictionary<string, string> Delete_1_Nullable_Parameter(int? id)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>
            {
                { "id", id.HasValue ? id.ToString() : null },
                { "url",  nameof(this.Delete_1_Nullable_Constraint) },
            };

            return dictionary;
        }

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

public static Hashtable getThisWeek()
        {
            string sql = "select user_qq,DATE_FORMAT(create_date,'%Y-%m-%d') as date from ichunqiu_user where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(create_date) GROUP BY user_qq,DATE_FORMAT(create_date,'%Y-%m-%d');";
            Hashtable hashtable = new Hashtable();
            MySqlConnection connection = null;
            try
            {
                connection = ConnectionPool.getPool().getConnection();
                // 链接为null就执行等待
                while (connection == null)
                {

                }
                using (MySqlCommand mySqlCommand = new MySqlCommand(sql, connection))
                {
                    // 提取数据
                    using (MySqlDataReader myDataReader = mySqlCommand.ExecuteReader())
                    {
                        while (myDataReader.Read() == true)
                        {
                            string date = myDataReader["date"].ToString();
                            if (hashtable.Contains(date))
                            {
                                hashtable[date] = (Convert.ToInt16(hashtable[date]) + 1).ToString();
                            }
                            else
                            {
                                hashtable.Add(date, "1");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
                ConnectionPool.getPool().closeConnection(connection);
            }
            return hashtable;
        }

19 View Source File : HttpGetController.cs
License : MIT License
Project Creator : 188867052

[HttpGet("{id?}")]
        public Dictionary<string, string> Get_1_Nullable_Constraint(int? id)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>
            {
                { "id", id.HasValue ? id.ToString() : null },
                { "url",  nameof(this.Get_1_Nullable_Constraint) },
            };

            return dictionary;
        }

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

public static KeysetId Baslik(int baslikId, bool validateKeys = false)
        {
            return new KeysetId("CKS_BSL_" + baslikId.ToString(), validateKeys);
        }

19 View Source File : HttpGetController.cs
License : MIT License
Project Creator : 188867052

[Route("~/api/Values/constraint/{id:range(1,10)}")]
        public string GetById(int id)
        {
            return "value:" + id.ToString();
        }

19 View Source File : TableColumn.Types.cs
License : MIT License
Project Creator : 0x1000000

public override string Readreplacedtring(ISqDataRecordReader recordReader)
            => this.ReadNullable(recordReader)?.ToString()
               ?? throw new SqExpressException($"Null value is not expected in non nullable column '{this.ColumnName.Name}'");

19 View Source File : Form1.cs
License : Apache License 2.0
Project Creator : 1694439208

private void button1_Click(object sender, EventArgs e)
        {
            ModuleAddress = getModule(textBox1.Text);
            label1.Text = ModuleAddress.ToString();
        }

19 View Source File : CooldownTracker.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public void TickUI(UICooldownItem ui, float percent) {
            if (State == TrackerState.None) {
                ui.SetOffCD();
                ui.SetNoDash();
                ui.SetText("");
            }
            else if (State == TrackerState.Running) {
                ui.SetOffCD();
                ui.SetDash(percent);
                ui.SetText(((int)Math.Round(TimeLeft)).ToString());
            }
            else if (State == TrackerState.OnCD) {
                ui.SetOnCD();
                ui.SetNoDash();
                ui.SetText(((int)Math.Round(TimeLeft)).ToString());
            }
            else if (State == TrackerState.OffCD) {
                ui.SetOffCD();
                ui.SetNoDash();
                ui.SetText("");
            }
        }

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

public static void Init(int minNegativeValue, int maxPositiveValue)
        {
            if (minNegativeValue <= 0)
            {
                int length = Mathf.Abs(minNegativeValue);
                negativeBuffer = new string[length];
                for (int i = 0; i < length; i++)
                {
                    negativeBuffer[i] = (-i).ToString();
                }
            }
            if (maxPositiveValue >= 0)
            {
                positiveBuffer = new string[maxPositiveValue];
                for (int i = 0; i < maxPositiveValue; i++)
                {
                    positiveBuffer[i] = i.ToString();
                }
            }
        }

19 View Source File : TableColumnsTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public void TestByte()
        {
            replacedert.AreEqual(SqQueryBuilder.SqlType.Byte, this.Table.ColByte.SqlType);
            replacedert.AreEqual("[AT].[ColByte]", this.Table.ColByte.ToSql());
            replacedert.IsFalse(this.Table.ColByte.IsNullable);

            DerivedTable dt = new DerivedTable();
            var customColumn = this.Table.ColByte.AddToDerivedTable(dt);
            replacedert.AreEqual(this.Table.ColByte.ColumnName, customColumn.ColumnName);
            replacedert.IsTrue(dt.Columns.Contains(customColumn));

            var customColumn2 = this.Table.ColByte.ToCustomColumn(this.NewSource);
            replacedert.AreEqual(this.Table.ColByte.ColumnName, customColumn2.ColumnName);

            var reader = new Mock<ISqDataRecordReader>();

            this.Table.ColByte.Read(reader.Object);
            customColumn.Read(reader.Object);

            reader.Verify(r => r.GetByte(It.Is<string>(name => name == customColumn.ColumnName.Name)), Times.Exactly(2));

            replacedert.Throws<SqExpressException>(() => this.Table.ColByte.Readreplacedtring(reader.Object));
            reader.Setup(r => r.GetNullableByte(It.Is<string>(name => name == customColumn.ColumnName.Name))).Returns(255);
            replacedert.AreEqual(255.ToString(), this.Table.ColByte.Readreplacedtring(reader.Object));

            replacedert.AreEqual("255", this.Table.ColByte.FromString("255").ToSql());
            replacedert.Throws<SqExpressException>(() => this.Table.ColByte.FromString(null));
        }

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

public override bool Process()
        {
            ViewQueryResult queryResult;
            int pageNumber, baslikId;
            bool latest = false;

            pageNumber = GetValue<int>("pagenum");
            baslikId = GetValue<int>("bid");

            if (HasKey("latest"))
                latest = true;

            if (baslikId < 0)
                baslikId = 0;

            if (pageNumber > 0)
                pageNumber--;
            else
                pageNumber = 0;

            if (latest && baslikId > 0)
            {
                BaslikBasicInfo bbi;

                if (CacheManager.TryGetCachedResult<BaslikBasicInfo>("BBI_" + baslikId.ToString(), out bbi))
                {
                    pageNumber = SozlukDataStore.CalcPageCount(bbi.TotalEntries,RecordPerPageType.Entries) - 1;
                }

            }

            queryResult = SozlukDataStore.FetchEntriesOfBaslik(
                GetValue<string>("baslik"),
                baslikId,
                pageNumber);

            if (queryResult.HasEntry)
            {

                PushResponseItem("RecordCount", queryResult.PhysicalRecordCount);
                PushResponseItem("TotalPageCount", SozlukDataStore.CalcPageCount(queryResult.TotalRecordCount,RecordPerPageType.Entries));
                PushResponseItem("RecordsPerPage", SozlukDataStore.RecordsPerPage);
                PushResponseItem("CurrentPageNum", pageNumber + 1);
                PushResponseItem("BaslikId", queryResult.BaslikId);
                PushResponseItem("Baslik", queryResult.Entries[0].Baslik);


                foreach (var entry in queryResult.Entries)
                    PushResponseContent(entry.GetTransportString());
            }
            else
            {
                PushResponseItem("RecordCount", 0);
            }

            return true;
        }

19 View Source File : BuffTracker.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public void TickUI(UIBuff ui) {
            if (UI != ui || UI?.Iconid != Config.Icon) {
                UI = ui;
                SetupUI();
            }

            UI.Show();

            if (State == BuffState.Running) {
                UI.SetOffCD();
                UI.SetPercent(Percent);
                UI.SetText(((int)Math.Round(TimeLeft)).ToString());
            }
            else if (State == BuffState.OffCD) {
                UI.SetOffCD();
                UI.SetPercent(0);
                UI.SetText("");
            }
            else if (State == BuffState.OnCD_Visible) {
                UI.SetOnCD();
                UI.SetPercent(Percent);
                UI.SetText(((int)Math.Round(TimeLeft)).ToString());
            }
        }

19 View Source File : GaugeMPTracker.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

protected override void TickTracker() {
            var mp = JobBars.ClientState.LocalPlayer.CurrentMp;
            Value = mp / 10000f;
            TextValue = ((int)(mp / 100)).ToString();
        }

19 View Source File : UIIconTimer.cs
License : GNU Affero General Public License v3.0
Project Creator : 0ceal0t

public override void SetProgress(float current, float max) {
            if (State == IconState.TimerDone && current <= 0) return;
            State = IconState.TimerRunning;

            UIHelper.Show(Text);
            Text->SetText(((int)Math.Round(current)).ToString());

            UIHelper.Show(Ring);
            Ring->PartId = (ushort)(80 - (float)(current / max) * 80);

            JobBars.IconBuilder.AddIconOverride(new IntPtr(OriginalImage));
            SetDimmed(true);
        }

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

public void ProcessGroupMessage(GroupMessageReceivedContext context)
        {
            String message = context.Message;
            message = message.Trim();
            if (message == "" || message.Length == 0 || message == null)
            {
                return;
            }
            String myQQ = _mahuaApi.GetLoginQq();
            String aiteQQ = "[CQ:at,qq=" + myQQ + "]";
            if (message.Contains(aiteQQ)) {
                String sendMessage = "[CQ:at,qq=" + context.FromQq + "]";
                message = message.Replace(aiteQQ, "").Replace("\"\"","").Replace("“","").Replace("”","").Trim();
                IDatabase redis = RedisHelper.getRedis();
                // 判断用户是否在缓冲中
                if (redis.StringGet(context.FromQq).IsNull)
                {
                    redis.StringSet(context.FromQq, "flag");
                    redis.KeyExpire(context.FromQq, new TimeSpan(10000000 * Convert.ToInt16(Constants.sleepTime)));
                }
                else {
                    string tmpStr = "为防止造成刷屏,您每次使用机器人的时间间隔"+ Constants.sleepTime + "秒哦!";
                    sendMessage += tmpStr;
                    _mahuaApi.SendGroupMessage(context.FromGroup, sendMessage);
                    return;
                };
                if (message == null || message =="" || message.Length == 0) {
                    //
                }
                else
                {
                    MessageModel messageModel = MessageController.main(message, context.FromQq);
                    // 发送消息
                    string tmpStr = messageModel.SendMessage;
                    if (messageModel.IsAdmin) {
                        // 群数量
                        if (MessageConstant.QUN_TOTAL.Equals(messageModel.Code))
                        {
                            ModelWithSourceString<IEnumerable<GroupInfo>> modelWithSourceString = _mahuaApi.GetGroupsWithModel();
                            IEnumerable<GroupInfo> groupInfo = modelWithSourceString.Model;
                            int count = 0;
                            foreach (var item in groupInfo)
                            {
                                count ++;
                            }
                            _mahuaApi.SendGroupMessage(context.FromQq, "群数量:" + count.ToString());
                        }
                        else
                        {
                            if (tmpStr != "" && tmpStr.Length > 0)
                            {
                                sendMessage += tmpStr;
                                _mahuaApi.SendGroupMessage(context.FromQq, sendMessage);
                            }
                        }
                    }
                    else
                    {
                        if (tmpStr != "" && tmpStr.Length > 0)
                        {
                            sendMessage += tmpStr;
                            _mahuaApi.SendGroupMessage(context.FromGroup, sendMessage);
                        }
                    }
                }
            }
        }

19 View Source File : Rational.cs
License : MIT License
Project Creator : 0xC0000054

public override string ToString()
        {
            return this.Numerator.ToString() + "/" + this.Denominator.ToString();
        }

See More Examples