/// <summary> /// Build the endpoint array /// </summary> /// <returns> /// The endpoint info array /// </returns> private static WebServiceInfo[] BuildEndpoints() { var endpointInfos = new WebServiceInfo[_types.Length]; for (int i = 0; i < _types.Length; i++) { endpointInfos[i] = GetEndpoint(_types[i]); if (endpointInfos[i] != null) { endpointInfos[i].SchemaPath = _schemas[i]; endpointInfos[i].Description = _names[i]; } } return endpointInfos; }
/// <summary> /// Gets the <see cref="WebServiceInfo"/> from the specified <paramref name="type"/> if it has the <see cref="WebServiceAttribute"/> /// </summary> /// <param name="type"> /// The type which should have the <see cref="WebServiceInfo"/> /// </param> /// <returns> /// the <see cref="WebServiceInfo"/> from the specified <paramref name="type"/> if it has the <see cref="WebServiceAttribute"/> ; otherwise null /// </returns> private static WebServiceInfo GetEndpoint(Type type) { var attributes = type.GetCustomAttributes(true); // ASMX var webServiceAttribute = attributes.OfType<WebServiceAttribute>().FirstOrDefault(); if (webServiceAttribute != null) { var info = new WebServiceInfo { Name = type.Name + ".asmx", Namespace = webServiceAttribute.Namespace }; return info; } // WCF var serviceContractAttribute = attributes.OfType<ServiceContractAttribute>().FirstOrDefault(); if (serviceContractAttribute != null) { return new WebServiceInfo { Name = serviceContractAttribute.Name, Namespace = serviceContractAttribute.Namespace }; } return null; }