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


C# IDictionary.Select方法代码示例

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


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

示例1: RetailAndPowerTrend

 public ActionResult RetailAndPowerTrend(IDictionary<string, GraphModel> graphModels)
 {
     var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     var months = graphModels.Select(x => x.Key.Substring(0, 3));
     ViewBag.months = serializer.Serialize(months);
     var actualManpowers = graphModels.Select(x => x.Value.ActualManPower);
     ViewBag.actualManPowers = serializer.Serialize(actualManpowers);
     var retails = graphModels.Select(x => x.Value.Retail);
     ViewBag.retails = serializer.Serialize(retails);
     var planManpower = graphModels.Select(x => x.Value.PlanManPower);
     ViewBag.planManPower = serializer.Serialize(planManpower);
     return PartialView();
 }
开发者ID:akhilrex,项目名称:DMP_New,代码行数:13,代码来源:ReportingController.cs

示例2: SchemaManager

        static SchemaManager()
        {
            const short arraySize = 3;

            CsdlNamespaces = new Dictionary<Version, XNamespace>(arraySize);
            CsdlNamespaces.Add(EntityFrameworkVersion.Version1, XNamespace.Get("http://schemas.microsoft.com/ado/2006/04/edm"));
            CsdlNamespaces.Add(EntityFrameworkVersion.Version2, XNamespace.Get("http://schemas.microsoft.com/ado/2008/09/edm"));
            CsdlNamespaces.Add(EntityFrameworkVersion.Version3, XNamespace.Get("http://schemas.microsoft.com/ado/2009/11/edm"));
            CsdlNamespaceNames = CsdlNamespaces.Select(n => n.Value.NamespaceName).ToArray();

            MslNamespaces = new Dictionary<Version, XNamespace>(arraySize);
            MslNamespaces.Add(EntityFrameworkVersion.Version1, XNamespace.Get("urn:schemas-microsoft-com:windows:storage:mapping:CS"));
            MslNamespaces.Add(EntityFrameworkVersion.Version2, XNamespace.Get("http://schemas.microsoft.com/ado/2008/09/mapping/cs"));
            MslNamespaces.Add(EntityFrameworkVersion.Version3, XNamespace.Get("http://schemas.microsoft.com/ado/2009/11/mapping/cs"));
            MslNamespaceNames = MslNamespaces.Select(n => n.Value.NamespaceName).ToArray();

            SsdlNamespaces = new Dictionary<Version, XNamespace>(arraySize);
            SsdlNamespaces.Add(EntityFrameworkVersion.Version1, XNamespace.Get("http://schemas.microsoft.com/ado/2006/04/edm/ssdl"));
            SsdlNamespaces.Add(EntityFrameworkVersion.Version2, XNamespace.Get("http://schemas.microsoft.com/ado/2009/02/edm/ssdl"));
            SsdlNamespaces.Add(EntityFrameworkVersion.Version3, XNamespace.Get("http://schemas.microsoft.com/ado/2009/11/edm/ssdl"));
            SsdlNamespaceNames = SsdlNamespaces.Select(n => n.Value.NamespaceName).ToArray();

            EdmxNamespaces = new Dictionary<Version, XNamespace>(arraySize);
            EdmxNamespaces.Add(EntityFrameworkVersion.Version1, XNamespace.Get("http://schemas.microsoft.com/ado/2007/06/edmx"));
            EdmxNamespaces.Add(EntityFrameworkVersion.Version2, XNamespace.Get("http://schemas.microsoft.com/ado/2008/10/edmx"));
            EdmxNamespaces.Add(EntityFrameworkVersion.Version3, XNamespace.Get("http://schemas.microsoft.com/ado/2009/11/edmx"));
            EdmxNamespaceNames = EdmxNamespaces.Select(n => n.Value.NamespaceName).ToArray();

            NamespaceToVersionReverseLookUp = new Dictionary<XNamespace, Version>();
            foreach (var kvp in CsdlNamespaces.Concat(MslNamespaces).Concat(SsdlNamespaces).Concat(EdmxNamespaces))
            {
                NamespaceToVersionReverseLookUp.Add(kvp.Value, kvp.Key);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:34,代码来源:SchemaManager.cs

示例3: Query

 /// <summary>
 ///   <para>Modifies target URL address by adding by adding given list of name/value pairs to its Query component.</para>
 ///   <para>Names and values of query string parameters are URL-encoded.</para>
 /// </summary>
 /// <param name="self">URI address to be modified.</param>
 /// <param name="parameters">Map of name/value parameters for query string.</param>
 /// <returns>Updated URI address.</returns>
 /// <exception cref="ArgumentNullException">If either <paramref name="self"/> or <paramref name="parameters"/> is a <c>null</c> reference.</exception>
 /// <seealso cref="Query(Uri, object)"/>
 /// <seealso cref="Query(Uri, IDictionary{string, object})"/>
 public static Uri Query(this Uri self, IDictionary<string, string> parameters)
 {
   var builder = new UriBuilder(self);
   var query = parameters.Select(parameter => $"{parameter.Key.UrlEncode()}={parameter.Value.UrlEncode()}").Join("&");
   builder.Query = builder.Query.Length > 1 ? builder.Query.Substring(1) + (query.IsEmpty() ? string.Empty : "&" + query) : query;
   return builder.Uri;
 }
开发者ID:prokhor-ozornin,项目名称:Catharsis.NET.Commons,代码行数:17,代码来源:NetworkExtensions.cs

示例4: CreateSign

        public static string CreateSign(IDictionary<string, string> parameters, string key, string charset)
        {
            string[] array = parameters.Select(item => string.Format("{0}={1}", item.Key, item.Value)).ToArray();
            string originalstr = string.Concat(string.Join("&", array), key);

            return CryptoUtil.MD5(originalstr, charset);
        }
开发者ID:yhhno,项目名称:thinkpay,代码行数:7,代码来源:AlipayUtil.cs

示例5: CreateQueryString

        private static string CreateQueryString(
            IDictionary<string, string> clientFilters,
            int page)
        {
            // Go through, replacing the page.number query param's value with
            // the actual page. Preserves other query parameters, since they're
            // still needed to provide the correct pagination links.
            var queries = clientFilters.Select(kv =>
            {
                var key = kv.Key;
                var value = kv.Key == Constants.QueryNames.PageNumber ? page.ToString() : kv.Value;

                if (string.IsNullOrEmpty(value))
                {
                    return null;
                }

                if (!key.Contains("."))
                {
                    return new { Key = key, Value = value };
                }

                var left = key.Substring(0, key.IndexOf(".", StringComparison.InvariantCulture));
                var right = key.Substring(left.Length + 1);
                return new { Key = left + $"[{right}]", Value = value };
            }).Where(k => k != null).ToList();

            return queries.Any()
                ? "?" + string.Join("&", queries.Select(kv => $"{kv.Key}={kv.Value}"))
                : null;
        }
开发者ID:joukevandermaas,项目名称:saule,代码行数:31,代码来源:PaginationQuery.cs

示例6: FormUrlEncode

 static string FormUrlEncode(IDictionary<string, string> data)
 {
     var pairs = data.Select(pair => string.Format("{0}={1}",
         WebUtility.UrlEncode(pair.Key),
         WebUtility.UrlEncode(pair.Value)));
     return string.Join("&", pairs);
 }
开发者ID:rackerlabs,项目名称:RackspaceCloudOfficeApiClient,代码行数:7,代码来源:BodyEncoder.cs

示例7: CompileDocumentType

        public static Type CompileDocumentType(Type baseType, IDictionary<string, Type> fields)
        {
            string signature = baseType.FullName + string.Join(";", fields.Select(f => f.ToString()));

            Type type = null;
            lock (_cachedTypes)
            {
                if (_cachedTypes.ContainsKey(signature))
                {
                    type = _cachedTypes[signature];
                }
            }

            if (type == null)
            {
                type = CompileDocumentTypeInternal(baseType, fields);
                lock (_cachedTypes)
                {
                    if (!_cachedTypes.ContainsKey(signature))
                    {
                        _cachedTypes.Add(signature, type);
                    }
                }
            }

            return type;
        }
开发者ID:object,项目名称:MongOData,代码行数:27,代码来源:DocumentTypeBuilder.cs

示例8: GetBdmtTitles

 private static string GetBdmtTitles(IDictionary<Language, string> bdmtTitles)
 {
     return !bdmtTitles.Any()
                ? null
                : string.Join(Environment.NewLine,
                              bdmtTitles.Select(pair => string.Format("{0}: {1}", pair.Key.ISO_639_2, pair.Value)));
 }
开发者ID:bdhero,项目名称:bdhero-fat,代码行数:7,代码来源:DiscInfoMetadataPanel.cs

示例9: ToQueryString

 public static string ToQueryString(IDictionary<string, string> pairs)
 {
     // http://stackoverflow.com/questions/829080/how-to-build-a-query-string-for-a-url-in-c/829138#829138
     return string.Join("&", pairs.Select(
         (pair) => string.Format("{0}={1}", UrlEncode(pair.Key), UrlEncode(pair.Value))
     ));
 }
开发者ID:strager,项目名称:NoCap,代码行数:7,代码来源:HttpUtility.cs

示例10: Remap

 public void Remap(IDictionary<string, AppFunc> map)
 {
     _map = map
         .Select(kv => Tuple.Create(kv.Key, kv.Value))
         .OrderByDescending(m => m.Item1.Length)
         .ToArray();
 }
开发者ID:Beatles1692,项目名称:pretzel,代码行数:7,代码来源:UrlMapper.cs

示例11: GetCompilation

        public CSharpCompilation GetCompilation(string assemblyName, IDictionary<string, string> files, out SyntaxTree[] trees)
        {
            var options = new CSharpParseOptions(_languageVersion);
            trees = files.Select(x =>
            {
                var text = x.Value;
                var tree = CSharpSyntaxTree.ParseText(text, options: options);
                if (tree.GetDiagnostics().Any())
                    throw new Exception(string.Format("Syntax error in file \"{0}\".", x.Key));
                return tree;
            }).ToArray();

            // adding everything is going to cause issues with dynamic assemblies
            // so we would want to filter them anyway... but we don't need them really
            //var refs = AssemblyUtility.GetAllReferencedAssemblyLocations().Select(x => new MetadataFileReference(x));
            // though that one is not ok either since we want our own reference
            //var refs = Enumerable.Empty<MetadataReference>();
            // so use the bare minimum
            var asms = ReferencedAssemblies;
            var a1 = typeof(Builder).Assembly;
            asms.Add(a1);
            foreach (var a in GetDeepReferencedAssemblies(a1)) asms.Add(a);
            var refs = asms.Select(x => MetadataReference.CreateFromFile(x.Location));

            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary);
            var compilation = CSharpCompilation.Create(
                assemblyName,
                /*syntaxTrees:*/ trees,
                /*references:*/ refs,
                compilationOptions);

            return compilation;
        }
开发者ID:nul800sebastiaan,项目名称:Zbu.ModelsBuilder,代码行数:33,代码来源:Compiler.cs

示例12: TestStrings

 private void TestStrings(
     IEnumerable<string> testData,
     IDictionary<string, string> testQueries,
     Func<string, Expression<Func<TestDatabaseExtensions.Simple, bool>>> filterExpressionForTest)
 {
     TestStrings(testData, testQueries.Select(test => Tuple.Create(test.Key, test.Value)).ToList(), filterExpressionForTest);
 }
开发者ID:tjakopovic,项目名称:Rhetos,代码行数:7,代码来源:DatabaseExtensionsTest.cs

示例13: UncompressedMemoryArchive

 /// <summary>
 /// Constructor.
 /// </summary>
 public UncompressedMemoryArchive(IDictionary<string, byte[]> files)
 {
     _contents = files
         .Select(kvp => new UncompressedMemoryArchiveFile(kvp.Key, kvp.Value))
         .Cast<IArchiveFile>()
         .ToList();
 }
开发者ID:CSClassroom,项目名称:CSClassroom,代码行数:10,代码来源:UncompressedMemoryArchive.cs

示例14: Convert

		/// <summary>
		/// Converts the specified parameters.
		/// </summary>
		/// <param name="parameters">The parameters.</param>
		/// <returns></returns>
		public static NameValuePairList Convert(IDictionary<string, string> parameters)
		{
			return new NameValuePairList {
				Count = (uint)parameters.Count,
				Pairs = parameters.Select(p => new NameValuePair(p.Key, p.Value)).ToArray()
			};
		}
开发者ID:HaKDMoDz,项目名称:InVision,代码行数:12,代码来源:NameValuePairList.cs

示例15: CreateQueryString

        private static string CreateQueryString(
            IDictionary<string, string> clientFilters,
            int page)
        {
            // Go through, replacing the page.number query param's value with
            // the actual page. Preserves other query parameters, since they're
            // still needed to provide the correct pagination links.
            var queries = clientFilters.Select(kv =>
            {
                var key = kv.Key;
                var value = kv.Key == Constants.PageNumberQueryName ? page.ToString() : kv.Value;

                if (string.IsNullOrEmpty(value))
                {
                    return null;
                }

                var parserMatch = queryParser.Match(key);

                if (!parserMatch.Success)
                {
                    return new { Key = key, Value = value };
                }

                var left = parserMatch.Groups["left"].Value;
                var right = parserMatch.Groups["right"].Value;
                return new { Key = left + $"[{right}]", Value = value };
            }).Where(k => k != null).ToList();

            return queries.Any()
                ? "?" + string.Join("&", queries.Select(kv => $"{kv.Key}={kv.Value}"))
                : null;
        }
开发者ID:robladbrook,项目名称:saule-aspnet5,代码行数:33,代码来源:PaginationQuery.cs


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