public RootResultModel Get() { var routes = _actionDescriptorCollectionProvider.ActionDescriptors.Items.Where( ad => ad.AttributeRouteInfo != null).Select(ad => new RouteModel { Name = ad.AttributeRouteInfo.Template, Method = ad.ActionConstraints?.OfType <HttpMethodActionConstraint>().FirstOrDefault()?.HttpMethods.First(), }).ToList(); var res = new RootResultModel { Routes = routes }; return(res); }
public dynamic Get() { //Config Dictionary <string, string> config = new Dictionary <string, string>(); foreach (PropertyInfo prop in typeof(Config).GetProperties()) { string name = prop.Name; try { string value = prop.GetValue(null).ToString(); config.Add(name, value); } catch (Exception ex) { Logger.Warning("Could not find config property value for root", new { name, ex }); } } //Routes var routes = _actionDescriptorCollectionProvider.ActionDescriptors.Items.Where( ad => ad.AttributeRouteInfo != null).Select(ad => new RouteModel { Name = ad.AttributeRouteInfo.Template, Method = ad.ActionConstraints?.OfType <HttpMethodActionConstraint>().FirstOrDefault()?.HttpMethods.First(), }).ToList(); var res = new RootResultModel { Config = config, Routes = routes }; return(res); }