当前位置: 首页>>代码示例>>C#>>正文


C# StringBuffer.ToString方法代码示例

本文整理汇总了C#中StringBuffer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuffer.ToString方法的具体用法?C# StringBuffer.ToString怎么用?C# StringBuffer.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringBuffer的用法示例。


在下文中一共展示了StringBuffer.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ByteArrayToHexString

        private static string ByteArrayToHexString(byte[] b)
        {
            StringBuffer resultSb = new StringBuffer();
            for (int i = 0; i < b.Length; i++)
                resultSb.Append(ByteToHexString(b[i]));

            return resultSb.ToString();
        }
开发者ID:MicahelWang,项目名称:XamarinSamples,代码行数:8,代码来源:MD5Util.cs

示例2: Test1

		public void Test1()
		{
			StringBuffer buf = new StringBuffer(100);
			
			Assert.AreEqual(0, buf.Length);
			Assert.AreEqual("", buf.ToString());
			
			buf.Append('a');
			buf.Append('b');
			buf.Append('c');
			
			Assert.AreEqual(3, buf.Length);
			Assert.AreEqual("abc", buf.ToString());
			
			buf.Clear();
			
			Assert.AreEqual(0, buf.Length);
			Assert.AreEqual("", buf.ToString());
		}
开发者ID:kaijin-games,项目名称:larning-english-game,代码行数:19,代码来源:HtmlParserTest.cs

示例3: BanUser

        public override void BanUser(string operatorname, BanType bantype, DateTime operationtime, string cause, Dictionary<int, DateTime> foruminfos, int userid, string targetname, string userip)
        {
            using (SqlQuery query = new SqlQuery())
            {
                StringBuffer sqlBuffer = new StringBuffer();
                sqlBuffer += "DELETE FROM bx_BannedUsers WHERE UserID = @UserID;";
                sqlBuffer += "INSERT INTO bx_BanUserLogs(OperationType,OperationTime,OperatorName,Cause,UserID,Username,UserIP,AllBanEndDate) Values(@OperationType,@OperationTime,@OperatorName,@Cause,@UserID,@Username,@UserIP,@AllBanEndDate);DECLARE @logid int;SELECT @[email protected]@IDENTITY;";
                foreach (KeyValuePair<int, DateTime> forumBanInfo in foruminfos)
                {
                    sqlBuffer += string.Format("INSERT INTO bx_BannedUsers( UserID, ForumID, EndDate, Cause ) VALUES(@UserID , @ForumID{0},@EndDate{0}, @Cause);", forumBanInfo.Key);
                    sqlBuffer += string.Format("INSERT INTO bx_BanUserLogForumInfos(LogID,ForumID,ForumName,EndDate) Select @logid,@ForumID{0},ForumName,@EndDate{0} FROM [bx_Forums] WHERE [email protected]{0};", forumBanInfo.Key);
                    query.CreateParameter<int>(string.Format("@ForumID{0}", forumBanInfo.Key), forumBanInfo.Key, SqlDbType.Int);
                    query.CreateParameter<DateTime>(string.Format("@EndDate{0}", forumBanInfo.Key), forumBanInfo.Value, SqlDbType.DateTime);
                }
                query.CreateParameter<int>("@OperationType", (int)bantype, SqlDbType.Int);
                query.CreateParameter<DateTime>("@OperationTime", operationtime, SqlDbType.DateTime);
                query.CreateParameter<string>("@OperatorName", operatorname, SqlDbType.NVarChar, 50);
                query.CreateParameter<string>("@Cause", cause, SqlDbType.NVarChar, 1000);
                query.CreateParameter<int>("@UserID", userid, SqlDbType.Int);
                query.CreateParameter<string>("@Username", targetname, SqlDbType.NVarChar, 50);
                query.CreateParameter<string>("@UserIP", userip, SqlDbType.NVarChar, 50);

                DateTime allBanEndDate;
                if (foruminfos.TryGetValue(0, out allBanEndDate))
                {
                    query.CreateParameter<DateTime>("@AllBanEndDate", allBanEndDate, SqlDbType.DateTime);
                }
                else
                {
                    query.CreateParameter<DateTime>("@AllBanEndDate", DateTime.MaxValue, SqlDbType.DateTime);
                }

                query.CommandText = sqlBuffer.ToString();
                query.ExecuteNonQuery();
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:36,代码来源:BannedUserDao.cs

示例4: BuildConditionsByFilter

        private string BuildConditionsByFilter(SqlQuery query, AdminAlbumFilter filter, int operatorUserID, IEnumerable<Guid> excludeRoleIds, bool startWithWhere)
        {

            StringBuffer sqlConditions = new StringBuffer();

            if (filter.AlbumID != null)
            {
                sqlConditions += " AND [AlbumID] = @AlbumID";
                query.CreateParameter<int?>("@AlbumID", filter.AlbumID, SqlDbType.Int);
            }
            if (filter.AuthorID != null)
            {
                sqlConditions += " AND [UserID] = @UserID";
                query.CreateParameter<int?>("@UserID", filter.AuthorID, SqlDbType.Int);
            }
            if (filter.PrivacyType != null)
            {
                sqlConditions += " AND [PrivacyType] = @PrivacyType";
                query.CreateParameter<PrivacyType?>("@PrivacyType", filter.PrivacyType, SqlDbType.TinyInt);
            }
            if (filter.BeginDate != null)
            {
                sqlConditions += " AND [CreateDate] >= @BeginDate";
                query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime);
            }
            if (filter.EndDate != null)
            {
                sqlConditions += " AND [CreateDate] <= @EndDate";
                query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime);
            }
            if (string.IsNullOrEmpty(filter.Username) == false)
            {
                sqlConditions += " AND [UserID] = (SELECT [UserID] FROM [bx_Users] WHERE [Username] = @Username)";
                query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
            }
            if (string.IsNullOrEmpty(filter.Name) == false)
            {
                sqlConditions += " AND ([Name] LIKE '%' + @Key + '%')";
                query.CreateParameter<string>("@Key", filter.Name, SqlDbType.NVarChar, 50);
            }

            string excludeRolesSql = DaoUtil.GetExcludeRoleSQL("[UserID]", "[LastEditUserID]", operatorUserID, excludeRoleIds, query);

            if (string.IsNullOrEmpty(excludeRolesSql) == false)
                sqlConditions += " AND " + excludeRolesSql;

            if (sqlConditions.Length > 0)
            {
                sqlConditions.Remove(0, 5);
                if (startWithWhere)
                    sqlConditions.InnerBuilder.Insert(0, " WHERE ");
            }

            return sqlConditions.ToString();
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:55,代码来源:AlbumDao.cs

示例5: DeleteAlbumsBySearch

        public override DeleteResult DeleteAlbumsBySearch(AdminAlbumFilter filter, int operatorID, IEnumerable<Guid> excludeRoleIDs, int topCount, out int deletedCount, out int[] deletedPhotoIDs)
        {
            deletedCount = 0;

            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, operatorID, excludeRoleIDs, true);

                StringBuffer sql = new StringBuffer();

                sql += @"
DECLARE @DeleteData table (UserID int, AlbumID int, PhotoCount int);

INSERT INTO @DeleteData SELECT TOP (@TopCount) [UserID],[A].[AlbumID],(SELECT COUNT(*) FROM [bx_Photos] AS [B] WHERE [B].[AlbumID]=[A].[AlbumID]) FROM [bx_Albums] AS [A] " + conditions + @";

DECLARE @DeletePhotos table (PhotoID int);

INSERT INTO @DeletePhotos SELECT PhotoID from bx_Photos WHERE AlbumID IN (SELECT [AlbumID] FROM @DeleteData);

DELETE [bx_Albums] WHERE [AlbumID] IN (SELECT [AlbumID] FROM @DeleteData);

SELECT @@ROWCOUNT;

SELECT [UserID],SUM([PhotoCount]) AS [Count] FROM @DeleteData GROUP BY [UserID];

SELECT [PhotoID] FROM @DeletePhotos;";

                query.CreateTopParameter("@TopCount", topCount);

                query.CommandText = sql.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DeleteResult deleteResult = new DeleteResult();

                    if (reader.Read())
                        deletedCount = reader.Get<int>(0);

                    reader.NextResult();

                    while (reader.Read())
                    {
                        deleteResult.Add(reader.Get<int>("UserID"), reader.Get<int>("Count"));
                    }

                    reader.NextResult();

                    List<int> deletePhotos = new List<int>();

                    while (reader.Read())
                    {
                        deletePhotos.Add(reader.Get<int>(0));
                    }

                    deletedPhotoIDs = deletePhotos.ToArray();

                    return deleteResult;
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:60,代码来源:AlbumDao.cs

示例6: buf2String

        /**
         * convert byte array to Hex String.
         *
         * @param info - the propmt String
         * @param buf - the byte array which will be converted
         * @param offset - the start position of buf
         * @param length - the converted length
         * @param isOneLine16 - if true 16 bytes one line, false all bytes in one line
         * @return Hex String
         */
        public static string buf2String(string info, byte[] buf, int offset,
			int length, bool oneLine16)
        {
            int i, index;

            StringBuffer sBuf = new StringBuffer();
            sBuf.Append(info);

            for (i = 0 + offset; i < length + offset; i++)
            {
                if (i % 16 == 0)
                {
                    if (oneLine16)
                    {
                        sBuf.Append(lineSeperate);
                    }
                } else if (i % 8 == 0)
                {
                    if (oneLine16)
                    {
                        sBuf.Append("   ");
                    }
                }
                index = buf[i] < 0 ? buf[i] + DEFAULT_TABLE_LENGTH : buf[i];
                sBuf.Append(convertTable[index]);
            }
            return sBuf.ToString();
        }
开发者ID:Coopermine,项目名称:P25M_PRINTER,代码行数:38,代码来源:ByteConverter.cs

示例7: TabKey

        void TabKey()
        {
            int pos = caretPos == -1 ? buffer.Length - 1 : caretPos;
            int start = pos;
            char[] value = buffer.value;

            while( start >= 0 && IsNameChar( value[start] ) )
                start--;
            start++;
            if( pos < 0 || start > pos ) return;

            string part = new String( value, start, pos + 1 - start );
            List<string> matches = new List<string>();
            game.Chat.Add( null, MessageType.ClientStatus5 );

            bool extList = game.Network.UsingExtPlayerList;
            CpeListInfo[] info = game.CpePlayersList;
            Player[] players = game.Players.Players;
            for( int i = 0; i < EntityList.MaxCount; i++ ) {
                if( extList && info[i] == null ) continue;
                if( !extList && players[i] == null ) continue;

                string rawName = extList ? info[i].PlayerName : players[i].DisplayName;
                string name = Utils.StripColours( rawName );
                if( name.StartsWith( part, StringComparison.OrdinalIgnoreCase ) )
                    matches.Add( name );
            }

            if( matches.Count == 1 ) {
                if( caretPos == -1 ) pos++;
                int len = pos - start;
                for( int i = 0; i < len; i++ )
                    buffer.DeleteAt( start );
                if( caretPos != -1 ) caretPos -= len;
                AppendText( matches[0] );
            } else if( matches.Count > 1 ) {
                StringBuffer sb = new StringBuffer( 64 );
                int index = 0;
                sb.Append( ref index, "&e" );
                sb.AppendNum( ref index, matches.Count );
                sb.Append( ref index, " matching names: " );

                foreach( string match in matches ) {
                    if( (match.Length + 1 + sb.Length) > LineLength ) break;
                    sb.Append( ref index, match );
                    sb.Append( ref index, ' ' );
                }
                game.Chat.Add( sb.ToString(), MessageType.ClientStatus5 );
            }
        }
开发者ID:Retatta,项目名称:ClassicalSharp,代码行数:50,代码来源:TextInputWidget.Handlers.cs

示例8: BuildConditionsByFilter

        private string BuildConditionsByFilter(SqlQuery query, AdminTagFilter filter)
        {
            StringBuffer sqlConditions = new StringBuffer();

            if (string.IsNullOrEmpty(filter.Name))
            {
                sqlConditions += " AND [Name] Like '%' + @Name + '%'";
                query.CreateParameter<string>("@Name", filter.Name, SqlDbType.NVarChar, 50);
            }

            if (filter.Type != null)
            {
                sqlConditions += " AND ([ID] IN (SELECT [TagID] FROM [bx_TagRelation] WHERE [Type] = @Type))";
                query.CreateParameter<TagType?>("@Type", filter.Type, SqlDbType.TinyInt);
            }

            if (filter.IsLock != null)
            {
                sqlConditions += " AND [IsLock] = @IsLock";
                query.CreateParameter<bool?>("@IsLock", filter.IsLock, SqlDbType.Bit);
            }

            if (filter.TotalElementsScopeBegin != null && filter.TotalElementsScopeEnd != null)
            {
                sqlConditions += " AND ([TotalElements] >= @TotalElementsBegin AND [TotalElements] <= @TotalElementsEnd)";
                query.CreateParameter<int?>("@TotalElementsBegin", filter.TotalElementsScopeBegin, SqlDbType.Int);
                query.CreateParameter<int?>("@TotalElementsEnd", filter.TotalElementsScopeEnd, SqlDbType.Int);
            }

            if (sqlConditions.Length > 0)
                sqlConditions.Remove(0, 5);

            return sqlConditions.ToString();
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:34,代码来源:TagDao.cs

示例9: DeleteBlogCategoriesBySearch

        public override DeleteResult DeleteBlogCategoriesBySearch(AdminBlogCategoryFilter filter, bool deleteArticle, int operatorUserID, IEnumerable<Guid> excludeRoleIDs, int topCount, out int deletedCount)
        {

            deletedCount = 0;

            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, excludeRoleIDs, true);

                StringBuffer sql = new StringBuffer();

                sql += @"
DECLARE @DeleteData table (UserID int, [CategoryID] int, [ArticleCount] int);

INSERT INTO @DeleteData SELECT TOP (@TopCount) [A].[UserID],[A].[CategoryID],(SELECT COUNT(*) FROM [bx_BlogArticles] AS [B] WHERE [B].[CategoryID]=[A].[CategoryID]) FROM [bx_BlogCategories] AS [A] " + conditions + ";";

                if (deleteArticle)
                {

                    sql += @"
DELETE [bx_BlogArticles] WHERE [CategoryID] IN (SELECT [CategoryID] FROM @DeleteData);";

                }
                else
                {

                    sql += @"
UPDATE [bx_BlogArticles] SET [CategoryID] = 0 WHERE [CategoryID] IN (SELECT [CategoryID] FROM @DeleteData);";

                }

                sql += @"
DELETE [bx_BlogCategories] WHERE [CategoryID] IN (SELECT [CategoryID] FROM @DeleteData);

SELECT @@ROWCOUNT;

SELECT [UserID],SUM([ArticleCount]) AS [Count] FROM @DeleteData GROUP BY [UserID];";

                query.CreateTopParameter("@TopCount", topCount);

                query.CommandText = sql.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DeleteResult deleteResult = new DeleteResult();

                    if (reader.Read())
                        deletedCount = reader.Get<int>(0);

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            deleteResult.Add(reader.Get<int>("UserID"), reader.Get<int>("Count"));
                        }
                    }

                    return deleteResult;
                }
            }

        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:62,代码来源:BlogDao.cs

示例10: DeleteImpressionRecordsForAdmin

        public override bool DeleteImpressionRecordsForAdmin(AdminImpressionRecordFilter filter, int topCount, out int deletedCount)
        {
            deletedCount = 0;

            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildCondition(query, filter);

                StringBuffer sql = new StringBuffer();

                sql += @"
DECLARE @DeleteData table (RecordID int);

INSERT INTO @DeleteData SELECT TOP (@TopCount) [RecordID] FROM [bx_ImpressionRecords] WHERE " + conditions + @";

DELETE [bx_ImpressionRecords] WHERE TypeID IN (SELECT [RecordID] FROM @DeleteData);

SELECT @@ROWCOUNT;";

                query.CreateTopParameter("@TopCount", topCount);

                query.CommandText = sql.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DeleteResult deleteResult = new DeleteResult();

                    if (reader.Read())
                        deletedCount = reader.Get<int>(0);

                    return true;
                }
            }
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:34,代码来源:ImpressionDao.cs

示例11: GetFinishConditionDescription

        public override string GetFinishConditionDescription(StringTable values)
        {
            StringBuffer description = new StringBuffer();

            string value_Timeout = values[input_Timeout];
            string value_Action = values[input_Action];
            string value_Count = values[input_Count];

            if (string.IsNullOrEmpty(value_Timeout) == false && value_Timeout != "0")
                description += "从申请任务开始计时," + value_Timeout + " 小时内,";

            if (value_Action == "1")
            {
                description += "发表文章";
            }
            else if (value_Action == "2")
            {
                string value_ArticleID = values[input_ArticleID];

                if (string.IsNullOrEmpty(value_ArticleID) == false)
                {
                    BlogArticle article = BlogBO.Instance.GetBlogArticle(int.Parse(value_ArticleID));


                    description += "评论博客文章:<a href=\"" + UrlHelper.GetBlogArticleUrl(article.ArticleID) + "\">" + article.Subject + "</a>,";
                }
                else
                {
                    string value_UserID = values[input_UserID];

                    User user = UserBO.Instance.GetUser(int.Parse(value_UserID));

                    description += "评论用户:" + user.PopupNameLink + " 的博客文章,";
                }
            }

            description += "达到" + value_Count + "次。";

            return description.ToString();
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:40,代码来源:DefaultMissions.cs

示例12: BuildCondition

        private string BuildCondition(SqlQuery query, AdminImpressionTypeFilter filter)
        {
            StringBuffer condition = new StringBuffer();

            if (string.IsNullOrEmpty(filter.SearchKey) == false)
            {
                condition += "[Text] LIKE '%' + @SearchKey + '%'";
                query.CreateParameter<string>("@SearchKey", filter.SearchKey, SqlDbType.NVarChar, 100);
            }

            return condition.ToString();
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:12,代码来源:ImpressionDao.cs

示例13: mutate

        private String mutate(String individual)
        {
            StringBuffer mutInd = new StringBuffer(individual);

            int posOffset = randomOffset(individualLength);
            int charOffset = randomOffset(finiteAlphabet.length);

            mutInd.setCharAt(posOffset, finiteAlphabet[charOffset]);

            return mutInd.ToString();
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:11,代码来源:GeneticAlgorithm.cs

示例14: dump

        public static string dump(byte[] abyte0, int beginIndex, int endIndex, bool spaceFlag, bool asciiFlag, bool lineNumberFlag, int linenumber)
        {
            byte[] cont = abyte0;
            if(abyte0 == null || cont.Length  == 0)
                return "";

            string outMsg = "";
            int totalLine = (endIndex - beginIndex) / 16;
            int lineNumber, q;
            int offset = beginIndex;
            byte byte0;
            StringBuffer stringbuffer = new StringBuffer(6 + (spaceFlag?48:32));
            StringBuffer asciibuffer = new StringBuffer();
            string printString;
            int stringcount;
            int asccicount;

            if (linenumber < 0)
                linenumber = 0;
            else
                linenumber = linenumber % 10000;

            for(int i = 0; i <= totalLine; i++, linenumber++)
            {
                if (offset < endIndex) {
                    stringcount = stringbuffer.Length();
                    asccicount = asciibuffer.Length();
                    stringbuffer.Delete(0, stringcount);
                    asciibuffer.Delete(0, asccicount);
                    if (lineNumberFlag) {
                        stringbuffer.Append("0000: ");
                        lineNumber = linenumber;
                        for(byte0 = 3; byte0 >=0; byte0--){
                            q = (lineNumber * 52429) >> (16+3);
                            stringbuffer.SetCharAt(byte0, toHexChar(lineNumber - ((q << 3) + (q << 1)))); // toHexChar(lineNumber-(q*10))
                            lineNumber = q;
                            if (0 == lineNumber) break;
                        }
                    }
                    for(int j = 0; j < 16; j++, offset++)
                    {
                        if (offset < endIndex) {
                            byte0 = abyte0[offset];
                            stringbuffer.Append(toHexChar(byte0 >> 4));
                            stringbuffer.Append(toHexChar(byte0));
                            if (spaceFlag)
                                stringbuffer.Append(' ');
                            if (asciiFlag) {
                                if (byte0 >= 0x20 && byte0 <= 0x7E)
                                    asciibuffer.Append((char)byte0);
                                else
                                    asciibuffer.Append('.');
                            }
                        } else {
                            stringbuffer.Append(' ');
                            stringbuffer.Append(' ');
                            if (spaceFlag)
                                stringbuffer.Append(' ');
                        }
                    }
                    if (asciiFlag)
                        printString = stringbuffer.ToString() + "; " + asciibuffer.ToString();
                    else
                        printString = stringbuffer.ToString();
                    //        printLine(printString);
                    outMsg =  outMsg + printString + "\n";
                } else {
                    break;
                }
            }
            printString = null;
            stringbuffer = asciibuffer = null;
            return outMsg;
        }
开发者ID:Coopermine,项目名称:P25M_PRINTER,代码行数:74,代码来源:Tracer.cs

示例15: ToString

 /// <summary>
 /// Convert the numeric value of each array element to a hex string divided by '-'.
 /// </summary>
 public static string ToString(byte[] value, int index, int length)
 {
     if (value == null)
         throw new ArgumentNullException("value");
     if (index < 0)
         throw new ArgumentOutOfRangeException("index");
     if (length < 0)
         throw new ArgumentOutOfRangeException("length");
     if (index + length > value.Length)
         throw new ArgumentException("length");
     var buffer = new StringBuffer();
     for (var i = 0; i < length; i++)
     {
         if (i > 0)
             buffer.Append('-');
         var hex = int.ToHexString((int) value[index + i]);
         if (hex.Length == 1)
             buffer.Append('0');
         buffer.Append(hex);
     }
     return buffer.ToString();
 }
开发者ID:nguyenkien,项目名称:api,代码行数:25,代码来源:BitConverter.cs


注:本文中的StringBuffer.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。