Ejemplo n.º 1
0
        internal static void AddXmlComment(CodeTypeMember member, string documentation, ImportOptions options)
        {
            IEnumerable <string> commentLines = XmlCommentsUtils.ParseAndReformatComment(documentation, options.Format, options.WrapLongLines);

            CodeCommentStatement[] commentStatements = commentLines.Select(s => new CodeCommentStatement(s, true)).ToArray();
            member.Comments.AddRange(commentStatements);
        }
Ejemplo n.º 2
0
        internal static void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context, XmlCommentFormat format)
        {
            InitXsdDataContractExporter(exporter, format);

            XmlDocument commentsDoc = XmlCommentsUtils.LoadXmlComments(context.Contract.ContractType, true);

            if (commentsDoc == null)
            {
                return;
            }

            string comment = XmlCommentsUtils.GetFormattedComment(commentsDoc, context.Contract.ContractType, format);

            if (comment != null)
            {
                context.WsdlPortType.Documentation = comment;
            }

            foreach (Operation op in context.WsdlPortType.Operations)
            {
                OperationDescription opDescription = context.GetOperationDescription(op);
                MemberInfo           mi            = opDescription.SyncMethod;
                if (mi == null)
                {
                    mi = opDescription.BeginMethod;
                }
                comment = XmlCommentsUtils.GetFormattedComment(commentsDoc, mi, format);
                if (comment != null)
                {
                    op.Documentation = comment;
                }
            }
        }
Ejemplo n.º 3
0
 internal static void ExportEndpoint(WsdlExporter exporter, XmlCommentFormat format)
 {
     foreach (XmlSchema schema in exporter.GeneratedXmlSchemas.Schemas())
     {
         foreach (XmlSchemaObject schemaObj in schema.Items)
         {
             ConvertObjectAnnotation(schemaObj);
         }
     }
     XmlCommentsUtils.ClearCache();
 }
Ejemplo n.º 4
0
        object IDataContractSurrogate.GetCustomDataToExport(MemberInfo memberInfo, Type dataContractType)
        {
            XmlDocument commentsDoc = XmlCommentsUtils.LoadXmlComments(memberInfo.DeclaringType);

            if (commentsDoc != null)
            {
                string comment = XmlCommentsUtils.GetFormattedComment(commentsDoc, memberInfo, format);
                if (comment != null)
                {
                    return(new Annotation(comment));
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        object IDataContractSurrogate.GetCustomDataToExport(Type clrType, Type dataContractType)
        {
            if (dataContractType.IsGenericType && dataContractType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                dataContractType = dataContractType.GetGenericArguments()[0];
            }
            XmlDocument commentsDoc = XmlCommentsUtils.LoadXmlComments(dataContractType);

            if (commentsDoc != null)
            {
                if (dataContractType.IsEnum)
                {
                    EnumAnnotation annotation = new EnumAnnotation();
                    string         comment    = XmlCommentsUtils.GetFormattedComment(commentsDoc, dataContractType, format);
                    if (comment != null)
                    {
                        annotation.EnumText = comment;
                    }
                    Dictionary <string, MemberInfo> enumMembers = ReflectionUtils.GetEnumMembers(dataContractType);
                    foreach (KeyValuePair <string, MemberInfo> member in enumMembers)
                    {
                        comment = XmlCommentsUtils.GetFormattedComment(commentsDoc, member.Value, format);
                        if (comment != null)
                        {
                            annotation.Members.Add(member.Key, comment);
                        }
                    }
                    if (annotation.EnumText != null || annotation.Members.Count > 0)
                    {
                        return(annotation);
                    }
                }
                else
                {
                    string comment = XmlCommentsUtils.GetFormattedComment(commentsDoc, dataContractType, format);
                    if (comment != null)
                    {
                        return(new Annotation(comment));
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
        internal static void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context, XmlCommentFormat format, string implementationClass)
        {
            InitXsdDataContractExporter(exporter, format);

            XmlDocument commentsDoc = XmlCommentsUtils.LoadXmlComments(context.Contract.ContractType, true);

            if (commentsDoc == null)
            {
                return;
            }

            //See if we're being asked to get the comments from a specific implementation class
            //otherwise we can just use the interface contract itself
            Type type = context.Contract.ContractType;

            if (!String.IsNullOrEmpty(implementationClass))
            {
                Assembly assembly = type.Assembly;
                Type     implType = assembly.GetType(implementationClass, false, true);
                if (implType != null)
                {
                    type = implType;
                }
            }

            string comment = XmlCommentsUtils.GetFormattedComment(commentsDoc, type, format);

            if (comment != null)
            {
                // Set the doc element; if this isn't done first, there is no XmlElement in the
                // DocumentElement property.
                context.WsdlPortType.Documentation = String.Empty;

                //Now add the XML comments
                XmlDocument xmlDoc           = context.WsdlPortType.DocumentationElement.OwnerDocument;
                XmlElement  xmlDocumentation = xmlDoc.CreateElement("comments");
                xmlDocumentation.InnerXml = comment;
                context.WsdlPortType.DocumentationElement.AppendChild(xmlDocumentation);
            }

            foreach (Operation op in context.WsdlPortType.Operations)
            {
                OperationDescription opDescription = context.GetOperationDescription(op);
                MemberInfo           mi            = opDescription.SyncMethod;
                if (mi == null)
                {
                    mi = opDescription.BeginMethod;
                }

                //See if we're being asked to get the comments from a specific implementation class
                //otherwise we can just use the interface contract itself
                if (!String.IsNullOrEmpty(implementationClass))
                {
                    Assembly assembly = type.Assembly;
                    Type     implType = assembly.GetType(implementationClass, false, true);
                    if (implType != null)
                    {
                        MethodInfo[] implMethods = implType.GetMethods();
                        foreach (MethodInfo implMethod in implMethods)
                        {
                            if (implMethod.Name == mi.Name)
                            {
                                mi = implMethod;
                                break;
                            }
                        }
                    }
                }

                comment = XmlCommentsUtils.GetFormattedComment(commentsDoc, mi, format);
                if (comment != null)
                {
                    // Set the doc element; if this isn't done first, there is no XmlElement in the
                    // DocumentElement property.
                    op.Documentation = String.Empty;

                    //Now add the XML comments
                    XmlDocument xmlDoc           = op.DocumentationElement.OwnerDocument;
                    XmlElement  xmlDocumentation = xmlDoc.CreateElement("comments");
                    xmlDocumentation.InnerXml = comment;
                    op.DocumentationElement.AppendChild(xmlDocumentation);
                }
            }
        }