本文整理汇总了C#中this.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# this.AddChild方法的具体用法?C# this.AddChild怎么用?C# this.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.AddChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Property
/// <summary>
/// Add a property to a <see cref="FunctionBody"/>
/// </summary>
/// <param name="functionBody"><see cref="FunctionBody"/> to add to</param>
/// <param name="name">Name of the property to add</param>
/// <param name="callback"><see cref="Action{PropertyAssignment}"/> that gets called for working with the <see cref="PropertyAssignment"/></param>
/// <returns>Chained <see cref="FunctionBody"/> to keep building on</returns>
public static FunctionBody Property(this FunctionBody functionBody, string name, Action<PropertyAssignment> callback)
{
var propertyAssignment = new PropertyAssignment(name);
functionBody.AddChild(propertyAssignment);
callback(propertyAssignment);
return functionBody;
}
示例2: AssignAccessor
/// <summary>
/// Add a <see cref="AccessorAssignment"/> to the <see cref="FunctionBody"/>
/// </summary>
/// <param name="functionBody"><see cref="FunctionBody"/> to add to</param>
/// <param name="name">Name of the property to add</param>
/// <param name="callback"><see cref="Action{AccessorAssignment}"/> that gets called for working with the <see cref="AccessorAssignment"/></param>
/// <returns>Chained <see cref="FunctionBody"/> to keep building on</returns>
public static FunctionBody AssignAccessor(this FunctionBody functionBody, string name, Action<AccessorAssignment> callback)
{
var accessorAssignment = new AccessorAssignment(name);
functionBody.AddChild(accessorAssignment);
callback(accessorAssignment);
return functionBody;
}
示例3: setFirstChild
public static void setFirstChild( this ITree tree, ITree child )
{
if ( tree.ChildCount == 0 )
tree.AddChild( child );
else
tree.SetChild( 0, child );
}
示例4: add_Method
public static MethodDeclaration add_Method(this TypeDeclaration typeDeclaration, string methodName, Dictionary<string, object> invocationParameters, BlockStatement body)
{
var newMethod = new MethodDeclaration
{
Name = methodName,
//Modifier = Modifiers.None | Modifiers.Public | Modifiers.Static,
Modifier = Modifiers.None | Modifiers.Public,
Body = body
};
newMethod.setReturnType();
if (invocationParameters != null)
foreach (var invocationParameter in invocationParameters)
{
var parameterType = new TypeReference(
(invocationParameter.Value != null && invocationParameter.Key != "returnData")
? invocationParameter.Value.typeFullName()
: "System.Object", true);
var parameter = new ParameterDeclarationExpression(parameterType, invocationParameter.Key);
newMethod.Parameters.Add(parameter);
}
typeDeclaration.AddChild(newMethod);
return newMethod;
}
示例5: AddChild
public static DomElement AddChild(this DomElement elem, string elementName, out DomElement elemExit)
{
var newchild = elem.OwnerDocument.CreateElement(elementName);
elem.AddChild(newchild);
elemExit = newchild;
return newchild;
}
示例6: add_Type
// create
public static TypeDeclaration add_Type(this NamespaceDeclaration namespaceDeclaration, IClass iClass)
{
// move to method IClass.typeDeclaration();
var typeName = iClass.Name;
var newType = namespaceDeclaration.type(typeName); // check if already exists and if it does return it
if (newType != null)
return newType;
const Modifiers modifiers = Modifiers.None | Modifiers.Public;
newType = new TypeDeclaration(modifiers, new List<AttributeSection>());
newType.Name = typeName;
foreach (var baseType in iClass.BaseTypes)
{
if (baseType.FullyQualifiedName != "System.Object") // no need to include this one
newType.BaseTypes.Add(new TypeReference(baseType.FullyQualifiedName));
}
namespaceDeclaration.AddChild(newType);
return newType;
//return namespaceDeclaration.add_Type(iClass.Name);
}
示例7: Access
/// <summary>
/// Add a accessor accessing an object
/// </summary>
/// <param name="functionBody"><see cref="FunctionBody"/> to add to</param>
/// <param name="name">Name of variant</param>
/// <param name="callback"><see cref="Action{Accessor}"/> that gets called for working with the <see cref="Accessor"/></param>
/// <returns>Chained <see cref="FunctionBody"/> to keep building on</returns>
public static FunctionBody Access(this FunctionBody functionBody, string name, Action<Accessor> callback)
{
var accessor = new Accessor(name);
functionBody.AddChild(accessor);
callback(accessor);
return functionBody;
}
示例8: FunctionCall
/// <summary>
/// Specify a <see cref="FunctionCall"/> for the <see cref="Scope"/>
/// </summary>
/// <param name="scope"><see cref="Scope"/> to specify for</param>
/// <param name="callback"><see cref="Action{FunctionCall}"/> that gets called for setting up the <see cref="FunctionCall"/></param>
/// <returns>Chained <see cref="Scope"/> to keep building on</returns>
public static Scope FunctionCall(this Scope scope, Action<FunctionCall> callback)
{
var functionCall = new FunctionCall();
scope.AddChild(functionCall);
callback(functionCall);
return scope;
}
示例9: AddChildTypeDeclaration
public static void AddChildTypeDeclaration(this AstNode tree, TypeDeclaration newClass,
NamespaceDeclaration parentNamespace = null)
{
if (null != parentNamespace)
{
var newNamespaceNode = new NamespaceDeclaration(
parentNamespace.Name);
newNamespaceNode.AddMember(newClass);
tree.AddChild(newNamespaceNode, SyntaxTree.MemberRole);
}
else
{
tree.AddChild(newClass, Roles.TypeMemberRole);
}
}
示例10: AddStatement
public static void AddStatement(this BlockStatement block, Statement statement)
{
if (block == null)
throw new ArgumentNullException("block");
if (statement == null)
throw new ArgumentNullException("statement");
block.AddChild(statement);
statement.Parent = block;
}
示例11: AddChild
/// <summary>
/// Add a child validation item.
/// </summary>
/// <param name="item"></param>
/// <param name="xpath"></param>
/// <param name="children"></param>
/// <param name="relative">Is the xpath relative to the child xpath</param>
/// <returns></returns>
public static XPathValidator AddChild(this XPathValidator item, string xpath, IList<IXPathValidator> children = null, bool relative = false)
{
if (relative)
{
xpath = item.XPath + "/" + xpath;
}
var child = new XPathValidator { XPath = xpath, Children = children };
return item.AddChild(child);
}
示例12: AddDescription
public static SKLabelNode AddDescription(this SKNode self, string description, PointF position)
{
SKLabelNode label = new SKLabelNode ("Helvetica") {
Text = description,
FontSize = 18,
Position = position
};
self.AddChild (label);
return label;
}
示例13: WrapWithHtmlTag
public static void WrapWithHtmlTag(this HtmlNode node)
{
var pTag = new HtmlTagNode("p");
foreach (var child in node.Children)
pTag.AddChild(child);
var htmlTag = new HtmlTagNode("html");
htmlTag.AddChild(pTag);
node.Children.Clear();
node.AddChild(htmlTag);
}
示例14: AddMetaDataEntry
public static void AddMetaDataEntry(this XmlData projectMetaData,
ContentMetaData contentEntry)
{
var newEntry = new XmlData(typeof(ContentMetaData).Name);
AddBasicMetaDataValues(newEntry, contentEntry);
if (contentEntry.Language != null)
newEntry.AddAttribute("Language", contentEntry.Language);
if (contentEntry.PlatformFileId != 0)
newEntry.AddAttribute("PlatformFileId", contentEntry.PlatformFileId);
foreach (KeyValuePair<string, string> valuePair in contentEntry.Values)
newEntry.AddAttribute(valuePair.Key, valuePair.Value);
projectMetaData.AddChild(newEntry);
}
示例15: add_Type
/*public static TypeDeclaration add_Type(this CompilationUnit compilationUnit, IReturnType iReturnType)
{
}*/
public static TypeDeclaration add_Type(this CompilationUnit compilationUnit, IClass iClass)
{
try
{
if (iClass.Namespace.valid())
{
var namespaceDeclaration = compilationUnit.add_Namespace(iClass.Namespace);
return namespaceDeclaration.add_Type(iClass);
}
// move to method IClass.typeDeclaration();
var typeName = iClass.Name;
var newType = compilationUnit.type(typeName); // check if already exists and if it does return it
if (newType != null)
return newType;
const Modifiers modifiers = Modifiers.None | Modifiers.Public;
newType = new TypeDeclaration(modifiers, new List<AttributeSection>())
{
Name = typeName
};
foreach (var baseType in iClass.BaseTypes)
{
newType.BaseTypes.Add(new TypeReference(baseType.FullyQualifiedName));
}
compilationUnit.AddChild(newType);
return newType;
// return newType;
/*var classFinder = new ClassFinder(iClass,0,0);
var typeReference = (TypeReference)ICSharpCode.SharpDevelop.Dom.Refactoring.CodeGenerator.ConvertType(iClass.DefaultReturnType, classFinder);
if (typeReference != null)
{
compilationUnit.AddChild(typeReference);
return typeReference;
}*/
//return compilationUnit.add_Type_(iClass.Namespace, iClass.Name);
}
catch (Exception ex)
{
ex.log("in TypeReference.add_Type");
}
return compilationUnit.add_Type(iClass.Namespace, iClass.Name);
}