//============================================================ // <T>生成节点时,将此对象生成的节点连接到上层节点上</T> // @param node 需要连接的父节点。 // @return 本对象生成的节点。 //============================================================ public FXmlNode XMLMaker(FXmlNode node, FAsClassesIndexTable indextable) { FXmlNode classNode = new FXmlNode("Class"); classNode.Set("name", this.ClassName); if (this.AccessLevel != "") { classNode.Set("access_level", this.AccessLevel); } if (this.Annotates != null && Annotates.Count > 0) { ParserClassAnnotate(); if (Label.Trim() != "") { classNode.Set("label", Label.Trim()); } if (Description.Trim() != "") { classNode.Set("description", Description.Trim()); } } if (this.ParentName != string.Empty) { FFileNode type = new FFileNode(this.ParentName.Trim(), GetUsing(_strLine)); string parent = indextable.LookInMap(type, this._parentName.Trim()); classNode.Set("parent_class", parent); } FXmlNode classCode = new FXmlNode("Source"); classCode.Text = ClassCode; classNode.Push(classCode); node.Push(classNode); return(classNode); }
//============================================================ // <T>构造方法,有参数的构造。</T> // // @param nodeParent 字段节点的父节点(类节点) // @param indextable 类全名的索引表 // @param swPrint 用于打印警告结果的StreamWriter对象 // @param relative 当前解析文件所在的目录的路径 // @param file 当前解析的文件 //============================================================ public void XMLMaker(FXmlNode nodeParent, FAsClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative) { if (!IsFieldAnnoFine()) { PrintAnnoWarning(swPrint, file, relative); } FXmlNode nodeField = new FXmlNode("Field"); nodeField.Set("name", this.FieldName); nodeField.Set("full_name", this.FullName); nodeField.Set("access_level", this.AccessLevel); nodeField.Set("type", this.Type); FFileNode type = new FFileNode(this.Type, GetUsing(_strLines)); string fulltype = indextable.LookInMap(type, this.Type); if (Type != this.Type) { nodeField.Set("return_type", fulltype); } if (Description != "") { nodeField.Set("description", Description); } nodeParent.Push(nodeField); }
//============================================================ // <T>在Map表中查找类型对应的全名。</T> // // @param filenode 从文件中提取的待查找节点 // @param type 类型 // @return 查找到的全名 //============================================================ public string LookInMap(FFileNode filenode, string type) { string fullClassString = string.Empty; string key = filenode.ClassStr; if (_classesMap.Contains(key)) { FArray <string> value = _classesMap[key]; if (_classesMap.Contains(key) && value.Length == 1) { fullClassString = value[0].ToString(); if (fullClassString != string.Empty) { return(fullClassString + "." + type); } else { return(type); } } if (_classesMap.Contains(key) && value.Length > 1) { fullClassString = GetCorrectNamespace(filenode.Impotrs, value); if (fullClassString != string.Empty) { return(fullClassString + "." + type); } else { return(type); } } } return(type); }
//============================================================ // <T>构造方法,有参数的构造。</T> // // @param nodeParent 属性对象的生成的节点的父节点 // @param indextable 类全名的索引表 // @param swPrint 用于打印警告结果的StreamWriter对象 // @param relative 当前解析文件所在的目录的路径 // @param file 当前解析的文件 //============================================================ public void XMLMaker(FXmlNode nodeParent, FAsClassesIndexTable indextable, StreamWriter swPrint, FileInfo file, string relative) { if (!IsProAnnoFine()) { PrintAnnoWarning(swPrint, file, relative); } FXmlNode nodeProperty = new FXmlNode("Property"); nodeProperty.Set("name", this.PropertyName); nodeProperty.Set("type", this.PropertyType); FFileNode type = new FFileNode(this.PropertyType, GetUsing(_strLine)); string fulltype = indextable.LookInMap(type, this.PropertyType); if (fulltype != this.PropertyType) { nodeProperty.Set("full_name", fulltype); } if (this.AnnotateLable != "") { nodeProperty.Set("label", AnnotateLable); } if (this.AnnotateDescription != "") { nodeProperty.Set("description", AnnotateDescription); } nodeProperty.Set("access_level", AccessLevel); FXmlNode code = new FXmlNode("Source"); code.Text = this.PropertyCode; nodeProperty.Push(code); nodeParent.Push(nodeProperty); }
//============================================================ // <T>构造方法,有参数的构造。</T> // // @param indextable 类全名的索引表 // @param nodeMethod 参数节点所属的方法节点 // @param swPrint 用于打印警告结果的StreamWriter对象 // @param relative 当前解析文件所在的目录的路径 // @param file 当前解析的文件 //============================================================ public void ParserParameter(FAsClassesIndexTable indextable, FXmlNode nodeMethod, StreamWriter swPrint, FileInfo file, string relative) { string[] pa = _parameterStr.Split(':'); if (pa.Length == 2 && pa[0] != "" && pa[1] != "") { this._parameterName = pa[0].Trim(); this._parameterType = pa[1].Trim(); FFileNode type = new FFileNode(_parameterType, GetImport(_strLines)); this._fulltype = indextable.LookInMap(type, this._parameterType); XMLMaker(nodeMethod, swPrint, file, relative); } }
//============================================================ // <T>根据方法的返回值信息生成方法的返回值节点,并附加到方法节点上</T> // // @param nodeClass 需要连接上的父节点也是类节点 // @param indextable 类的全名(命名空间+类名)和类名的索引表 //============================================================ public void MethodReturnNode(FAsClassesIndexTable indextable, FXmlNode nodeMethod) { if (MethodType != "" && MethodType != "void") { FXmlNode methodTypeNode = new FXmlNode("Return"); methodTypeNode.Set("type", MethodType); FFileNode type = new FFileNode(MethodType, GetImport(_strLine)); string _fulltype = indextable.LookInMap(type, this.MethodType); if (_fulltype != MethodType) { methodTypeNode.Set("full_type", _fulltype); } nodeMethod.Push(methodTypeNode); } }
//============================================================ //<T>将类所继承的接口作为子节点连接到类的节点下面</T> // @param interface 接口的字符串组 // @param nodeClass 要连接的父节点,也就是类的节点 //============================================================ public void MakeInterfaceNode(FXmlNode nodeClass, FAsClassesIndexTable indextable) { if (InterfaceStrings == null || InterfaceStrings.Count < 1) { return; } FXmlNode nodeInterface = new FXmlNode("Inherts"); foreach (string str in InterfaceStrings) { FXmlNode inhert = new FXmlNode("Inhert"); string inhertstr = str.Trim(); FFileNode type = new FFileNode(inhertstr, GetUsing(_strLine)); inhertstr = indextable.LookInMap(type, inhertstr); inhert.Set("name", inhertstr.Trim()); nodeInterface.Push(inhert); } nodeClass.Push(nodeInterface); }