Ejemplo n.º 1
0
        public static ConstructorDef FromConstructorInfo(ClassDef parentClass, ConstructorInfo info, XMLDocs doc = null)
        {
            var def = new ConstructorDef(parentClass);

            def.ConstructorInfo = info;

            // Określanie poziomu dostępu
            if (info.IsPublic)
            {
                def.AccessType = AccessType.PUBLIC;
            }
            else if (info.IsFamily)
            {
                def.AccessType = AccessType.PROTECTED;
            }
            else if (info.IsPrivate)
            {
                def.AccessType = AccessType.PRIVATE;
            }
            else
            {
                def.AccessType = AccessType.INNER;
            }


            // Parametry
            var parameters = info.GetParameters();

            foreach (var param in parameters)
            {
                def.AddParam(ParamDef.FromParamInfo(param));
            }

            // Dopisywanie dokumentacji
            if (doc != null)
            {
                XmlNode docsNode = doc.GetDocumentation(def);

                if (docsNode != null)
                {
                    XmlNode current;
                    for (int i = 0; i < docsNode.ChildNodes.Count; i++)
                    {
                        current = docsNode.ChildNodes[i];

                        switch (current.Name)
                        {
                        case "summary":
                            def.Summary = current.InnerText.Replace("\n\r            ", "\n").Replace("\r\n            ", "\n").Replace("\n            ", "\n");
                            def.Summary = def.Summary.Substring(1, def.Summary.Length - 2);
                            def.Summary.Replace("\n", "\n\t");
                            break;

                        case "remarks":
                            def.Remarks = current.InnerText;
                            break;

                        case "param":
                            string name  = current.Attributes["name"].InnerText;
                            var    param = def.GetParam(name);
                            if (param != null)
                            {
                                param.Description = current.InnerText;
                            }
                            else
                            {
                                Console.WriteLine("Parameter not found: " + name);
                            }
                            break;

                        default:
                            Console.WriteLine("Unrecognized tag " + current.Name + " in class definition of " + def.ParentClass.TypeDef.FullName + ", method name " + def.Name);
                            break;
                        }
                    }
                }
            }

            return(def);
        }
Ejemplo n.º 2
0
 public void AddParam(ParamDef def)
 {
     Params.Add(def);
 }