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


C# IDictionary.OrderBy方法代码示例

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


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

示例1: Sign

 public string Sign(string consumerSecret, string url, IDictionary<string, string> data,
                     string httpMethod = "POST")
 {
     var orderedFormData = data.OrderBy(kvp => kvp.Key);
     var normalizedData = NormalizeFormData(orderedFormData);
     return Sign(consumerSecret, url, normalizedData, httpMethod);
 }
开发者ID:kreso,项目名称:OAuthTest,代码行数:7,代码来源:OAuthSigner.cs

示例2: PrintResultToConsole

 private static void PrintResultToConsole(IDictionary<string, int> counterOfWords)
 {
     foreach (var word in counterOfWords.OrderBy(x => x.Value))
     {
         Console.WriteLine("{0} -> {1}", word.Key, word.Value);
     }
 }
开发者ID:NikolayKostadinov,项目名称:Homeworks,代码行数:7,代码来源:CountWordsInText.cs

示例3: SetEvidence

        internal void SetEvidence(
            IDictionary<string, Tuple<FObservation, FRandomVariable[]>> evidences,
            IDictionary<string, string> abbreviations)
        {
            var evidencesSorted
                = evidences.OrderBy(kvp => kvp.Key);

            xEvidenceList.Children.Clear();

            foreach (var kvp in evidencesSorted)
            {
                // Scenario label.
                TextBlock scenarioLabel = new TextBlock();
                scenarioLabel.Text = kvp.Key;
                xEvidenceList.Children.Add(scenarioLabel);

                // Observation values.
                Observation.Observation obsControl = new Observation.Observation();
                var observation = kvp.Value.Item1;
                var observationVariables = kvp.Value.Item2;
                obsControl.SetData(observation, observationVariables, abbreviations);
                xEvidenceList.Children.Add(obsControl);
                obsControl.Margin = new Thickness(0, 0, 0, 12);
            }
        }
开发者ID:duckmaestro,项目名称:F-AI,代码行数:25,代码来源:EvidenceInspector.xaml.cs

示例4: ViewBooksViewModel

		public ViewBooksViewModel(IEnumerable<BookListView> books, 
			IDictionary<string, string> genres, string selectedGenre, IEnumerable<BookListView> wishlistBooks)
		{
			Books = books.OrderByDescending(b => b.Rating);
			Genres = genres.OrderBy(g => g.Value).ToDictionary(x => x.Key, x => x.Value);
			WishlistBooks = wishlistBooks;

			if (!string.IsNullOrWhiteSpace(selectedGenre) && genres.Keys.Contains(selectedGenre))
			{
				SelectedGenre = genres[selectedGenre];
			}
		}
开发者ID:NTCoding,项目名称:FubuRaven.NTCoding.com,代码行数:12,代码来源:ViewBooksViewModel.cs

示例5: MakeAuthedUrl

        protected string MakeAuthedUrl(string method, IDictionary<string, string> urlParams)
        {
            var paramsList = urlParams.OrderBy(e => e.Key)
                .Select(e => string.Join("=", e.Key, e.Value))
                .ToList();

            var encryptor = new HashHelper();
            var enctyptedTokenAndKey = encryptor.GetMD5Hash(AccessToken + AppSecretKey);
            var sig = encryptor.GetMD5Hash(string.Concat(paramsList) + enctyptedTokenAndKey);

            return string.Format("http://api.ok.ru/api/{0}?{1}&access_token={2}&sig={3}",
                method, string.Join("&", paramsList), AccessToken, sig);
        }
开发者ID:some-body,项目名称:rsoi_lab1,代码行数:13,代码来源:OAuth2ApiForOK.cs

示例6: BuildSig

        public static string BuildSig(string secretKey, string method, IDictionary<string, string> parameters)
        {
            parameters.Add("method", method);
            var temp = parameters.OrderBy(x => x.Key);
            var s = new StringBuilder();
            foreach (var p in temp)
            {
                s.Append(p.Key);
                s.Append(p.Value);
            }

            s.Append(secretKey);
            return Md5(s.ToString());
        }
开发者ID:justdude,项目名称:meridian,代码行数:14,代码来源:LastFmUtils.cs

示例7: GeneralPostdata

 /// <summary>
 /// 生成POST的xml数据字符串
 /// </summary>
 /// <param name="postdataDict">>参与生成的参数列表</param>
 /// <param name="sign">签名</param>
 /// <returns></returns>
 public static string GeneralPostdata(IDictionary<string, string> postdataDict, string sign)
 {
     var sb2 = new StringBuilder();
     sb2.Append("<xml>");
     foreach (var sA in postdataDict.OrderBy(x => x.Key))//参数名ASCII码从小到大排序(字典序);
     {
         sb2.Append("<" + sA.Key + ">")
            .Append(Util.Transfer(sA.Value))//参数值用XML转义即可,CDATA标签用于说明数据不被XML解析器解析。 
            .Append("</" + sA.Key + ">");
     }
     sb2.Append("<sign>").Append(sign).Append("</sign>");
     sb2.Append("</xml>");
     return sb2.ToString();
 }
开发者ID:keep01,项目名称:weixinSDK,代码行数:20,代码来源:PayUtil.cs

示例8: Set

        public void Set(string path, IDictionary<string, string> routeValues, string source, bool isManaged) {
            if (path == null) {
                throw new ArgumentNullException("path");
            }

            var aliasRecord = _aliasRepository.Fetch(r => r.Path == path, o => o.Asc(r => r.Id), 0, 1).FirstOrDefault();
            aliasRecord = aliasRecord ?? new AliasRecord { Path = path };

            string areaName = null;
            string controllerName = null;
            string actionName = null;
            var values = new XElement("v");
            foreach (var routeValue in routeValues.OrderBy(kv => kv.Key, StringComparer.InvariantCultureIgnoreCase)) {
                if (string.Equals(routeValue.Key, "area", StringComparison.InvariantCultureIgnoreCase)
                    || string.Equals(routeValue.Key, "area-", StringComparison.InvariantCultureIgnoreCase)) {
                    areaName = routeValue.Value;
                }
                else if (string.Equals(routeValue.Key, "controller", StringComparison.InvariantCultureIgnoreCase)) {
                    controllerName = routeValue.Value;
                }
                else if (string.Equals(routeValue.Key, "action", StringComparison.InvariantCultureIgnoreCase)) {
                    actionName = routeValue.Value;
                }
                else {
                    values.SetAttributeValue(routeValue.Key, routeValue.Value);
                }
            }

            aliasRecord.Action = _actionRepository.Fetch(
                r => r.Area == areaName && r.Controller == controllerName && r.Action == actionName,
                o => o.Asc(r => r.Id), 0, 1).FirstOrDefault();
            aliasRecord.Action = aliasRecord.Action ?? new ActionRecord { Area = areaName, Controller = controllerName, Action = actionName };

            aliasRecord.RouteValues = values.ToString();
            aliasRecord.Source = source;
            aliasRecord.IsManaged = isManaged;
            if (aliasRecord.Action.Id == 0 || aliasRecord.Id == 0) {
                if (aliasRecord.Action.Id == 0) {
                    _actionRepository.Create(aliasRecord.Action);
                }
                if (aliasRecord.Id == 0) {
                    _aliasRepository.Create(aliasRecord);
                }
                // Bulk updates might go wrong if we don't flush
                _aliasRepository.Flush();
            }
            // Transform and push into AliasHolder
            var dict = ToDictionary(aliasRecord);
            _aliasHolder.SetAlias(new AliasInfo { Path = dict.Item1, Area = dict.Item2, RouteValues = dict.Item3, IsManaged = dict.Item6 });
        }
开发者ID:Higea,项目名称:Orchard,代码行数:50,代码来源:AliasStorage.cs

示例9: FormatFromDictionary

        public static string FormatFromDictionary(this string formatString, IDictionary<string, string> valueDict)
        {
            int i = 0;
            StringBuilder newFormatString = new StringBuilder(formatString);
            IDictionary<string, int> keyToInt = new Dictionary<string, int>();
            foreach (var tuple in valueDict)
            {
                newFormatString = newFormatString.Replace("{" + tuple.Key + "}", "{" + i.ToString() + "}");
                keyToInt.Add(tuple.Key, i);
                i++;
            }

            // ReSharper disable once CoVariantArrayConversion
            return string.Format(newFormatString.ToString(), valueDict.OrderBy(x => keyToInt[x.Key]).Select(x => x.Value).ToArray());
        }
开发者ID:Blisse,项目名称:UWAPI,代码行数:15,代码来源:Extensions.cs

示例10: GenerateCacheKey

        private string GenerateCacheKey(IDictionary<string, object> parameters, params object[] extraInput) {
            // generate a cache key for just the parameters
            List<object> parameterCacheKeyInputs = new List<object>(parameters.Count * 2);
            foreach (var entry in parameters.OrderBy(o => o.Key, StringComparer.OrdinalIgnoreCase)) {
                parameterCacheKeyInputs.Add(entry.Key);
                parameterCacheKeyInputs.Add(entry.Value);
            }
            string parametersKey = CacheKeyUtil.GenerateCacheKey(parameterCacheKeyInputs.ToArray());

            object[] combinedInputs =
                new object[] { Duration, Key, parametersKey }
                .Concat(extraInput).ToArray();

            return _cacheKeyPrefix + CacheKeyUtil.GenerateCacheKey(combinedInputs);
        }
开发者ID:consumentor,项目名称:Server,代码行数:15,代码来源:ChildActionCacheAttribute.cs

示例11: JsonMappings

        public JsonMappings(
            IDictionary<Type, Type> mappingsByType,
            IDictionary<PropertyInfo, Type> mappingsByProperty)
        {
            _mappingsByType = mappingsByType;
            _mappingsByProperty = mappingsByProperty;

            _mappings =
                mappingsByType.OrderBy(x => x.Key.FullName)
                    .Select(item => new Tuple<MemberInfo, Type>(item.Key, item.Value))
                .Concat(mappingsByProperty.OrderBy(DeclaringTypeAndPropertyName)
                    .Select(item => new Tuple<MemberInfo, Type>(item.Key, item.Value))).ToList();

            _hashCode =
                unchecked(_mappings.Aggregate(
                    typeof(JsonMappings).GetHashCode(),
                    (currentHashCode, item) => (currentHashCode * 397) ^ item.GetHashCode()));
        }
开发者ID:JonOsment,项目名称:XSerializer,代码行数:18,代码来源:JsonMappings.cs

示例12: CurrentChain

        public CurrentChain(BehaviorChain top, IDictionary<string, object> data)
        {
            _chains.Push(top);
            _originalChain = top;

            _routeData = data;

            _resourceHash = new Lazy<string>(() =>
            {
                var dict = new Dictionary<string, string>{
                    {"Pattern", top.ToString()}
                };

                data.OrderBy(x => x.Key).Each(
                    pair => { dict.Add(pair.Key, pair.Value == null ? string.Empty : pair.Value.ToString()); });

                return dict.Select(x => "{0}={1}".ToFormat(x.Key, x.Value)).Join(";").ToHash();
            });
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:19,代码来源:CurrentChain.cs

示例13: CreateETag

        public EntityTagHeaderValue CreateETag(IDictionary<string, object> properties)
        {
            if (properties == null)
            {
                throw Error.ArgumentNull("properties");
            }

            if (properties.Count == 0)
            {
                return null;
            }

            StringBuilder builder = new StringBuilder();
            builder.Append('\"');
            bool firstProperty = true;

            foreach (object propertyValue in properties.OrderBy(p => p.Key).Select(p => p.Value))
            {
                if (firstProperty)
                {
                    firstProperty = false;
                }
                else
                {
                    builder.Append(Separator);
                }

                string str = propertyValue == null
                    ? NullLiteralInETag
                    : ConventionsHelpers.GetUriRepresentationForValue(propertyValue);

                // base64 encode
                byte[] bytes = Encoding.UTF8.GetBytes(str);
                string etagValueText = Convert.ToBase64String(bytes);
                builder.Append(etagValueText);
            }

            builder.Append('\"');
            string tag = builder.ToString();
            return new EntityTagHeaderValue(tag, isWeak: true);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:41,代码来源:DefaultODataETagHandler.cs

示例14: CacheKey

        protected CacheKey(IDictionary<string, object> key, Type type, string operation, OperationReturnType returnType, bool sorted, HashAlgorithmName hashAlgorithm = HashAlgorithmName.Default)
        {
            var reflectedType = Reflector.GetReflectedType(type);
            var typeName = reflectedType.IsBusinessObject && reflectedType.InterfaceTypeName != null ? reflectedType.InterfaceTypeName : reflectedType.FullTypeName;

            _hashAlgorithm = hashAlgorithm == HashAlgorithmName.Default ? ObjectFactory.Configuration.DefaultHashAlgorithm : hashAlgorithm;
            if (_hashAlgorithm == HashAlgorithmName.Native || _hashAlgorithm == HashAlgorithmName.None)
            {
                var keyValue = (sorted ? key.Select(k => string.Format("{0}={1}", k.Key, Uri.EscapeDataString(Convert.ToString(k.Value)))) : key.OrderBy(k => k.Key).Select(k => string.Format("{0}={1}", k.Key, Uri.EscapeDataString(Convert.ToString(k.Value))))).ToDelimitedString("&");
                if (!string.IsNullOrEmpty(operation))
                {
                    _value = string.Concat(typeName, "->", operation, "[", returnType, "]", "::", keyValue);
                }
                else
                {
                    _value = string.Concat(typeName, "::", keyValue);
                }
                _data = _value.ToByteArray();
            }
            else
            {
                Func<KeyValuePair<string, object>, IEnumerable<byte>> func = k => BitConverter.GetBytes(k.Key.GetHashCode()).Append((byte)'=').Concat(BitConverter.GetBytes(k.Value.GetHashCode())).Append((byte)'&');
                var keyValue = (sorted ? key.Select(func) : key.OrderBy(k => k.Key).Select(func)).Flatten().ToArray();
                if (!string.IsNullOrEmpty(operation))
                {
                    _data = new byte[4 + 4 + 1 + keyValue.Length];
                    Buffer.BlockCopy(BitConverter.GetBytes(typeName.GetHashCode()), 0, _data, 0, 4);
                    Buffer.BlockCopy(BitConverter.GetBytes(operation.GetHashCode()), 0, _data, 4, 4);
                    Buffer.BlockCopy(new[] { (byte)returnType }, 0, _data, 8, 1);
                    Buffer.BlockCopy(keyValue, 0, _data, 9, keyValue.Length);
                }
                else
                {
                    _data = new byte[4 + keyValue.Length];
                    Buffer.BlockCopy(BitConverter.GetBytes(typeName.GetHashCode()), 0, _data, 0 , 4);
                    Buffer.BlockCopy(keyValue, 0, _data, 4 , keyValue.Length);
                }
            }
        }
开发者ID:rhutchison,项目名称:Nemo,代码行数:39,代码来源:CacheKey.cs

示例15: PlotDataPoints

        public void PlotDataPoints(IDictionary<DateTime, IDataPoint> highActivityDataPoints,
                                 IDictionary<DateTime, IDataPoint> lowActivityDataPoints)
        {
            if(highActivityDataPoints == null || lowActivityDataPoints == null)
            return;

             // plot high activity heart rate data.
             ExerciseChart.Series[0].Points.Clear();
             foreach(var point in highActivityDataPoints
                              .OrderBy(x => x.Key)
                              .Select(kv => kv.Value)
                              .Smooth(GetChunkSize(ViewModel.HighActivityDataPoints.Count)))
             {
            ExerciseChart.Series[0].Points.AddXY(point.Date.ToOADate(), point.HeartRate);
             }

             // plot low activity heart rate data.
             ExerciseChart.Series[1].Points.Clear();
             foreach(var point in lowActivityDataPoints
                              .OrderBy(x => x.Key)
                              .Select(kv => kv.Value)
                              .Smooth(GetChunkSize(ViewModel.LowActivityDataPoints.Count)))
             {
            ExerciseChart.Series[1].Points.AddXY(point.Date.ToOADate(), point.HeartRate);
             }
        }
开发者ID:mrgrier,项目名称:FitnessDataAnalyzer,代码行数:26,代码来源:ProgressView.cs


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