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


C# DomNode.AddChild方法代码示例

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


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

示例1: InsertComment

		public void InsertComment (DomNode node, MonoDevelop.CSharp.Dom.Comment comment)
		{
			if (node.EndLocation < comment.StartLocation) {
				node.AddChild (comment);
				return;
			}
			
			foreach (var child in node.Children) {
				if (child.StartLocation < comment.StartLocation && comment.StartLocation < child.EndLocation) {
					InsertComment (child, comment);
					return;
				}
				if (comment.StartLocation < child.StartLocation) {
					node.InsertChildBefore (child, comment, DomNode.Roles.Comment);
					return;
				}
			}
			
			node.AddChild (comment);
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:20,代码来源:CSharpParser.cs

示例2: AddModifiers

			void AddModifiers (DomNode parent, LocationsBag.MemberLocations location)
			{
				if (location == null || location.Modifiers == null)
					return;
				foreach (var modifier in location.Modifiers) {
					parent.AddChild (new CSharpModifierToken (Convert (modifier.Item2), modifierTable[modifier.Item1]), DomNode.Roles.Modifier);
				}
			}
开发者ID:nickname100,项目名称:monodevelop,代码行数:8,代码来源:CSharpParser.cs

示例3: AddArguments

			void AddArguments (DomNode parent, object location, Mono.CSharp.Arguments args)
			{
				if (args == null)
					return;
				
				var commaLocations = LocationsBag.GetLocations (args);
				
				for (int i = 0; i < args.Count; i++) {
					Argument arg = args[i];
					if (arg.ArgType == Argument.AType.Out || arg.ArgType == Argument.AType.Ref) {
						DirectionExpression direction = new DirectionExpression ();
						direction.FieldDirection = arg.ArgType == Argument.AType.Out ? FieldDirection.Out : FieldDirection.Ref;
						var argLocation = LocationsBag.GetLocations (arg);
						if (location != null)
							direction.AddChild (new CSharpTokenNode (Convert (argLocation[0]), "123".Length), InvocationExpression.Roles.Keyword);
						direction.AddChild ((DomNode)arg.Expr.Accept (this), InvocationExpression.Roles.Expression);
						
						parent.AddChild (direction, InvocationExpression.Roles.Parameter);
					} else {
						parent.AddChild ((DomNode)arg.Expr.Accept (this), InvocationExpression.Roles.Parameter);
					}
					if (commaLocations != null && i > 0) {
						int idx = commaLocations.Count - i;
						if (idx >= 0)
							parent.AddChild (new CSharpTokenNode (Convert (commaLocations[idx]), 1), InvocationExpression.Roles.Comma);
					}
				}
				if (commaLocations != null && commaLocations.Count > args.Count) 
					parent.AddChild (new CSharpTokenNode (Convert (commaLocations[0]), 1), InvocationExpression.Roles.Comma);
			}
开发者ID:nickname100,项目名称:monodevelop,代码行数:30,代码来源:CSharpParser.cs

示例4: AddConstraints

			void AddConstraints (DomNode parent, DeclSpace d)
			{
				if (d == null || d.Constraints == null)
					return;
				for (int i = 0; i < d.Constraints.Count; i++) {
					Constraints c = d.Constraints[i];
					var location = LocationsBag.GetLocations (c);
//					var constraint = new Constraint ();
					parent.AddChild (new CSharpTokenNode (Convert (location[0]), "where".Length), InvocationExpression.Roles.Keyword);
					parent.AddChild (new Identifier (c.TypeParameter.Value, Convert (c.TypeParameter.Location)), InvocationExpression.Roles.Identifier);
					parent.AddChild (new CSharpTokenNode (Convert (location[1]), 1), InvocationExpression.Roles.Colon);
					foreach (var expr in c.ConstraintExpressions)
						parent.AddChild ((DomNode)expr.Accept (this), InvocationExpression.Roles.TypeParameter);
				}
			}
开发者ID:nickname100,项目名称:monodevelop,代码行数:15,代码来源:CSharpParser.cs

示例5: AddTypeArguments

			void AddTypeArguments (DomNode parent, List<Location> location, Mono.CSharp.TypeArguments typeArguments)
			{
				if (typeArguments == null || typeArguments.IsEmpty)
					return;
				for (int i = 0; i < typeArguments.Count; i++) {
					if (location != null && i > 0 && i - 1 < location.Count)
						parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma);
					var arg = typeArguments.Args[i];
					if (arg == null)
						continue;
					parent.AddChild ((DomNode)arg.Accept (this), InvocationExpression.Roles.TypeParameter);
				}
			}
开发者ID:nickname100,项目名称:monodevelop,代码行数:13,代码来源:CSharpParser.cs

示例6: AddParameter

			void AddParameter (DomNode parent, Mono.CSharp.AParametersCollection parameters)
			{
				if (parameters == null)
					return;
				var paramLocation = LocationsBag.GetLocations (parameters);
			
				for (int i = 0; i < parameters.Count; i++) {
					if (paramLocation != null && i > 0 && i - 1 < paramLocation.Count) 
						parent.AddChild (new CSharpTokenNode (Convert (paramLocation[i - 1]), 1), ParameterDeclaration.Roles.Comma);
					var p = (Parameter)parameters.FixedParameters[i];
					var location = LocationsBag.GetLocations (p);
					
					ParameterDeclaration parameterDeclarationExpression = new ParameterDeclaration ();
					switch (p.ModFlags) {
					case Parameter.Modifier.OUT:
						parameterDeclarationExpression.ParameterModifier = ParameterModifier.Out;
						if (location != null)
							parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[0]), "out".Length), ParameterDeclaration.Roles.Keyword);
						break;
					case Parameter.Modifier.REF:
						parameterDeclarationExpression.ParameterModifier = ParameterModifier.Ref;
						if (location != null)
							parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[0]), "ref".Length), ParameterDeclaration.Roles.Keyword);
						break;
					case Parameter.Modifier.PARAMS:
						parameterDeclarationExpression.ParameterModifier = ParameterModifier.Params;
						if (location != null)
							parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[0]), "params".Length), ParameterDeclaration.Roles.Keyword);
						break;
					case Parameter.Modifier.This:
						parameterDeclarationExpression.ParameterModifier = ParameterModifier.This;
						if (location != null)
							parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[0]), "this".Length), ParameterDeclaration.Roles.Keyword);
						break;
					}
					if (p.TypeExpression != null) // lambdas may have no types (a, b) => ...
						parameterDeclarationExpression.AddChild ((DomNode)p.TypeExpression.Accept (this), ParameterDeclaration.Roles.ReturnType);
					parameterDeclarationExpression.AddChild (new Identifier (p.Name, Convert (p.Location)), ParameterDeclaration.Roles.Identifier);
					if (p.HasDefaultValue) {
						if (location != null)
							parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ParameterDeclaration.Roles.Assign);
						parameterDeclarationExpression.AddChild ((DomNode)p.DefaultValue.Accept (this), ParameterDeclaration.Roles.Expression);
					}
					parent.AddChild (parameterDeclarationExpression, InvocationExpression.Roles.Parameter);
				}
			}
开发者ID:nickname100,项目名称:monodevelop,代码行数:46,代码来源:CSharpParser.cs

示例7: AddTypeArguments

			void AddTypeArguments (DomNode parent, LocationsBag.MemberLocations location, Mono.CSharp.TypeArguments typeArguments)
			{
				if (typeArguments == null)
					return;
				for (int i = 0; i < typeArguments.Count; i++) {
					if (location != null && i > 0 && i - 1 < location.Count)
						parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma);
					parent.AddChild ((DomNode)typeArguments.Args[i].Accept (this), InvocationExpression.Roles.TypeParameter);
				}
			}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:10,代码来源:CSharpParser.cs


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