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


C# SortedDictionary.GetEnumerator方法代码示例

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


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

示例1: BuildXml

 public static string BuildXml(IDictionary<string, string> dict, bool encode)
 {
     SortedDictionary<string, string> dictionary = new SortedDictionary<string, string>(dict);
     StringBuilder builder = new StringBuilder();
     builder.AppendLine("<xml>");
     IEnumerator<KeyValuePair<string, string>> enumerator = dictionary.GetEnumerator();
     while (enumerator.MoveNext())
     {
         KeyValuePair<string, string> current = enumerator.Current;
         string key = current.Key;
         current = enumerator.Current;
         string str2 = current.Value;
         if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(str2))
         {
             decimal result = 0M;
             bool flag = false;
             if (!decimal.TryParse(str2, out result))
             {
                 flag = true;
             }
             if (encode)
             {
                 builder.AppendLine("<" + key + ">" + (flag ? "<![CDATA[" : "") + HttpUtility.UrlEncode(str2, Encoding.UTF8) + (flag ? "]]>" : "") + "</" + key + ">");
             }
             else
             {
                 builder.AppendLine("<" + key + ">" + (flag ? "<![CDATA[" : "") + str2 + (flag ? "]]>" : "") + "</" + key + ">");
             }
         }
     }
     builder.AppendLine("</xml>");
     return builder.ToString();
 }
开发者ID:ZhangVic,项目名称:asp1110git,代码行数:33,代码来源:SignHelper.cs

示例2: GetSignRequest

        public static string GetSignRequest(Dictionary<string, string> parameters)
        {
            IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters);
            IEnumerator<KeyValuePair<string, string>> dem = sortedParams.GetEnumerator();

            StringBuilder query = new StringBuilder();
            while (dem.MoveNext())
            {
                string key = dem.Current.Key;
                string value = dem.Current.Value;
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
                {
                    query.Append(key).Append("=").Append(value).Append("&");
                }
            }
            string requstString = query.ToString();
            if (requstString.Contains("&"))
            {
                requstString = requstString.Remove(requstString.Length - 1);
            }

            var sha1 = System.Security.Cryptography.SHA1.Create();
            var sha1Arr = sha1.ComputeHash(Encoding.UTF8.GetBytes(requstString));
            StringBuilder enText = new StringBuilder();
            foreach (var b in sha1Arr)
            {
                enText.AppendFormat("{0:x2}", b);
            }
            return enText.ToString();
        }
开发者ID:szoliver,项目名称:wxpay,代码行数:30,代码来源:wxpay.cs

示例3: Delta

        /// <summary>
        /// Computes delta values (the differences) between values in one dictionary and another dictionary. 
        /// The keys in both dictionary has to match. 
        /// </summary>
        /// <param name="valuesOne">The values one.</param>
        /// <param name="valuesTwo">The values two.</param>
        /// <exception cref="ArgumentException">If count of values in two given dictionaries do not match</exception>
        /// <exception cref="ArgumentException">If keys in two dictionaries do not match</exception>
        /// <returns></returns>
        public static SortedDictionary<string, double> Delta(SortedDictionary<string, double> valuesOne, SortedDictionary<string, double> valuesTwo)
        {
            if (valuesOne.Count != valuesTwo.Count)
            {
                throw new ArgumentException("The count of results from two techniques are different.");
            }

            IEnumerator<KeyValuePair<string, double>> iter1 = valuesOne.GetEnumerator();
            IEnumerator<KeyValuePair<string, double>> iter2 = valuesTwo.GetEnumerator();

            while (iter1.MoveNext() && iter2.MoveNext())
            {
                string queryid1 = iter1.Current.Key;
                string queryid2 = iter2.Current.Key;
                if (queryid1.Equals(queryid2) == false)
                {
                    throw new ArgumentException("The query ids in both collections do not match");
                }
            }

            SortedDictionary<string, double> differencesResults = new SortedDictionary<string, double>();

            foreach (KeyValuePair<string, double> pair in valuesOne)
            {
                string queryId = pair.Key;
                double score = pair.Value;
                double score2 = valuesTwo[queryId];

                differencesResults.Add(queryId, score2 - score); //substract from new technique value the baseline value
            }

            return differencesResults;
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:42,代码来源:ScoreComputationHelper.cs

示例4: BuildQuery

 public static string BuildQuery(IDictionary<string, string> dict, bool encode)
 {
     SortedDictionary<string, string> dictionary = new SortedDictionary<string, string>(dict);
     StringBuilder builder = new StringBuilder();
     bool flag = false;
     IEnumerator<KeyValuePair<string, string>> enumerator = dictionary.GetEnumerator();
     while (enumerator.MoveNext())
     {
         KeyValuePair<string, string> current = enumerator.Current;
         string key = current.Key;
         current = enumerator.Current;
         string str2 = current.Value;
         if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(str2))
         {
             if (flag)
             {
                 builder.Append("&");
             }
             builder.Append(key);
             builder.Append("=");
             if (encode)
             {
                 builder.Append(HttpUtility.UrlEncode(str2, Encoding.UTF8));
             }
             else
             {
                 builder.Append(str2);
             }
             flag = true;
         }
     }
     return builder.ToString();
 }
开发者ID:ZhangVic,项目名称:asp1110git,代码行数:33,代码来源:SignHelper.cs

示例5: GetSignature

        /// <summary>
        /// 计算参数签名
        /// </summary>
        /// <param name="params">请求参数集,所有参数必须已转换为字符串类型</param>
        /// <param name="secret">签名密钥</param>
        /// <returns>签名</returns>
        public static string GetSignature(IDictionary<string, string> parameters, string secret, string url)
        {
            // 先将参数以其参数名的字典序升序进行排序
            IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters);
            IEnumerator<KeyValuePair<string, string>> iterator = sortedParams.GetEnumerator();

            // 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
            StringBuilder basestring = new StringBuilder();
            WebRequest request = WebRequest.Create(url);
            basestring.Append("POST").Append(request.RequestUri.Host).Append(request.RequestUri.AbsolutePath);
            while (iterator.MoveNext())
            {
                string key = iterator.Current.Key;
                string value = iterator.Current.Value;
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
                {
                    basestring.Append(key).Append("=").Append(value);
                }
            }
            basestring.Append(secret);

            // 使用MD5对待签名串求签
            MD5 md5 = MD5.Create();
            byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(basestring.ToString()));

            // 将MD5输出的二进制结果转换为小写的十六进制
            StringBuilder result = new StringBuilder();
            foreach (byte b in bytes)
            {
                result.Append(b.ToString("x2").ToLower());
            }
            return result.ToString();
        }
开发者ID:kinshines,项目名称:XinGePush,代码行数:39,代码来源:SignUtility.cs

示例6: GetEnumerator

 /// <summary>
 /// Gets the <see cref="IEnumerator{T}"/>.
 /// </summary>
 /// <returns>The <see cref="IEnumerator{T}"/>.</returns>
 public IEnumerator<Scene> GetEnumerator()
 {
     Scene[] scenes;
     lock (this.scenes)
     {
         scenes = this.scenes.Values.ToArray();
     }
     return (IEnumerator<Scene>)scenes.GetEnumerator();
 }
开发者ID:ScianGames,项目名称:Engine,代码行数:13,代码来源:SceneManager.cs

示例7: Execute

        public override void Execute()
        {
            SortedDictionary<int, int> counts = new SortedDictionary<int, int>();
            SortedDictionary<string, int> results = new SortedDictionary<string, int>();
            if (_wvm.CurrentWorld == null)
                return;

            int x0 = 0;
            int y0 = 0;
            int xN = _wvm.CurrentWorld.TilesWide;
            int yN = _wvm.CurrentWorld.TilesHigh;
            if (_wvm.Selection.IsActive) {
                x0 = _wvm.Selection.SelectionArea.Left;
                y0 = _wvm.Selection.SelectionArea.Top;
                xN = _wvm.Selection.SelectionArea.Right;
                yN = _wvm.Selection.SelectionArea.Bottom;
            }
            for (int x = x0; x < xN; x++) {
                for (int y = y0; y < yN; y++) {
                    Tile curTile = _wvm.CurrentWorld.Tiles[x, y];
                    int count = 0;
                    if (counts.ContainsKey(curTile.Type)) {
                        count = counts[curTile.Type];
                    }
                    counts[curTile.Type] = count + 1;
                }
            }

            string resultText = "";
            IDictionaryEnumerator e = counts.GetEnumerator();
            while (e.MoveNext()) {
                int t = (int)e.Key;
                string tileName = (t != 0 ? World.TileProperties[t].Name : "[empty]");
                if (tileName.Length == 0) tileName = "[unclassified]";
                string key = string.Format("{0} ({1})", tileName, e.Key);
                results[key] = (int)e.Value;
            }

            e = results.GetEnumerator();
            while (e.MoveNext()) {
                resultText += string.Format("{0,-25} {1}\r\n", e.Key, e.Value);
            }

            AnalyzeTilesPluginView view = new AnalyzeTilesPluginView(resultText);
            view.Owner = App.Current.MainWindow;
            view.DataContext = _wvm;
            view.Show();
        }
开发者ID:Kaedenn,项目名称:Terraria-Map-Editor,代码行数:48,代码来源:AnalyzeTilesPlugin.cs

示例8: GetSignContent

        public static string GetSignContent(IDictionary<string, string> parameters)
        {
            // 第一步:把字典按Key的字母顺序排序
            IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters);
            IEnumerator<KeyValuePair<string, string>> dem = sortedParams.GetEnumerator();

            // 第二步:把所有参数名和参数值串在一起
            StringBuilder query = new StringBuilder("");
            while (dem.MoveNext())
            {
                string key = dem.Current.Key;
                string value = dem.Current.Value;
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
                {
                    query.Append(key).Append("=").Append(value).Append("&");
                }
            }
            string content = query.ToString().Substring(0, query.Length - 1);

            return content;
        }
开发者ID:liuxing7954,项目名称:cangku_1,代码行数:21,代码来源:AlipaySignature.cs

示例9: GetSignature

        /// <summary>
        /// 计算参数签名
        /// </summary>
        /// <param name="params">请求参数集,所有参数必须已转换为字符串类型</param>
        /// <param name="secret">签名密钥</param>
        /// <returns>签名</returns>
        public static string GetSignature(IDictionary<string, string> parameters, string secret, string url)
        {
            // 先将参数以其参数名的字典序升序进行排序
            IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters);
            IEnumerator<KeyValuePair<string, string>> iterator = sortedParams.GetEnumerator();

            // 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
            StringBuilder basestring = new StringBuilder();
            basestring.Append("POST").Append(url.Replace("http://",""));
            while (iterator.MoveNext())
            {
                string key = iterator.Current.Key;
                string value = iterator.Current.Value;
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
                {
                    basestring.Append(key).Append("=").Append(value);
                }
            }
            basestring.Append(secret);

            // 使用MD5对待签名串求签
            MD5 md5 = MD5.Create();
            byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(basestring.ToString()));

            // 将MD5输出的二进制结果转换为小写的十六进制
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < bytes.Length; i++)
            {
                string hex = bytes[i].ToString("x");
                if (hex.Length == 1)
                {
                    result.Append("0");
                }
                result.Append(hex);
            }
            return result.ToString();
        }
开发者ID:onedot,项目名称:XinGePushSDK.NET,代码行数:43,代码来源:SignUtility.cs

示例10: SignTopRequest

        /// <summary> 
        /// 给TOP请求签名。 
        /// </summary> 
        /// <param name="parameters">所有字符型的TOP请求参数</param> 
        /// <param name="secret">签名密钥</param> 
        /// <returns>签名</returns> 
        public static string SignTopRequest(IDictionary<string, string> parameters, string secret)
        {
            // 第一步:把字典按Key的字母顺序排序
            IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters);
            IEnumerator<KeyValuePair<string, string>> dem = sortedParams.GetEnumerator();

            // 第二步:把所有参数名和参数值串在一起
            StringBuilder query = new StringBuilder(secret);
            while (dem.MoveNext())
            {
                string key = dem.Current.Key;
                string value = dem.Current.Value;
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
                {
                    query.Append(key).Append(value);
                }
            }

            // 第三步:使用MD5加密
            MD5 md5 = MD5.Create();
            byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(query.ToString()));

            // 第四步:把二进制转化为大写的十六进制
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < bytes.Length; i++)
            {
                string hex = bytes[i].ToString("X");
                if (hex.Length == 1)
                {
                    result.Append("0");
                }
                result.Append(hex);
            }

            return result.ToString();
        }
开发者ID:NoobSkie,项目名称:taobao-shop-helper,代码行数:42,代码来源:SysUtils.cs

示例11: GenerateCacheKey

 public virtual string GenerateCacheKey(int tabId, StringCollection includeVaryByKeys, StringCollection excludeVaryByKeys, SortedDictionary<string, string> varyBy)
 {
     var cacheKey = new StringBuilder();
     if (varyBy != null)
     {
         SortedDictionary<string, string>.Enumerator varyByParms = varyBy.GetEnumerator();
         while ((varyByParms.MoveNext()))
         {
             string key = varyByParms.Current.Key.ToLower();
             if (includeVaryByKeys.Contains(key) && !excludeVaryByKeys.Contains(key))
             {
                 cacheKey.Append(string.Concat(key, "=", varyByParms.Current.Value, "|"));
             }
         }
     }
     return GenerateCacheKeyHash(tabId, cacheKey.ToString());
 }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:17,代码来源:OutputCachingProvider.cs

示例12: ProcessTCPPacket

        private void ProcessTCPPacket(TCPPacket pTCPPacket, ref uint pSequence, SortedDictionary<uint, byte[]> pBuffer, RiftStream pStream)
        {
            if (pTCPPacket.SequenceNumber > pSequence) pBuffer[(uint)pTCPPacket.SequenceNumber] = pTCPPacket.TCPData;
            if (pTCPPacket.SequenceNumber < pSequence)
            {
                int difference = (int)(pSequence - pTCPPacket.SequenceNumber);
                byte[] data = pTCPPacket.TCPData;
                if (data.Length > difference)
                {
                    pStream.Append(data, difference, data.Length - difference);
                    pSequence += (uint)(data.Length - difference);
                }
            }
            else if (pTCPPacket.SequenceNumber == pSequence)
            {
                byte[] data = pTCPPacket.TCPData;
                pStream.Append(data);
                pSequence += (uint)data.Length;

                bool found;
                do
                {
                    SortedDictionary<uint, byte[]>.Enumerator enumerator = pBuffer.GetEnumerator();
                    if ((found = (enumerator.MoveNext() && enumerator.Current.Key <= pSequence)))
                    {
                        int difference = (int)(pSequence - enumerator.Current.Key);
                        if (enumerator.Current.Value.Length > difference)
                        {
                            pStream.Append(enumerator.Current.Value, difference, enumerator.Current.Value.Length - difference);
                            pSequence += (uint)(enumerator.Current.Value.Length - difference);
                        }
                        pBuffer.Remove(enumerator.Current.Key);
                    }
                }
                while (found);
            }

            RiftPacket packet;
            while ((packet = pStream.Read(pTCPPacket.Timeval.Date)) != null)
            {
                AddPacket(packet);
                if (packet.Opcode == 0x01B7)
                {
                    mIsCharacterSession = true;
                }
                else if (packet.Opcode == 0x040B)
                {
                    RiftPacketField fieldServerPublicKey;
                    if (packet.GetFieldByIndex(out fieldServerPublicKey, 1) &&
                        fieldServerPublicKey.Type == ERiftPacketFieldType.ByteArray &&
                        fieldServerPublicKey.Value.Bytes.Length == 128)
                    {
                        if (mClientPrivateKeys == null)
                        {
                            DateTime started = DateTime.Now;
                            while (!Program.LiveKeys.ContainsKey(mIsCharacterSession) && DateTime.Now.Subtract(started).TotalSeconds < 10) Thread.Sleep(1);
                            if (Program.LiveKeys.ContainsKey(mIsCharacterSession)) mClientPrivateKeys = Program.LiveKeys;
                            else
                            {
                                MessageBox.Show(this, "The required key was unable to be found for some reason, let the developers know this happened.", "Key Grab Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                mTerminated = true;
                                return;
                            }
                        }
                        mClientPrivateKey = BigNumber.FromArray(mClientPrivateKeys[mIsCharacterSession]);
                        mServerPublicKey = BigNumber.FromArray(fieldServerPublicKey.Value.Bytes);
                        DH dh = new DH(mModulus, mGenerator, BigNumber.One, mClientPrivateKey);
                        mSharedSecretKey = dh.ComputeKey(mServerPublicKey);
                    }
                }
                else if (packet.Opcode == 0x19)
                {
                    pStream.EnableInflater();
                    if (packet.Outbound)
                    {
                        mInboundStream.EnableEncryption(mSharedSecretKey);
                        mOutboundStream.EnableEncryption(mSharedSecretKey);
                    }
                }
            }
        }
开发者ID:vangan123,项目名称:rift-sunrise,代码行数:81,代码来源:SessionForm.cs

示例13: GenerateCacheKey

 public override string GenerateCacheKey(int tabModuleId, SortedDictionary<string, string> varyBy)
 {
     var cacheKey = new StringBuilder();
     if (varyBy != null)
     {
         SortedDictionary<string, string>.Enumerator varyByParms = varyBy.GetEnumerator();
         while ((varyByParms.MoveNext()))
         {
             string key = varyByParms.Current.Key.ToLower();
             cacheKey.Append(string.Concat(key, "=", varyByParms.Current.Value, "|"));
         }
     }
     return GenerateCacheKeyHash(tabModuleId, cacheKey.ToString());
 }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:14,代码来源:FileProvider.cs

示例14: GetSignature

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    /// <summary>
    /// 计算参数签名
    /// </summary>
    /// <param name="params">请求参数集,所有参数必须已转换为字符串类型</param>
    /// <param name="secret">签名密钥</param>
    /// <returns>签名</returns>
    public string GetSignature(IDictionary<string, string> parameters, string secret)
    {
        // 先将参数以其参数名的字典序升序进行排序
        IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters);
        IEnumerator<KeyValuePair<string, string>> iterator= sortedParams.GetEnumerator();

        // 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
        StringBuilder basestring= new StringBuilder();
        while (iterator.MoveNext()) {
                string key = iterator.Current.Key;
                string value = iterator.Current.Value;
                if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)){
                    if (basestring.Length > 0) {
                        basestring.Append("&");
                    }
                    basestring.Append(key).Append("=").Append(value);
                }
        }
        basestring.Append(secret);
        Debug.Log(basestring.ToString());

        // 使用MD5对待签名串求签
        System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
        byte[] bytes = sha1.ComputeHash(Encoding.UTF8.GetBytes(basestring.ToString()));

        // 将MD5输出的二进制结果转换为小写的十六进制
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < bytes.Length; i++) {
                string hex = bytes[i].ToString("x");
                if (hex.Length == 1) {
                    result.Append("0");
                }
                result.Append(hex);
        }

        return result.ToString();
    }
开发者ID:nantas,项目名称:Danmaku,代码行数:46,代码来源:SNSMng.cs

示例15: GetDiff

		private void GetDiff(List<ExecutionMessage> diff, DateTime time, DateTimeOffset serverTime, SortedDictionary<decimal, RefPair<List<ExecutionMessage>, QuoteChange>> from, IEnumerable<QuoteChange> to, Sides side, out decimal newBestPrice)
		{
			newBestPrice = 0;

			var canProcessFrom = true;
			var canProcessTo = true;

			QuoteChange currFrom = null;
			QuoteChange currTo = null;

			// TODO
			//List<ExecutionMessage> currOrders = null;

			var mult = side == Sides.Buy ? -1 : 1;
			bool? isSpread = null;

			using (var fromEnum = from.GetEnumerator())
			using (var toEnum = to.GetEnumerator())
			{
				while (true)
				{
					if (canProcessFrom && currFrom == null)
					{
						if (!fromEnum.MoveNext())
							canProcessFrom = false;
						else
						{
							currFrom = fromEnum.Current.Value.Second;
							isSpread = isSpread == null;
						}
					}

					if (canProcessTo && currTo == null)
					{
						if (!toEnum.MoveNext())
							canProcessTo = false;
						else
						{
							currTo = toEnum.Current;

							if (newBestPrice == 0)
								newBestPrice = currTo.Price;
						}
					}

					if (currFrom == null)
					{
						if (currTo == null)
							break;
						else
						{
							AddExecMsg(diff, time, serverTime, currTo, currTo.Volume, false);
							currTo = null;
						}
					}
					else
					{
						if (currTo == null)
						{
							AddExecMsg(diff, time, serverTime, currFrom, -currFrom.Volume, isSpread.Value);
							currFrom = null;
						}
						else
						{
							if (currFrom.Price == currTo.Price)
							{
								if (currFrom.Volume != currTo.Volume)
								{
									AddExecMsg(diff, time, serverTime, currTo, currTo.Volume - currFrom.Volume, isSpread.Value);
								}

								currFrom = currTo = null;
							}
							else if (currFrom.Price * mult > currTo.Price * mult)
							{
								AddExecMsg(diff, time, serverTime, currTo, currTo.Volume, isSpread.Value);
								currTo = null;
							}
							else
							{
								AddExecMsg(diff, time, serverTime, currFrom, -currFrom.Volume, isSpread.Value);
								currFrom = null;
							}
						}
					}
				}
			}
		}
开发者ID:vikewoods,项目名称:StockSharp,代码行数:88,代码来源:ExecutionLogConverter.cs


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