Exemplo n.º 1
0
        private OperationDoc(Type requestType)
        {
            this.Name = requestType.Name;

            var xmlDocument = FindXmlDocumentationFile(requestType);

            Request = new DtoDoc
                      	{
                      		Name = requestType.Name,
                      		XmlDocumentation = xmlDocument != null ? ExtractMemberElement(xmlDocument, "T", requestType.FullName) : null,
                      	};

            this.XmlDocumentation = Request.XmlDocumentation;

            PopulateProperties(Request, requestType, xmlDocument);

            Responses = new List<DtoDoc>();

            // Support for multiple response types may appear in the future.
            // For now, append suffix to find the single response DTO.
            var responseType = requestType.Assembly.GetType(requestType.FullName + ResponseSuffix, false);

            if (responseType != null)
            {
                var response = new DtoDoc
                               	{
                               		Name = responseType.Name,
                               		XmlDocumentation =
                                        xmlDocument != null ? ExtractMemberElement(xmlDocument, "T", responseType.FullName) : null,
                               	};

                PopulateProperties(response, responseType, xmlDocument);

                Responses.Add(response);
            }
        }
Exemplo n.º 2
0
        private void PopulateProperties(DtoDoc dto, Type requestType, XDocument xmlDocument)
        {
            foreach (var propertyInfo in requestType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                var propertyDoc = new PropertyDoc
                                  	{
                                  		Name = propertyInfo.Name,
                                        PropertyType = propertyInfo.PropertyType.Name,
                                  		XmlDocumentation =
                                  			xmlDocument != null ? ExtractMemberElement(xmlDocument, "P", requestType.FullName + "." + propertyInfo.Name) : null
                                  	};

                dto.Properties.Add(propertyDoc);
            }

            dto.Properties.Sort((x, y) => x.Name.CompareTo(y.Name));
        }