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


C# IDictionary.ToList方法代码示例

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


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

示例1: Dump

        public static string Dump(string sql, IDictionary<string, object> parameters, ISqlDialect dialect = null)
        {
            if (parameters == null)
                return sql;

            var param = parameters.ToList();
            for (var i = 0; i < param.Count; i++)
            {
                var name = param[i].Key;
                if (!name.StartsWith("@"))
                    param[i] = new KeyValuePair<string,object>("@" + name, param[i].Value);
            }

            param.Sort((x, y) => y.Key.Length.CompareTo(x.Key.Length));

            var sb = new StringBuilder(sql);
            foreach (var pair in param)
                sb.Replace(pair.Key, DumpParameterValue(pair.Value, dialect));

            var text = DatabaseCaretReferences.Replace(sb.ToString());

            dialect = dialect ?? SqlSettings.DefaultDialect;
            var openBracket = dialect.OpenQuote;
            if (openBracket != '[')
                text = BracketLocator.ReplaceBrackets(text, dialect);

            var paramPrefix = dialect.ParameterPrefix;
            if (paramPrefix != '@')
                text = ParamPrefixReplacer.Replace(text, paramPrefix);

            return text;
        }
开发者ID:CodeFork,项目名称:Serenity,代码行数:32,代码来源:SqlDebugDumper.cs

示例2: Can_serialize_content_as_complex_associative_array

        public void Can_serialize_content_as_complex_associative_array()
        {
            var message = new MandrillMessage();

            var data = new IDictionary<string, object>[]
            {
                new Dictionary<string, object>
                {
                    {"sku", "apples"},
                    {"unit_price", 0.20},
                },
                new Dictionary<string, object>
                {
                    {"sku", "oranges"},
                    {"unit_price", 0.40},
                }
            };

            message.GlobalMergeVars.Add(new MandrillMergeVar()
            {
                Name = "test",
                Content = data.ToList()
            });

            var json = JObject.FromObject(message, MandrillSerializer.Instance);

            json["global_merge_vars"].Should().NotBeEmpty();
            var result = json["global_merge_vars"].First["content"]
                .ToObject<List<Dictionary<string, object>>>(MandrillSerializer.Instance);

            result[0]["sku"].Should().Be("apples");
            result[0]["unit_price"].Should().Be(0.20);
            result[1]["sku"].Should().Be("oranges");
            result[1]["unit_price"].Should().Be(0.40);
        }
开发者ID:ChrisEby,项目名称:Mandrill.net,代码行数:35,代码来源:SerializationTests.cs

示例3: AmqpConnectionParameters

        public AmqpConnectionParameters(IDictionary<string, string> parameters)
        {
            this.SetDefaultValues();

            parameters
                .ToList<KeyValuePair<string, string>>()
                .ForEach(param => this.Set(param.Key, param.Value));
        }
开发者ID:Berico-Technologies,项目名称:Event-Bus,代码行数:8,代码来源:AmqpConnectionParameters.cs

示例4: DispatchDoesNotMutateInputRouteValues

 public void DispatchDoesNotMutateInputRouteValues(
     DefaultRouteDispatcher sut,
     MethodCallExpression method,
     IDictionary<string, object> routeValues)
 {
     var expected = routeValues.ToList();
     sut.Dispatch(method, routeValues);
     Assert.True(expected.SequenceEqual(routeValues));
 }
开发者ID:khaledm,项目名称:Hyprlinkr,代码行数:9,代码来源:ScalarRouteDispatcherTests.cs

示例5: ReportRunner

 public ReportRunner(
     ReportFormat reportFormat,
     string reportPath,
     IDictionary<string, object> reportParameters)
     : this(reportFormat, 
         reportPath, 
         reportParameters != null ? reportParameters.ToList() : null)
 {
 }
开发者ID:harroot,项目名称:MvcReportViewer,代码行数:9,代码来源:ReportRunner.cs

示例6: SetOutputArguments

        public void SetOutputArguments(IDictionary<string, string> output)
        {
            RemoveArgument(output, StartArgument.Replace("/", ""));
            RemoveArgument(output, EndArgument.Replace("/", ""));

            foreach (var kvp in output.ToList())
            {
                output[kvp.Key] = string.Format("{0}.{1}.{2}.pout", kvp.Value, Start, End);
            }
        }
开发者ID:ablandhol,项目名称:pxunit,代码行数:10,代码来源:ParallelXunitCommandLine.cs

示例7: GetInstalledExtensionPaths

        /// <summary>
        /// Converts the given collection of extension properties and their identifiers to full paths.
        /// </summary>
        internal static Dictionary<string, string> GetInstalledExtensionPaths(IVsExtensionManager extensionManager, IDictionary<string, string> extensionIds)
        {
            // Update installed Extensions
            var installedExtensionPaths = new Dictionary<string, string>();
            extensionIds.ToList().ForEach(ie =>
            {
                installedExtensionPaths.Add(ie.Key, GetInstalledExtensionPath(extensionManager, ie.Value));
            });

            return installedExtensionPaths;
        }
开发者ID:NuPattern,项目名称:NuPattern,代码行数:14,代码来源:VersionHelper.cs

示例8: BuildCommand

        public IDbCommand BuildCommand(IDbConnection connection, string sql, IDictionary<string, object> parameters)
        {
            var cmd = connection.CreateCommand();
            cmd.Connection = connection;
            cmd.CommandText = sql;

            parameters.ToList()
                .ForEach(cmd.AddParameter);

            return cmd;
        }
开发者ID:timlucas,项目名称:Simple.Data.RawSql,代码行数:11,代码来源:DbCommandBuilder.cs

示例9: Calculate

        /// <summary>
        /// Append stats distributed in castle
        /// </summary>
        /// <param name="castleStatsDictionary">Stats distributed in castle</param>
        /// <param name="calculationResult">Current calculation result</param>
        public void Calculate(IDictionary<StatTypeEnum, byte> castleStatsDictionary, CalculationResult calculationResult)
        {
            if (castleStatsDictionary == null)
                throw new ArgumentNullException("castleStatsDictionary");
            if (calculationResult == null)
                throw new ArgumentNullException("calculationResult");

            castleStatsDictionary
                .ToList()
                .ForEach(y => applyStatValue(y.Key, y.Value, calculationResult));
        }
开发者ID:majeretft,项目名称:Talented,代码行数:16,代码来源:StatDistributionCalculator.cs

示例10: CreateTags

        /// <summary>
        /// Creates Tag objects from a provided dictionary of string tags along with integer values indicating the weight of each tag. 
        /// This overload is suitable when you have a list of already weighted tags, i.e. from a database query result.
        /// </summary>
        /// <param name="weightedTags">A dictionary that takes a string for the tag text (as the dictionary key) and an integer for the tag weight (as the dictionary value).</param>
        /// <param name="rules">A TagCloudGenerationRules object to decide how the cloud is generated.</param>
        /// <returns>A list of Tag objects that can be used to create the tag cloud.</returns>
        public static IEnumerable<Tag> CreateTags(IDictionary<string, int> weightedTags, TagCloudGenerationRules generationRules)
        {
            #region Parameter validation

            if (weightedTags == null) throw new ArgumentNullException("weightedTags");
            if (generationRules == null) throw new ArgumentNullException("generationRules");

            #endregion

            return CreateTags(weightedTags.ToList(), generationRules);
        }
开发者ID:khoainv,项目名称:Framework,代码行数:18,代码来源:TagCloud.cs

示例11: OrderedWordsByValue

        private static List<KeyValuePair<string, int>> OrderedWordsByValue(IDictionary<string, int> wordsCount)
        {
            List<KeyValuePair<string, int>> sorted = wordsCount.ToList();

            sorted.Sort((firstPair, nextPair) =>
                {
                    return firstPair.Value.CompareTo(nextPair.Value);
                }
            );

            return sorted;
        }
开发者ID:VesiBaleva,项目名称:TelerikAcademy,代码行数:12,代码来源:CountAndOrderWordsFormFile.cs

示例12: ReportRunner

 public ReportRunner(
     ReportFormat reportFormat,
     string reportPath,
     IDictionary<string, object> reportParameters,
     ProcessingMode mode = ProcessingMode.Remote,
     IDictionary<string, DataTable> localReportDataSources = null)
     : this(reportFormat, 
         reportPath, 
         reportParameters != null ? reportParameters.ToList() : null,
         mode,
         localReportDataSources)
 {
 }
开发者ID:postjuan,项目名称:MvcReportViewer,代码行数:13,代码来源:ReportRunner.cs

示例13: InitValues

        public void InitValues(IDictionary<string, object> defaultValues) {
            valueControls.Clear();
            items.Children.Clear();
            items.RowDefinitions.Clear();

            var defVals = defaultValues.ToList();
            for (int i = 0; i < defVals.Count; ++i) {
                var p = defVals[i];

                items.RowDefinitions.Add(new RowDefinition());
                var control = CreateItem(p.Key, p.Value, i, items);
                valueControls.Add(p.Key, new Tuple<Control, Type>(control, p.Value.GetType()));
            }
        }
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:14,代码来源:KeyValuePairsBlock.xaml.cs

示例14: UploadString

        /// <summary>
        /// 上传数据
        /// </summary>
        /// <param name="url"></param>
        /// <param name="service"></param>
        /// <param name="queries"></param>
        /// <param name="action"></param>
        /// <param name="failed"></param>
        protected void UploadString(string url
            , IDictionary<string, string> queries
            , Action<RestResponse, object> action
            , Action<Exception> failed
            , object userState)
        {
            bool httpResult = HttpWebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
            RestClient client = new RestClient();
            client.Method = WebMethod.Post;
            queries.ToList().ForEach(o => client.AddParameter(o.Key, o.Value));
            client.AddHeader("X-Requested-With", "xmlhttp");

            client.Authority = url;
            RestRequest restRequest = new RestRequest();
            CookieContainer cookieContainer = null;
            if (IsolatedStorageSettings.ApplicationSettings.Contains("cookie"))
            {
                cookieContainer = IsolatedStorageSettings.ApplicationSettings["cookieContainer"] as CookieContainer;
                Cookie cookie = IsolatedStorageSettings.ApplicationSettings["cookie"] as Cookie;
                if (cookieContainer.Count == 0 && cookie != null)
                {
                    cookieContainer.SetCookies(new Uri(Constant.ROOTURL), string.Format("{0}={1}", cookie.Name, cookie.Value));
                }
            }
            else
            {
                cookieContainer = new CookieContainer();
            }

            restRequest.CookieContainer = cookieContainer;
            client.BeginRequest(restRequest, (request, response, userState1) =>
            {
                cookieContainer = response.CookieContainer;
                CookieCollection cookies = cookieContainer.GetCookies(new Uri(Constant.ROOTURL));
                try
                {
                    IsolatedStorageSettings.ApplicationSettings["cookie"] = cookies["cooper"];
                    IsolatedStorageSettings.ApplicationSettings["cookieContainer"] = cookieContainer;
                    IsolatedStorageSettings.ApplicationSettings.Save();
                }
                catch
                {
                }

                if (response != null)
                    Deployment.Current.Dispatcher.BeginInvoke(action, response, userState1);
                else
                    Deployment.Current.Dispatcher.BeginInvoke(failed, new Exception("response返回为空!"));
            }, userState);
        }
开发者ID:codesharp,项目名称:cooper-mobi,代码行数:58,代码来源:WebRequestWrapper.cs

示例15: LogEvent

        static void LogEvent(string eventName, IDictionary<string, object> eventData = null)
        {
            var dict = GetGenericEventDict();

            if (eventData != null)
            {
                var dataList = eventData.ToList();

                dataList.ForEach(pair =>
                {
                    dict.Add(pair);
                });
            }

            Analytics.CustomEvent(eventName, dict);
        }
开发者ID:Kundara,项目名称:project1,代码行数:16,代码来源:JetsonsAnalytics.cs


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