public string get_Prototype(int Flags)
 {
     return(_event.get_Prototype(Flags));
 }
Exemple #2
0
        /// <summary>
        /// Returns a CodeElement's documentation comment if it has
        /// one, otherwise returns relevant information from the prototype.
        /// </summary>
        /// <param name="element">A CodeElement object.</param>
        /// <returns>A string representing the element's definition.</returns>
        public static string GetPrototypeFromCMElement(CodeElement element)
        {
            System.Xml.XmlDocument docComment = new System.Xml.XmlDocument();

            try
            {
                if (element == null)
                {
                    throw new ArgumentNullException("element");
                }

                switch (element.Kind)
                {
                case vsCMElement.vsCMElementFunction:
                    CodeFunction codeFunction = ((CodeFunction)element);
                    if (!string.IsNullOrEmpty(codeFunction.DocComment))
                    {
                        docComment.LoadXml(String.Format("<docComment>{0}</docComment>", codeFunction.DocComment));
                        System.Xml.XmlNode node = docComment.SelectSingleNode("/docComment/summary");
                        if (node != null)
                        {
                            return(String.Format("{0}\n{1}", node.InnerText.Trim(),
                                                 codeFunction.get_Prototype(
                                                     (int)vsCMPrototype.vsCMPrototypeType | (int)vsCMPrototype.vsCMPrototypeParamNames | (int)vsCMPrototype.vsCMPrototypeParamTypes)));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(codeFunction.get_Prototype((int)vsCMPrototype.vsCMPrototypeType |
                                                          (int)vsCMPrototype.vsCMPrototypeParamNames |
                                                          (int)vsCMPrototype.vsCMPrototypeParamTypes));
                    }

                case vsCMElement.vsCMElementProperty:
                    CodeProperty codeProperty = ((CodeProperty)element);
                    if (!string.IsNullOrEmpty(codeProperty.DocComment))
                    {
                        docComment.LoadXml(String.Format("<docComment>{0}</docComment>", codeProperty.DocComment));
                        System.Xml.XmlNode node = docComment.SelectSingleNode("/docComment/summary");
                        if (node != null)
                        {
                            return(String.Format("{0}\n{1}", node.InnerText.Trim(),
                                                 codeProperty.get_Prototype((int)vsCMPrototype.vsCMPrototypeType |
                                                                            (int)vsCMPrototype.vsCMPrototypeParamNames |
                                                                            (int)vsCMPrototype.vsCMPrototypeParamTypes)));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(codeProperty.get_Prototype((int)vsCMPrototype.vsCMPrototypeType |
                                                          (int)vsCMPrototype.vsCMPrototypeParamNames |
                                                          (int)vsCMPrototype.vsCMPrototypeParamTypes));
                    }

                case vsCMElement.vsCMElementVariable:
                    CodeVariable codeVariable = ((CodeVariable)element);
                    return(codeVariable.get_Prototype((int)vsCMPrototype.vsCMPrototypeType));

                case vsCMElement.vsCMElementEvent:
                    CodeEvent codeEvent = ((CodeEvent)element);
                    if (!string.IsNullOrEmpty(codeEvent.DocComment))
                    {
                        docComment.LoadXml(String.Format("<docComment>{0}</docComment>", codeEvent.DocComment));
                        System.Xml.XmlNode node = docComment.SelectSingleNode("/docComment/summary");
                        if (node != null)
                        {
                            return(String.Format("{0}\n{1}", node.InnerText.Trim(),
                                                 codeEvent.get_Prototype((int)vsCMPrototype.vsCMPrototypeType |
                                                                         (int)vsCMPrototype.vsCMPrototypeParamNames |
                                                                         (int)vsCMPrototype.vsCMPrototypeParamTypes)));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(codeEvent.get_Prototype((int)vsCMPrototype.vsCMPrototypeType |
                                                       (int)vsCMPrototype.vsCMPrototypeParamNames |
                                                       (int)vsCMPrototype.vsCMPrototypeParamTypes));
                    }

                case vsCMElement.vsCMElementDelegate:
                    CodeDelegate codeDelegate = ((CodeDelegate)element);
                    if (!string.IsNullOrEmpty(codeDelegate.DocComment))
                    {
                        docComment.LoadXml(String.Format("<docComment>{0}</docComment>", codeDelegate.DocComment));
                        System.Xml.XmlNode node = docComment.SelectSingleNode("/docComment/summary");
                        if (node != null)
                        {
                            return(String.Format("{0}\n{1}", node.InnerText.Trim(),
                                                 codeDelegate.get_Prototype((int)vsCMPrototype.vsCMPrototypeType |
                                                                            (int)vsCMPrototype.vsCMPrototypeParamNames |
                                                                            (int)vsCMPrototype.vsCMPrototypeParamTypes)));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(codeDelegate.get_Prototype((int)vsCMPrototype.vsCMPrototypeType |
                                                          (int)vsCMPrototype.vsCMPrototypeParamNames |
                                                          (int)vsCMPrototype.vsCMPrototypeParamTypes));
                    }

                case vsCMElement.vsCMElementClass:
                    CodeClass codeClass = ((CodeClass)element);
                    if (!string.IsNullOrEmpty(codeClass.DocComment))
                    {
                        docComment.LoadXml(String.Format("<docComment>{0}</docComment>", codeClass.DocComment));
                        System.Xml.XmlNode node = docComment.SelectSingleNode("/docComment/summary");
                        if (node != null)
                        {
                            return(node.InnerText.Trim());
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(string.Empty);
                    }

                //nemerle variant type and variant options
                case vsCMElement.vsCMElementUnion:
                    CodeClass codeVariant = ((CodeClass)element);
                    if (!string.IsNullOrEmpty(codeVariant.DocComment))
                    {
                        docComment.LoadXml(String.Format("<docComment>{0}</docComment>", codeVariant.DocComment));
                        System.Xml.XmlNode node = docComment.SelectSingleNode("/docComment/summary");
                        if (node != null)
                        {
                            return(node.InnerText.Trim());
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(string.Empty);
                    }


                case vsCMElement.vsCMElementStruct:
                    CodeStruct codeStruct = ((CodeStruct)element);
                    if (!string.IsNullOrEmpty(codeStruct.DocComment))
                    {
                        docComment.LoadXml(String.Format("<docComment>{0}</docComment>", codeStruct.DocComment));
                        System.Xml.XmlNode node = docComment.SelectSingleNode("/docComment/summary");
                        if (node != null)
                        {
                            return(node.InnerText.Trim());
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(string.Empty);
                    }

                case vsCMElement.vsCMElementInterface:
                    CodeInterface codeInterface = ((CodeInterface)element);
                    if (!string.IsNullOrEmpty(codeInterface.DocComment))
                    {
                        docComment.LoadXml(String.Format("<docComment>{0}</docComment>", codeInterface.DocComment));
                        System.Xml.XmlNode node = docComment.SelectSingleNode("/docComment/summary");
                        if (node != null)
                        {
                            return(node.InnerText.Trim());
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(string.Empty);
                    }

                default:
                    return(string.Empty);
                }
            }
            catch
            {
                return(string.Empty);
            }
        }