/// <summary> /// Builds a WebService from from a Custom Web Service Plugin. /// </summary> /// <param name="webServiceType">The custom web service type.</param> /// <param name="attribute">The CustomWebServiceAttribute applied to the custom web service type. Uses CustomWebServiceAttribute.ServiceRoute or CustomWebServiceAttribute.Entity to determine the route.</param> /// <param name="factory">The WebServiceHostFactory, which is by default the Rhyous.WebFramework.Behaviors.RestWebServiceHostFactory.</param> /// <param name="routeCollection">The route collection to update. It is RouteTable.Routes static by default.</param> public static void BuildWebService(Type webServiceType, CustomWebServiceAttribute attribute, WebServiceHostFactory factory = null, RouteCollection routeCollection = null) { if (!string.IsNullOrWhiteSpace(attribute.ServiceRoute)) { BuildWebService(webServiceType, attribute.ServiceRoute, factory, routeCollection); } else if (attribute.Entity != null) { BuildWebService(webServiceType, $"{attribute.Entity.Name}Service.svc", factory, routeCollection); } else { throw new Exception("Either CustomWebServiceAttribute.ServiceRoute or CustomWebServiceAttribute.Entity must be set."); } }
public void ConsolidateByAttributeTests() { // Arrange var attribute = new CustomWebServiceAttribute { ServiceContract = typeof(Contract1) }; var c1 = ContractDescription.GetContract(typeof(Contract1)); var c2 = ContractDescription.GetContract(typeof(Contract2)); IDictionary <string, ContractDescription> contracts = new Dictionary <string, ContractDescription> { { typeof(Contract1).FullName, c1 }, { typeof(Contract2).FullName, c2 } }; // Act ContractConsolidator.ConsolidateByAttribute(attribute, contracts); //Assert Assert.AreEqual(typeof(Contract1).FullName, contracts.Keys.Single()); Assert.AreEqual(c1, contracts.Values.Single()); }