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


C# Dictionary.add方法代码示例

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


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

示例1: CheckThatObjectIsNotUsed_TMUser

        public void CheckThatObjectIsNotUsed_TMUser()
        {
            var methods = tmWebServices.type().methods();
            Assert.Less(100,methods.size());
            var returnTypeMappings = new Dictionary<string, List<MethodInfo>>();

            //Create a Mapping based on the return Type of all WebServices methods
            foreach (var method in methods)
            {
                var returnType = method.ReturnType;
                if (returnType.IsGenericType)
                    foreach(var genericParameter in returnType.GetGenericArguments())
                        returnTypeMappings.add(genericParameter.Name, method);
                returnTypeMappings.add(returnType.Name, method);
            }
            returnTypeMappings.Keys.toString().info();

            var typeNames = returnTypeMappings.Keys.toList();
            Assert.Less     (15, typeNames.size());

            Assert.IsTrue (typeNames.contains("TeamMentor_Article"));
            Assert.IsTrue (typeNames.contains("TM_Library"));
            Assert.IsTrue (typeNames.contains("Folder_V3"));
            Assert.IsTrue (typeNames.contains("View_V3"));
            Assert.IsTrue (typeNames.contains("Library"));
            Assert.IsTrue (typeNames.contains("Guid"));
            Assert.IsTrue (typeNames.contains("TM_User")  , "TM_User object should be used instead of TMUser");

            Assert.IsFalse(typeNames.contains("TMUser")   , "TMUser object must not be exposed on a WebService (since it contains all user info, including its passwordHash)");

            //returnTypeMappings["TMUser"].names().toString().info();
        }
开发者ID:sempf,项目名称:Dev,代码行数:32,代码来源:Test_WebServices_Security.cs

示例2: queryParameters_Indexed_ByName

 public static Dictionary<string, string> queryParameters_Indexed_ByName(this Uri uri)
 {
     var queryParameters = new Dictionary<string,string>();
     if (uri.notNull())
     {
         var query = uri.Query;
         if (query.starts("?"))
             query = query.removeFirstChar();
         foreach(var parameter in query.split("&"))
             if (parameter.valid())
             {
                 var splitParameter = parameter.split("=");
                 if (splitParameter.size()==2)
                     if (queryParameters.hasKey(splitParameter[0]))
                     {
                         "duplicate parameter key in property '{0}', adding extra parameter in a new line".info(splitParameter[0]);
                         queryParameters.add(splitParameter[0], queryParameters[splitParameter[0]].line() + splitParameter[1]);
                     }
                     else
                         queryParameters.add(splitParameter[0], splitParameter[1]);
                 else
                     "Something's wrong with the parameter value, there should only be one = in there: '{0}' ".info(parameter);
             }
     }
     return queryParameters;
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:26,代码来源:Web_ExtensionMethods_QueryString.cs

示例3: indexed_By_MemberName

 public static Dictionary<string, List<string>> indexed_By_MemberName(this List<ValidationResult> validationResults)
 {
     var mappedData = new Dictionary<string, List<string>>();
     foreach(var validationResult in validationResults)
         foreach (var memberName in validationResult.MemberNames)
             mappedData.add(memberName, validationResult.ErrorMessage);
     return mappedData;
 }
开发者ID:sarvaje,项目名称:Master,代码行数:8,代码来源:TMUser_ExtensionMethods.cs

示例4: GetAvailableScripts

 public static Dictionary<string, string> GetAvailableScripts()
 {
     var files = HttpContextFactory.Server.MapPath(TBOT_SCRIPTS_FOLDER)
                                   .files(true, "*.cshtml");
     var mappings = new Dictionary<string, string>();
     foreach (var file in files)
         mappings.add(file.fileName_WithoutExtension(), file);
     return mappings;
     //return files.toDictionary((file) => file.fileName_WithoutExtension()); //this doesn't handle duplicate files names
 }
开发者ID:sempf,项目名称:Dev,代码行数:10,代码来源:TBot_Brain.cs

示例5: showInTreeView

        public static void showInTreeView(this MethodMappings methodMappings, TreeView treeView, string filter, bool showSourceCodeSnippets, bool onlyShowSourceCodeLine)
        {
            treeView.parent().backColor("LightPink");
            treeView.visible(false);
            treeView.clear();
            var indexedMappings = methodMappings.indexedByKey(filter);
            if (onlyShowSourceCodeLine)
            {
                //do this so that we don't add more than one item per line
                var indexedByFileAndLine = new Dictionary<string, MethodMapping>();

                foreach(var item in indexedMappings)
                    foreach(var methodMapping in item.Value)
                        if (methodMapping.File.valid())
                        {
                            var key = "{0}_{1}".format(methodMapping.File, methodMapping.Start_Line);
                            indexedByFileAndLine.add(key, methodMapping);
                        }
                // now group then by the same text in the SourceCodeLine
                var indexedBySourceCodeLine =  new Dictionary<string, List<MethodMapping>>();
                foreach(var methodMapping in indexedByFileAndLine.Values)
                    indexedBySourceCodeLine.add(methodMapping.sourceCodeLine(), methodMapping);

                //Finally show then
                foreach(var item  in indexedBySourceCodeLine)
                {
                    var uniqueTextNode = treeView.add_Node(item.Key, item.Value,true);
                }
            }
            else
            {
                foreach(var item in indexedMappings)
                {
                    var keyNodeText = "{0}                       ({1})".format(item.Key, item.Value.size());
                    var keyNode= treeView.add_Node(keyNodeText, item.Value,true);
                }
                treeView.afterSelect<List<MethodMapping>>(
                    (mappings)=>{
                                    var keyNode = treeView.selected();
                                    keyNode.clear();
                                    foreach(var methodMapping in mappings)
                                    {
                                        var nodeText = (showSourceCodeSnippets)
                                            ? methodMapping.sourceCodeLine()
                                            : "{0} - {1}".format(methodMapping.INodeType,methodMapping.SourceCode);
                                        keyNode.add_Node(nodeText, methodMapping);
                                    }
                    });
            }
            treeView.parent().backColor("Control");
            treeView.visible(true);
        }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:52,代码来源:MethodMappings_ExtensionMethods_GUI.cs

示例6: executeScript_ConvertTo_DicionaryStringString

     	public static Dictionary<string,string> executeScript_ConvertTo_DicionaryStringString(this API_Azure_via_WebREPL apiAzure, string script, string nameKey, string valueKey)
     	{
     		var data = new Dictionary<string,string>();
     		var response = apiAzure.executeScript(script);
     		if (response.valid())
     		{
     			var items = (Object[])response.json_Deserialize();			
				if (items.notNull())						
					foreach(Dictionary<string,object> item in items)				
						data.add(item[nameKey].str(),item[valueKey].str());						
     		}
     		return data;
     	}	
开发者ID:CallMeSteve,项目名称:O2.Platform.Scripts,代码行数:13,代码来源:API_Azure_via_WebREPL.cs

示例7: variables_byIndex

		public static Dictionary<int, List<Java_Variable>> variables_byIndex(this Java_Method method)
		{
			var variables_byIndex = new Dictionary<int, List<Java_Variable>>();
			foreach(var variable in method.Variables)
				variables_byIndex.add(variable.Index, variable);
			return variables_byIndex;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:7,代码来源:API_IKVMC_JavaMetadata.cs

示例8: methods_MappedTo_EnclosingMethod

		public static Dictionary<string, string> methods_MappedTo_EnclosingMethod(this API_IKVMC_Java_Metadata javaMetadata)
		{
			var enclosingMethods = new Dictionary<string, string>();
			foreach(var _class in javaMetadata.Classes)
				if (_class.EnclosingMethod.notNull())
					foreach(var method in _class.Methods)
						enclosingMethods.add(method.Signature, _class.EnclosingMethod);
			return 	enclosingMethods;			
		}		
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:API_IKVMC_JavaMetadata.cs

示例9: classes_MappedTo_EnclosingMethod

		public static Dictionary<string, List<Java_Class>> classes_MappedTo_EnclosingMethod(this API_IKVMC_Java_Metadata javaMetadata)
		{
			var enclosingMethods = new Dictionary<string, List<Java_Class>>();
			foreach(var _class in javaMetadata.Classes)
				if (_class.EnclosingMethod.notNull())
					enclosingMethods.add(_class.EnclosingMethod, _class);
			return 	enclosingMethods;	
		}
开发者ID:pusp,项目名称:o2platform,代码行数:8,代码来源:API_IKVMC_JavaMetadata.cs

示例10: externalMethodsAndProperties

        public static Dictionary<string,List<KeyValuePair<INode,IMethodOrProperty>>> externalMethodsAndProperties(this O2MappedAstData astData, IMethod iMethod)
        {        	
        	var externalMethods = new Dictionary<string,List<KeyValuePair<INode,IMethodOrProperty>>>();
        	// add the current method
        	
        	externalMethods.add(iMethod.DotNetName,  new KeyValuePair<INode,IMethodOrProperty>(astData.methodDeclaration(iMethod) ,iMethod));
        	
        	var iNodesAdded = new List<INode>();
        	
        	foreach (var methodCalled in astData.calledINodesReferences(iMethod))
			 	if (methodCalled is MemberReferenceExpression)
                {                             	
                	var memberRef = (MemberReferenceExpression)methodCalled;                 	
                	{                	
                		var methodOrProperty = astData.fromMemberReferenceExpressionGetIMethodOrProperty(memberRef);
                		if(methodOrProperty.notNull())                     	
                		{
                			externalMethods.add(methodOrProperty.DotNetName, new KeyValuePair<INode,IMethodOrProperty>(memberRef,methodOrProperty)); 
                			iNodesAdded.Add(memberRef);
                		}
                		else
                			externalMethods.add(astData.getTextForINode(memberRef),new KeyValuePair<INode,IMethodOrProperty>(memberRef,null));
                	}
				}
			
			
        	foreach(var mapping in astData.calledIMethods_getMappings(iMethod))
        	{                
                var iMethodMapping = mapping.Key;
                var iNodeMapping = mapping.Value;
                if (iNodesAdded.Contains(iNodeMapping).isFalse())
                	if (iNodeMapping is ObjectCreateExpression ||
                	   ((iNodeMapping is InvocationExpression &&
                	    (iNodeMapping as InvocationExpression).TargetObject.notNull() && 
                	    iNodesAdded.Contains((iNodeMapping as InvocationExpression).TargetObject).isFalse())))
                	 {                	 	
						var nodeText = (iMethodMapping.notNull())
												? iMethodMapping.DotNetName
												: astData.getTextForINode(iNodeMapping);
						externalMethods.add(nodeText, new KeyValuePair<INode,IMethodOrProperty>(iNodeMapping,iMethodMapping)); 				
					 }	
            }
        	
        	return externalMethods;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:45,代码来源:MethodMappings_ExtensionMethods.cs

示例11: loadFiles

		public void loadFiles(string filesPath, List<string> filesToLoad)
		{						
			sourceCode.set_Text("Loading files from: {0}".format(filesPath));
			Path.set_Text(filesPath);
			var filesContent = new Dictionary<string,string>();
			var nonBinaryFiles = new List<string>();
			foreach(var file in filesToLoad) 
				if (file.isBinaryFormat().isFalse()) 
					nonBinaryFiles.add(file);
			
			foreach(var file in nonBinaryFiles) 
					filesContent.add(file.remove(filesPath),file.contents());	
					
			searchEngine = new SearchEngine();
			searchEngine.loadFiles(nonBinaryFiles); 			
			
			//searchEngine.fixH2FileLoadingIssue();
			
			leftPanel.clear();
			treeView = leftPanel.add_TreeViewWithFilter(filesContent); 
			treeView.afterSelect<string>(
				(fileContents)=>{					
									sourceCode.open(filesPath + treeView.selected().get_Text());
								});						
			sourceCode.colorCodeForExtension(treeView.selected().str());
			sourceCode.set_Text("");
			textSearch_TextBox = leftPanel.controls<TextBox>(true)[1];
			textSearch_TextBox.onEnter(
				(text)=>{
					var searchResults = searchEngine.searchFor(text);
					dataGridView.loadInDataGridView_textSearchResults(searchResults);  
				});
			
			
		}		
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Scripts,代码行数:35,代码来源:ascx_SimpleFileSearch.cs

示例12: controllers_by_JavaClass

		public static Dictionary<string, SpringMvcController> controllers_by_JavaClass(this SpringMvcMappings mvcMappings)
		{
			var controllers_by_JavaClass = new Dictionary<string, SpringMvcController>();
			foreach(var controller in mvcMappings.Controllers)
				controllers_by_JavaClass.add(controller.JavaClass, controller);
			return controllers_by_JavaClass;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:7,代码来源:SpringMvcMappings.cs

示例13: show_ImagesList_In_TreeView

		public static List<Image> show_ImagesList_In_TreeView(this API_AmazonEC2 amazonEC2, AmazonEC2Client ec2Client, Control control)
		{				
			var treeView = control.clear().add_TreeView_with_PropertyGrid(false).sort();  	 
			treeView.parent().backColor(System.Drawing.Color.Azure);
			treeView.visible(false);
			Application.DoEvents();
			var imagesList = amazonEC2.getImagesList(ec2Client); 
			
			Func<Amazon.EC2.Model.Image,string> imageName = 
				(image)=> (image.Description.valid())
									? "{0} - {1}".format(image.Description, image.Name)
									: "{0}".format(image.Name).trim();
									
			Action<string> mapByProperty  = 
				(propertyName)=>{				
									var byPropertyNode = treeView.add_Node("by {0}".format(propertyName),"");
									foreach(var distinctPropertyValue in imagesList.Select((image)=>image.property(propertyName).str()).Distinct())
									{										
										var byDistinctPropertyValue = byPropertyNode.add_Node(distinctPropertyValue,"");

										var mappedByImageName = new Dictionary<string, List<Image>>();
										foreach(var imageInProperty in imagesList.Where((image) => image.property(propertyName).str() == distinctPropertyValue))
											mappedByImageName.add(imageName(imageInProperty),imageInProperty);																				
											
										foreach(var mappedData in mappedByImageName)
										{
											if (mappedData.Value.size() > 1)
												byDistinctPropertyValue.add_Node("{0}".format(mappedData.Key,mappedData.Value.size()))
														      		   .add_Nodes(mappedData.Value, imageName);
											else
												byDistinctPropertyValue.add_Node(imageName(mappedData.Value.first()),mappedData.Value.first());
										}			     
									}													  			
								};
			mapByProperty("Visibility");
			mapByProperty("ImageOwnerAlias");
			mapByProperty("Platform"); 
			mapByProperty("Architecture"); 
			"Completed processing show_ImagesList_In_TreeView".info();
			if (treeView.nodes().size()>0)
				treeView.backColor(System.Drawing.Color.White); 
			treeView.visible(true);				
			return imagesList;
		}
开发者ID:paul-green,项目名称:O2.Platform.Scripts,代码行数:44,代码来源:API_AmazonEC2.cs

示例14: files_Indexed_by_FileName

 public static Dictionary<string, string> files_Indexed_by_FileName(this List<string> files)
 {
     var files_Indexed_By_FileName = new Dictionary<string,string>();
     foreach(var file in files)
         files_Indexed_By_FileName.add(file.fileName(), file);
     return files_Indexed_By_FileName;
 }
开发者ID:njmube,项目名称:FluentSharp,代码行数:7,代码来源:IO_ExtensionMethods_File_Open.cs

示例15: files_Mapped_by_Extension

 public static Dictionary<string, List<string>> files_Mapped_by_Extension(this List<string> files)
 {
     var files_Indexed_By_FileName = new Dictionary<string,List<string>>();
     foreach(var file in files)
         files_Indexed_By_FileName.add(file.extension(), file);
     return files_Indexed_By_FileName;
 }
开发者ID:njmube,项目名称:FluentSharp,代码行数:7,代码来源:IO_ExtensionMethods_File_Open.cs


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