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; } } }
public void ImportContract(WsdlImporter importer, WsdlContractConversionContext context) { foreach (Operation operation in context.WsdlPortType.Operations) { var operationDescription = context.GetOperationDescription(operation); operationDescription.OperationBehaviors.Add(this); } }
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); } } }