using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WindreamHub.Legacy.Client.Routes { public static class RouteExtensions { public static string GetRouteName(this object service) { // Get the full class name including namespace string fullClassName = service.GetType().FullName; // Extract the class name part by getting the substring after the last dot (.) string className = fullClassName.Substring(fullClassName.LastIndexOf('.') + 1); // Remove the "RouteService" part and return the remainder string suffix = "RouteService"; if (className.EndsWith(suffix)) { // Remove the "RouteService" part string prefix = className.Substring(0, className.Length - suffix.Length); return prefix; } else { throw new ArgumentException("Class name does not follow the expected format."); } } } }