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


C# Dictionary.Merge方法代码示例

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


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

示例1: Diagnostic

        /// <summary>
        /// Diagnostics the specified base URL.
        /// </summary>
        /// <param name="baseUrl">The base URL.</param>
        /// <param name="paths">The paths.</param>
        /// <returns></returns>
        public static Dictionary<string, bool> Diagnostic(string baseUrl, params string[] paths)
        {
            Dictionary<string, bool> result = new Dictionary<string, bool>();

            if (!string.IsNullOrWhiteSpace(baseUrl) && paths.HasItem())
            {
                Parallel.ForEach(paths, (path) =>
                {
                    var httpRequest = string.Format("{0}/{1}", baseUrl.TrimEnd(' ', '/'), path.TrimStart('/', ' ')).CreateHttpWebRequest();

                    try
                    {
                        var response = httpRequest.GetResponse();
                        var length = response.ContentLength;

                        result.Merge(httpRequest.RequestUri.ToString(), true);
                    }
                    catch
                    {
                        result.Merge(httpRequest.RequestUri.ToString(), false);
                    }
                });
            }

            return result;
        }
开发者ID:rynnwang,项目名称:CommonSolution,代码行数:32,代码来源:QuickDiagnostic.cs

示例2: GetApiDocumentationAttributesAndReturnTypes

		private Dictionary<ApiDocumentationAttribute, Type> GetApiDocumentationAttributesAndReturnTypes( Type controllerType )
		{
			var result = new Dictionary<ApiDocumentationAttribute, Type>();

			var methods = GetControllerMethods( controllerType );
			var methodAttributesAndReturnTypes = GetMethodsAttributesAndReturnTypes( methods );
			var classAttributesAndReturnTypes = GetClassAttributesAndReturnTypes( controllerType );

			result.Merge( methodAttributesAndReturnTypes );
			result.Merge( classAttributesAndReturnTypes );

			return result;
		}
开发者ID:gandarez,项目名称:SwaggerAPIDocumentation,代码行数:13,代码来源:SwaggerDocumentationTools.cs

示例3: V

        public static ICode V(ICode ast) {
            var ctx = ast.Ctx;
            var blockInfo = VisitorSubstituteIrreducable.FindSuitableBlocks.GetInfo(ast);
            var bInfo = blockInfo.Select(x => new {
                toCount = VisitorContToCounter.GetCount(x.Key, ast),
                ast = x.Key,
                codeCount = x.Value.numICodes,
            }).ToArray();
            var block = bInfo.Where(x => x.toCount >= 2).OrderBy(x => x.toCount * x.codeCount).FirstOrDefault();
            if (block == null) {
                return ast;
            }

            var phis = new Dictionary<Expr,Expr>();
            var blockCopies = Enumerable.Range(0, block.toCount - 1)
                .Select(x => {
                    var v = new VisitorDuplicateCode();
                    var ret = v.Visit(block.ast);
                    phis = phis.Merge(v.phiMap, (a, b) => new ExprVarPhi(ctx) { Exprs = new[] { a, b } });
                    return ret;
                })
                .Concat(block.ast)
                .ToArray();

            var contTos = VisitorFindContinuationsRecursive.Get(ast).Where(x => x.To == block.ast).ToArray();
            for (int i = 0; i < contTos.Length; i++) {
                var contTo = contTos[i];
                var blockCopy = blockCopies[i];
                ast = VisitorReplace.V(ast, contTo, blockCopy);
            }

            ast = VisitorReplaceExprUse.V(ast, phis);

            return ast;
        }
开发者ID:chrisdunelm,项目名称:DotNetWebToolkit,代码行数:35,代码来源:VisitorDuplicateCode.cs

示例4: MergeReturnsSourceIfDictToMergeIsNull

 public void MergeReturnsSourceIfDictToMergeIsNull()
 {
     var source = new Dictionary<string, string> { { "key", "value" } };
     var candidate = source.Merge(null);
     Assert.IsNotNull(candidate);
     Assert.AreSame(source, candidate);
 }
开发者ID:kevinwiegand,项目名称:EnergyTrading-Core,代码行数:7,代码来源:DictionaryExtensionsFixture.cs

示例5: GetApiContracts

        /// <summary>
        /// Gets the API contracts.
        /// </summary>
        /// <returns>RemoteInvokeResult.</returns>
        public SandboxMarshalInvokeResult GetApiContracts()
        {
            SandboxMarshalInvokeResult result = new SandboxMarshalInvokeResult();

            try
            {
                Dictionary<string, string> interfaces = new Dictionary<string, string>();

                foreach (var one in EnvironmentCore.DescendingAssemblyDependencyChain)
                {
                    foreach (var item in one.GetTypes())
                    {
                        if (item.IsInterface && item.HasAttribute<ApiContractAttribute>() && !item.IsGenericTypeDefinition)
                        {
                            interfaces.Merge(item.GetFullName(), item.Name, false);
                        }
                    }
                }

                result.SetValue(interfaces);
            }
            catch (Exception ex)
            {
                result.SetException(ex.Handle());
            }

            return result;
        }
开发者ID:rynnwang,项目名称:CommonSolution,代码行数:32,代码来源:SandboxInvoker.cs

示例6: ForScope

        public IDictionary<string, object> ForScope(string path)
        {
            IDictionary<string, object> result = new Dictionary<string, object>();

            if (path == null) return result;

            if (path.Length > 0)
            {
                result = result.Merge(ForScope(Path.GetDirectoryName(path)));
            }
            if (_scopedValues.ContainsKey(path))
            {
                result = result.Merge(_scopedValues[path]);
            }
            return result;
        }
开发者ID:Code52,项目名称:pretzel,代码行数:16,代码来源:DefaultsConfiguration.cs

示例7: Merge_with_object_should_add_specified_items

        public void Merge_with_object_should_add_specified_items()
        {
            IDictionary<string, object> target = new Dictionary<string, object>();

            target.Merge(new { foo = "bar" });

            Assert.Equal("bar", target["foo"]);
        }
开发者ID:vialpando09,项目名称:RallyPortal2,代码行数:8,代码来源:DictionaryExtensionsTests.cs

示例8: Merge_with_object_should_not_replace_the_existing_items

        public void Merge_with_object_should_not_replace_the_existing_items()
        {
            IDictionary<string, object> target = new Dictionary<string, object> { { "foo", "bar" } };

            target.Merge(new { foo = "bar2" }, false);

            Assert.Equal("bar", target["foo"]);
        }
开发者ID:vialpando09,项目名称:RallyPortal2,代码行数:8,代码来源:DictionaryExtensionsTests.cs

示例9: DuplicatesAreNotOverwrittenByDefault

 public void DuplicatesAreNotOverwrittenByDefault()
 {
     var source = new Dictionary<string, string> { { "key", "value" } };
     var candidate = source.Merge(new Dictionary<string, string> { { "key", "value2" } });
     Assert.IsNotNull(candidate);
     Assert.AreEqual(1, candidate.Count);
     Assert.AreEqual("value", candidate["key"]);
 }
开发者ID:kevinwiegand,项目名称:EnergyTrading-Core,代码行数:8,代码来源:DictionaryExtensionsFixture.cs

示例10: DuplicatesOverwriteIfSpecified

 public void DuplicatesOverwriteIfSpecified()
 {
     var source = new Dictionary<string, string> { { "key", "value" } };
     var candidate = source.Merge(new Dictionary<string, string> { { "key", "value2" } }, true);
     Assert.IsNotNull(candidate);
     Assert.AreEqual(1, candidate.Count);
     Assert.AreEqual("value2", candidate["key"]);
 }
开发者ID:kevinwiegand,项目名称:EnergyTrading-Core,代码行数:8,代码来源:DictionaryExtensionsFixture.cs

示例11: Should_be_able_to_merge_item

        public void Should_be_able_to_merge_item()
        {
            IDictionary<string, object> target = new Dictionary<string, object>();

            target.Merge("key", "value", true);

            Assert.True(target.ContainsKey("key"));
        }
开发者ID:timbooker,项目名称:telerikaspnetmvc,代码行数:8,代码来源:DictionaryExtensionsTests.cs

示例12: LogWarning

 public static void LogWarning(Exception ex, Dictionary<string, string> attributes = null)
 {
     var attr = attributes.Merge(new Dictionary<string, string>
     {
         {"Exception", ex.Message},
         {"Stack", ex.StackTrace}
     });
     Session.TagEvent("Warning", attr);
 }
开发者ID:Bunk,项目名称:trellow,代码行数:9,代码来源:Analytics.cs

示例13: DictionariesAreMerged

 public void DictionariesAreMerged()
 {
     var source = new Dictionary<string, string> { { "key", "value" } };
     var candidate = source.Merge(new Dictionary<string, string> { { "key2", "value2" } });
     Assert.IsNotNull(candidate);
     Assert.AreEqual(2, candidate.Count);
     Assert.AreEqual("value", candidate["key"]);
     Assert.AreEqual("value2", candidate["key2"]);
 }
开发者ID:kevinwiegand,项目名称:EnergyTrading-Core,代码行数:9,代码来源:DictionaryExtensionsFixture.cs

示例14: Match

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            var attributeRoute = (IAttributeRoute)route;
            var allDefaults = new Dictionary<string, object>();
            allDefaults.Merge(attributeRoute.Defaults);
            allDefaults.Merge(attributeRoute.QueryStringDefaults);

            // If the param is optional and has no value, then pass the constraint
            if (allDefaults.ContainsKey(parameterName) && allDefaults[parameterName] == UrlParameter.Optional)
            {
                if (values[parameterName].HasNoValue())
                {
                    return true;
                }
            }

            return _constraint.Match(httpContext, route, parameterName, values, routeDirection);
        }
开发者ID:Cefa68000,项目名称:AttributeRouting,代码行数:18,代码来源:OptionalRouteConstraint.cs

示例15: GetControllerModels

        public Dictionary<string, ApiDocModel> GetControllerModels( Type controllerType )
        {
            var result = new Dictionary<String, ApiDocModel>();
            foreach ( var apiDocumentationAttributesAndReturnType in GetApiDocumentationAttributesAndReturnTypes( controllerType ) )
            {
                result.Merge( _modelsGenerator.GetModels( apiDocumentationAttributesAndReturnType.Key.ReturnType ?? apiDocumentationAttributesAndReturnType.Value ) );
            }

            return result;
        }
开发者ID:jaybredenberg,项目名称:SwaggerAPIDocumentation,代码行数:10,代码来源:SwaggerDocumentationTools.cs


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