/// <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; }
/// <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; }
public static void setFirstChild( this ITree tree, ITree child ) { if ( tree.ChildCount == 0 ) tree.AddChild( child ); else tree.SetChild( 0, child ); }
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; }
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; }
// 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); }
/// <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; }
/// <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; }
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); } }
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; }
/// <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); }
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; }
public static DomElement AddChild(this DomElement elem, string elementName, Decorate d) { var newchild = elem.OwnerDocument.CreateElement(elementName); elem.AddChild(newchild); if (d != null) { d(newchild); } return newchild; }
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); }
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); }
/*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); }
public static TypeDeclaration add_Type(this CompilationUnit compilationUnit, string typeName) { const Modifiers modifiers = Modifiers.None | Modifiers.Public; var newType = new TypeDeclaration(modifiers, new List<AttributeSection>()); newType.Name = typeName; compilationUnit.AddChild(newType); return newType; }
public static TypeDeclaration add_Ctor(this TypeDeclaration typeDeclaration, ConstructorDeclaration constructorDeclaration) { if (typeDeclaration != null && constructorDeclaration != null) typeDeclaration.AddChild(constructorDeclaration); return typeDeclaration; }
public static TypeDeclaration add_Method(this TypeDeclaration typeDeclaration, MethodDeclaration methodDeclaration) { if (typeDeclaration != null && methodDeclaration != null) typeDeclaration.AddChild(methodDeclaration); return typeDeclaration; }
/// <summary> /// Creates and adds a new field. /// </summary> /// <param name="me">component descriptor to host the new field</param> /// <param name="type">type descriptor of the new field</param> /// <param name="name">name of the new field</param> /// <returns>the descriptor of the new field</returns> public static DOMFieldBuilder CreateField(this IComponentDescriptor me, TypeDescriptor type, string name) { Contract.Requires<ArgumentNullException>(me != null); Contract.Requires<ArgumentNullException>(type != null); Contract.Requires<ArgumentNullException>(name != null); var fb = new DOMFieldBuilder(type); me.AddChild(fb, name); return fb; }
/// <summary> /// Assign a key within an <see cref="ObjectLiteral"/> /// </summary> /// <param name="objectLiteral"><see cref="ObjectLiteral"/> to assign to</param> /// <param name="name">Name of key</param> /// <returns><see cref="KeyAssignment"/> to build</returns> public static KeyAssignment Assign(this ObjectLiteral objectLiteral, string name) { var keyAssignment = new KeyAssignment(name); objectLiteral.AddChild(keyAssignment); return keyAssignment; }
/// <summary> /// Allows a custom pushpin to be added to a MapLayer /// </summary> /// <param name="layer">MapLayer to add custom pushpin to</param> /// <param name="pushpin">Custom Pushpin to add to layer</param> public static void AddChild(this MapLayer layer, CustomPushpin pushpin) { layer.AddChild(pushpin, pushpin.Location); }
/// <summary> /// Creates and adds a new symbolic process (i.e. without specification of behavior). /// </summary> /// <param name="me">component descriptor to host the new process</param> /// <param name="kind">kind of process</param> /// <param name="name">name of the new process</param> /// <param name="sensitivity">sensitivity list of the new process</param> /// <returns>the descriptor of the new process</returns> public static ProcessDescriptor CreateProcess(this IComponentDescriptor me, Process.EProcessKind kind, string name, params ISignalOrPortDescriptor[] sensitivity) { Contract.Requires<ArgumentNullException>(me != null); Contract.Requires<ArgumentNullException>(name != null); Contract.Requires<ArgumentNullException>(sensitivity != null); ProcessDescriptor pd = new ProcessDescriptor(name) { Kind = kind, Sensitivity = sensitivity }; me.AddChild(pd, pd.Name); return pd; }
public static Transform FindOrAddChild(this Transform parent, string childName) { Transform child = parent.FindChild(childName); if (child == null) child = parent.AddChild(childName); return child; }
/// <summary> /// Creates and adds a new field. /// </summary> /// <param name="me">component descriptor to host the new field</param> /// <param name="type">type descriptor of the new field</param> /// <param name="initialValue">initial field value</param> /// <param name="name">name of the new field</param> /// <returns>the descriptor of the new field</returns> public static DOMFieldBuilder CreateField(this IComponentDescriptor me, TypeDescriptor type, object initialValue, string name) { Contract.Requires<ArgumentNullException>(me != null); Contract.Requires<ArgumentNullException>(type != null); Contract.Requires<ArgumentNullException>(name != null); Contract.Requires<ArgumentException>(initialValue == null || TypeDescriptor.GetTypeOf(initialValue).Equals(type), "Field type must match type of initial value"); var fb = new DOMFieldBuilder(type, initialValue); me.AddChild(fb, name); return fb; }
/// <summary> /// Add a scope - such as "self", typically used together with an <see cref="Assignment"/> /// </summary> /// <param name="functionBody"><see cref="FunctionBody"/> to add to</param> /// <param name="name">Name of the scope, e.g. "self"</param> /// <param name="callback"><see cref="Action{Scope}"/> that gets called for working with the <see cref="Scope"/></param> /// <returns>Chained <see cref="FunctionBody"/> to keep building on</returns> public static FunctionBody Scope(this FunctionBody functionBody, string name, Action<Scope> callback) { var scope = new Scope(name); functionBody.AddChild(scope); callback(scope); return functionBody; }
// should be merged with the one using CompilationUnit public static TypeDeclaration add_Type(this NamespaceDeclaration namespaceDeclaration, string typeName) { 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; namespaceDeclaration.AddChild(newType); return newType; }
/// <summary> /// Add a variant to a <see cref="FunctionBody"/> /// </summary> /// <param name="functionBody"><see cref="FunctionBody"/> to add to</param> /// <param name="name">Name of variant</param> /// <param name="callback"><see cref="Action{VariantAssignment}"/> that gets called for working with the <see cref="VariantAssignment"/></param> /// <returns>Chained <see cref="FunctionBody"/> to keep building on</returns> public static FunctionBody Variant(this FunctionBody functionBody, string name, Action<VariantAssignment> callback) { var variantAssignment = new VariantAssignment(name); functionBody.AddChild(variantAssignment); callback(variantAssignment); return functionBody; }
/// <summary> /// Add a return statement /// </summary> /// <param name="functionBody"><see cref="FunctionBody"/> to add to</param> /// <param name="returnValue"><see cref="LanguageElement"/> representing the returnvalue</param> /// <returns>Chained <see cref="FunctionBody"/> to keep building on</returns> public static FunctionBody Return(this FunctionBody functionBody, LanguageElement returnValue) { var returnStatement = new Return(returnValue); functionBody.AddChild(returnStatement); return functionBody; }
/// <summary> /// Creates and adds a new port. /// </summary> /// <param name="me">component descriptor to host the new port</param> /// <param name="name">name of new port</param> /// <param name="dir">data-flow direction</param> /// <param name="usage">usage hint</param> /// <param name="dataType">type descriptor of exchanged data</param> /// <returns>the descriptor of the newly created port</returns> public static PortBuilder CreatePort(this IComponentDescriptor me, string name, EFlowDirection dir, EPortUsage usage, TypeDescriptor dataType) { Contract.Requires<ArgumentNullException>(me != null); Contract.Requires<ArgumentNullException>(name != null); Contract.Requires<ArgumentNullException>(dataType != null); PortBuilder result = new PortBuilder(dir, usage, null, dataType); me.AddChild(result, name); return result; }