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


C# Dictionary.Concat方法代码示例

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


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

示例1: GetArguments

        public object[] GetArguments(RouteInvocation route, IRequest request, MethodInfo method)
        {
            var foundArgs = new Dictionary<string, string[]>(ParameterComparer);
            foundArgs.Concat(route.RouteData);
            foundArgs.Concat(request.Query);
            foundArgs.Concat(request.Form);

            var args = new List<object>();
            foreach (var parameter in method.GetParameters())
            {
                object arg = null;
                var converter = Converters.FirstOrDefault
                    (x => x.CanConvert(parameter.ParameterType));
                if (converter != null) {
                    arg = converter.Convert(parameter.ParameterType, parameter.Name, foundArgs);
                }
                if ((converter == null || arg == null) && parameter.IsOptional)
                {
                    arg = (parameter.HasDefaultValue ? parameter.DefaultValue : null);
                }

                if (arg != null || parameter.IsOptional)
                {
                    args.Add(arg);
                }
                else
                {
                    throw new InvalidOperationException(String.Format(
                        "Required argument {0} was not supplied to method {1} on controller {2}",
                        parameter.Name, method.Name, method.DeclaringType));
                }
            }

            return args.ToArray();
        }
开发者ID:jammycakes,项目名称:dolstagis.web,代码行数:35,代码来源:ModelBinder.cs

示例2: GetRetroChanges

        private static IDictionary<SyntaxNode, SyntaxNode> GetRetroChanges(Compilation compilation, INamedTypeSymbol objectType)
        {
            var syntaxNodes = new Dictionary<SyntaxNode, SyntaxNode>();

            var semanticModels = compilation.SyntaxTrees.Select(x => compilation.GetSemanticModel(x));

            var genRefs = FindGenericClassMembers(semanticModels);

             //CHANGE
             //1. Generic references with cast
             //2. Generic T to Object
             //======

            foreach (var semanticModel in semanticModels)
            {
                var root = semanticModel.SyntaxTree.GetRoot();

                // get cast changes
                var castReferences = new Dictionary<SyntaxNode, SyntaxNode>();
                CastResursiveMethod(root, semanticModel, genRefs, castReferences);
                
                // get generic T to object
                var retroProperties = GenericToObject(root, semanticModel, objectType);

                var allChanges = castReferences.Concat(retroProperties);

                foreach (var ch in allChanges)
                    syntaxNodes.Add(ch.Key, ch.Value);
            }

            return syntaxNodes;
        }
开发者ID:mpielikis,项目名称:retrosharp,代码行数:32,代码来源:Generator.cs

示例3: Convert

        public Dictionary<string, object> Convert(string propertyName, CustomAttributeData attr)
        {
            var validations = new Dictionary<string, object>();

            var maxLength = GetConstructorArgumentValue(attr, 0);
            if (!string.IsNullOrWhiteSpace(maxLength))
            {
                var maxValidations = SetMaxLengthAAValidation(propertyName, attr, maxLength);
                validations = validations.Concat(maxValidations).ToDictionary(x => x.Key, x => x.Value);
            }

            var minLength = base.GetNamedArgumentValue(propertyName, attr, DataAnnotationConstants.MinimumLength, false);
            if (!string.IsNullOrWhiteSpace(minLength))
            {
                var minValidations = SetMinLengthAAValidation(propertyName, attr, minLength);
                validations = validations.Concat(minValidations).ToDictionary(x => x.Key, x => x.Value);
            }

            return validations;
        }
开发者ID:wald-tq,项目名称:aa-validation-from-server,代码行数:20,代码来源:StringLengthConverter.cs

示例4: ReadSubstitionVariablesFromConfigFile

        public void ReadSubstitionVariablesFromConfigFile()
        {
            var configFilePath = ConfigFile;
            var result = new Dictionary<string, string>
            {
                {"SERVERNAME", TargetDatabaseName},
                {"CRMDBNAME", CrmDatabaseName}
            };

            var config =
                JsonConvert.DeserializeObject<Config>(File.ReadAllText(configFilePath), new JsonSerializerSettings { });
            Variables = result.Concat(config.UsernameReplacements)
                .ToDictionary(x => x.Key, x => x.Value);
        }
开发者ID:campbellja,项目名称:dbup-deployer,代码行数:14,代码来源:Context.cs

示例5: MergeDictionaries

		/// <summary>
		/// Merge given dictionaries
		/// </summary>
		/// <param name="dictionaries">dictionaries to merge</param>
		/// <param name="overrideDueplicateWithLatterDictionaryValue">
		/// If true and duplicate key exists, then dupe key's values are overriden by latter dictionary values
		/// </param>
		public Dictionary<string, string> MergeDictionaries(
			Dictionary<int, Dictionary<string, string>> dictionaries, 
			bool overrideDueplicateWithLatterDictionaryValue = true)
		{
			Dictionary<string, string> result = new Dictionary<string, string>(dictionaries.Count);
			var query = overrideDueplicateWithLatterDictionaryValue ? dictionaries.Reverse() : dictionaries;

			foreach (var index in query)
			{
				Dictionary<string, string> d2 = index.Value;
				result = result.Concat(d2.Where(x => !result.Keys.Contains(x.Key))).ToDictionary(o => o.Key, o => o.Value);
			}

			return result;
		}
开发者ID:dance2die,项目名称:Project.TranslateTwitter,代码行数:22,代码来源:DictionaryMerger.cs

示例6: CreatePostBody

        public static FormUrlEncodedContent CreatePostBody(string method, string apikey, string apisig,
                                                          IEnumerable<KeyValuePair<string, string>> parameters)
        {
            var init = new Dictionary<string, string>
                           {
                               {"method", method},
                               {"api_key", apikey},
                               {"api_sig", apisig},
                               {"format", ResponseFormat}
                           };

            // TODO ordering
            var requestParameters = init.Concat(parameters);

            return new FormUrlEncodedContent(requestParameters);
        }
开发者ID:roberdjp,项目名称:lastfm,代码行数:16,代码来源:LastFm.cs

示例7: GetSignatureBaseString

        private static string GetSignatureBaseString(string httpMethod, string url, Dictionary<string, string> oAuthOptions)
        {
            var uri = new Uri(url);

            var normalizedUrl = string.Format("{0}://{1}{2}", uri.Scheme, uri.Host, uri.AbsolutePath);

            var queryString = uri.Query;

            var queryParameters = new Dictionary<string, string>();
            if (!string.IsNullOrEmpty(queryString))
            {
                var querySegments = queryString.Split('&');
                foreach (string segment in querySegments)
                {
                    var parts = segment.Split('=');
                    if (parts.Length > 0)
                    {
                        var key = parts[0].Trim(new[] { '?', ' ' });
                        var val = parts[1].Trim();

                        queryParameters.Add(key, val);
                    }
                }
            }

            var signableOptionsRaw = oAuthOptions.Concat(queryParameters).OrderBy(k => k.Key);

            var signableOptions = new Dictionary<string, string>();
            foreach (var option in signableOptionsRaw)
            {
                var key = UrlEncode(option.Key);
                var val = UrlEncode(option.Value);

                signableOptions.Add(key,val);
            }

            IOrderedEnumerable<KeyValuePair<string, string>> orderedSignableOptions = signableOptions.OrderBy(k => k.Key);

            var signableOptionParts = orderedSignableOptions.Select(option => String.Format("{0}%3D{1}", option.Key, option.Value)).ToList();

            var signableOptionString = string.Join("%26", signableOptionParts);

            var signatureParts = new List<string> {httpMethod, UrlEncode(normalizedUrl), signableOptionString};

            return string.Join("&", signatureParts);
        }
开发者ID:brianj1084,项目名称:FellowshipOneApi,代码行数:46,代码来源:RequestSigner.cs

示例8: getAllNodeNamesHelper

 private Dictionary<string, CCNode> getAllNodeNamesHelper(Dictionary<string, CCNode> children)
 {
     Dictionary<string, CCNode> list = new Dictionary<string, CCNode>();
     if (children != null)
     {
         foreach (KeyValuePair<string, CCNode> pair in children)
         {
             if (!pair.Key.StartsWith("__") && !pair.Key.StartsWith("#"))
             {
                 list.Add(pair.Key, pair.Value);
             }
             Dictionary<string, CCNode> list2 = getAllNodeNamesHelper(pair.Value.children);
             list = list.Concat(list2).ToDictionary(k => k.Key, v => v.Value);
         }
     }
     return list;
 }
开发者ID:ElmerNing,项目名称:Cocos2d-x-ParticleEditor-for-Windows,代码行数:17,代码来源:CCNode.cs

示例9: PreprocParse

 /// <summary>
 /// Parses preprocessor instructions.
 /// </summary>
 public static void PreprocParse(ref lib8081.CPU cpu, ref Dictionary<String, lib8081.instructions.Function> funcs, String code)
 {
     // Split the string out.
     String[] args = util.SplitWithQuotes(code);
     switch (args[0])
     {
         // More ungodly case statements.
         case "#load":
             PreprocInclude(ref cpu, ref funcs, args);
             break;
         case "#include":
             // No need for a dedicated function.
             var Included = PCDParser.GetParsedFunctions(args[1], ref cpu, true);
             funcs = funcs.Concat(Included).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
             break;
     }
 }
开发者ID:SunDwarf,项目名称:P8081,代码行数:20,代码来源:Preproc.cs

示例10: Execute

        /// <summary>Entry point</summary>
        public int Execute(CommandLine cmd, ConfigSource configuration)
        {
            Initialize(cmd, configuration);

            var proc = new Process();
            var runtime = configuration.GetRuntime();
            var ini = new Dictionary<string, IEnumerable<string>>()
            {
                { "magic_quotes_gpc", new string[] { "0" } },
                { "date.timezone", new string[] { TimeZoneInfo.Local.Olson() ?? "UTC" } },
                { "extension", configuration.GetExtensions(runtime) }
            };
            var use = configuration.GetUse() ?? UseComposer();

            Encoding encoding;
            Func<string, string> args;
            var main = Paths.TryLocate(use, new string[] { Paths.Compose("tools", MainFor(cmd) + ".php") }).FirstOrDefault();
            if (null == main)
            {
                main = Paths.Locate(new string[] { Paths.Binary().DirName() }, new string[] { MainFor(cmd) + "-main.php" }).First();
                encoding = Encoding.UTF8;

                // Arguments are encoded in utf-7, which is binary-safe
                args = Arguments.Encode;
            }
            else
            {
                args = Arguments.Escape;
                encoding = Encoding.GetEncoding("iso-8859-1");
            }

            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.FileName = configuration.GetExecutable(runtime) ?? "php";
            proc.StartInfo.Arguments = string.Format(
                "-C -q -d include_path=\".{0}{1}{0}{0}.{0}{2}\" {3} {4} {5}",
                Paths.Separator,
                string.Join(Paths.Separator, use.Concat(cmd.Options["modules"].Concat(ModulesFor(cmd)))),
                string.Join(Paths.Separator, cmd.Options["classpath"].Concat(ClassPathFor(cmd))),
                string.Join(" ", IniSettings(ini.Concat(configuration.GetArgs(runtime)))),
                main,
                string.Join(" ", ArgumentsFor(cmd).Select(args))
            );

            return cmd.ExecutionModel.Execute(proc, encoding);
        }
开发者ID:mikey179,项目名称:reference,代码行数:46,代码来源:Command.cs

示例11: GetUsedCarPrice

        /// <summary>
        /// </summary>
        /// <returns></returns>
        public string GetUsedCarPrice(Dictionary<string, string> paramList)
        {
            var paramBase = new Dictionary<string, string>
            {
                {"key", _appkey},
                {"dtype", "json"},
                {"method", "getUsedCarPrice"}
            };

            //合并参数
            var parameters = paramBase.Concat(paramList).ToDictionary(k => k.Key, v => v.Value);

            var result = DynamicWebService.SendPost(_url, parameters, "get");

            var obj = JObject.Parse(result);
            var errorCode = obj["reason"].ToString();
            return errorCode != "success" ? "0" : obj["result"].ToString();
        }
开发者ID:Chinaccn,项目名称:surfboard,代码行数:21,代码来源:JuheUtility.cs

示例12: ConvertToDictionary

        public static Dictionary<string, object> ConvertToDictionary(object data)
        {
            var result = new Dictionary<string, object>();
            if (data == null)
                return result;

            // Get all properties on the object
            var allPriperties = data.GetType().GetProperties()
                .Where(x => x.CanRead)
                .Where(x => x.GetValue(data, null) != null)
                .Where(x => !Attribute.IsDefined(x, typeof(QueryIgnore)));

            var nonTaggedProperties = allPriperties.Where(x => !Attribute.IsDefined(x, typeof(QueryProperty)))
                .ToDictionary(x => x.Name, x => x.GetValue(data, null));

            var taggedProperties = allPriperties.Where(x => Attribute.IsDefined(x, typeof(QueryProperty)))
                .ToDictionary(x => ((IEnumerable<QueryProperty>)x.GetCustomAttributes(typeof(QueryProperty), true)).First().Name, x => x.GetValue(data, null));

            return result.Concat(taggedProperties).Concat(nonTaggedProperties).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value);
        }
开发者ID:WhallaLabs,项目名称:QueryUrl-WP8,代码行数:20,代码来源:QueryUrlCore.cs

示例13: GetMediaFilesList

        public Dictionary<string, DateTime> GetMediaFilesList()
        {
            var searchOption = m_scanSubfolders ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
            var result = new Dictionary<string, DateTime>();

            foreach (var searchPattern in GetFolderSearchPatternsList())
            {
                var filesList = Directory.GetFiles(m_path, searchPattern, searchOption);
                m_totalItemsInProcess = filesList.Length;
                m_currentProgress = 0;
                m_logger.LogFormat(Resources.MediaMinerBase_GetMediaFilesList_Found__0__with__1__extension, m_totalItemsInProcess, searchPattern);

                Dictionary<string, DateTime> interimResult = filesList.AsParallel()
                    .Select(p => new { File = p, TakenDate = GetTakenDateEntry(p) })
                    .Where(p => p.TakenDate != null).ToDictionary(p => p.File, p => p.TakenDate.Value);

                result = result.Concat(interimResult).ToDictionary(p => p.Key, p => p.Value);
            }

            return result;
        }
开发者ID:anton-iermolenko,项目名称:Photo-library-toolkit,代码行数:21,代码来源:MediaMinerBase.cs

示例14: ConstructBasicParameters

        protected IDictionary<string,object> ConstructBasicParameters(string url, MethodType methodType, Token token, params KeyValuePair<string,object>[] optionalParameters)
        {
            Enforce.NotNull(url, "url");
            Enforce.NotNull(optionalParameters, "optionalParameters");

            var parameters = new Dictionary<string, object>
            {
                { "oauth_consumer_key", ConsumerKey },
                { "oauth_nonce", _random.Next() },
                { "oauth_timestamp", DateTime.UtcNow.ToUnixTime() },
                { "oauth_signature_method", "HMAC-SHA1" },
                { "oauth_version", "1.0" }
            };
            if (token != null)
                parameters.Add("oauth_token", token.Key);

            var signature = GenerateSignature(new Uri(url), methodType, token, parameters.Concat(optionalParameters));
            parameters.Add("oauth_signature", signature);

            return parameters;
        }
开发者ID:bling,项目名称:Ping.Pong,代码行数:21,代码来源:OAuthBase.cs

示例15: loadAllExtensions

        /// <summary>
        /// Loads all extension assemblies from the given base directory and all his sub folders.
        /// </summary>
        /// <param name="t">The Type to search for.</param>
        /// <param name="baseDirectory">The base directory.</param>
        /// <param name="prefix">The prefix added to the directory name (normally the parents directory key).</param>
        /// <returns>
        /// Dictionary of key [EXT_(subfoldername)] and list of available class types
        /// </returns>
        static Dictionary<String, List<Type>> loadAllExtensions(Type t, string baseDirectory, string prefix)
        {
            Dictionary<String, List<Type>> dic = new Dictionary<String, List<Type>>();
            if (t != null && Directory.Exists(baseDirectory))
            {
                //list all directly added types (without sub folder structure)
                var baseypes = LoadTypes(t, baseDirectory);

                if (baseypes != null && baseypes.Count > 0)
                {
                    dic.Add(prefix, baseypes);
                }

                // list all sub directories
                var subDirs = Directory.GetDirectories(baseDirectory);
                if (subDirs != null && subDirs.Length > 0)
                {
                    foreach (var subDir in subDirs)
                    {
                        try
                        {
                            if (Directory.Exists(subDir))
                            {
                                string name = new DirectoryInfo(subDir).Name;
                                name = (String.IsNullOrWhiteSpace(prefix) ? "" : (prefix + "_")) + name;
                                var subs = loadAllExtensions(t, subDir, name);

                                //combine the subs to the org
                                if (subs != null && subs.Count > 0)
                                {
                                    dic = dic.Concat(subs).ToDictionary(x => x.Key, x => x.Value);
                                }
                            }
                        }
                        catch(Exception){}
                    }
                }
            }
            return dic;
        }
开发者ID:TUD-INF-IAI-MCI,项目名称:DotNet_Extensibility,代码行数:49,代码来源:ExtensionLoader.cs


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