예제 #1
0
        public static WebId GetWebId(this IProvideUrl url,
                                     Type controllerType,
                                     string urnNamespace,
                                     string routeName = "DefaultApi")
        {
            var controllerName =
                controllerType.Name.TrimEnd("Controller",
                                            (trimmedName) => trimmedName, (originalName) => originalName);

            if (controllerType.ContainsCustomAttribute <FunctionViewControllerAttribute>())
            {
                var fvcAttr = controllerType.GetCustomAttribute <FunctionViewControllerAttribute>();
                if (fvcAttr.Route.HasBlackSpace())
                {
                    controllerName = fvcAttr.Route;
                }
            }

            var location = url.Link(routeName, controllerName);

            return(new WebId
            {
                Key = string.Empty,
                UUID = Guid.Empty,
                URN = controllerType.GetUrn(urnNamespace),
                Source = location,
            });
        }
예제 #2
0
        public static Uri GetLocation <TController>(this IProvideUrl url,
                                                    string action,
                                                    string routeName = "DefaultApi")
        {
            var controllerName =
                typeof(TController).Name.TrimEnd("Controller",
                                                 (trimmedName) => trimmedName, (originalName) => originalName);
            var location = url.Link(routeName, controllerName: controllerName, action: action);

            return(location);
        }
예제 #3
0
        public static Uri GetLocation(this IProvideUrl url, Type controllerType, Guid id,
                                      string routeName = "DefaultApi")
        {
            if (String.IsNullOrWhiteSpace(routeName))
            {
                routeName = "DefaultApi";
            }

            var controllerName =
                controllerType.Name.TrimEnd("Controller",
                                            (trimmedName) => trimmedName, (originalName) => originalName);
            var location = url.Link(routeName, controllerName: controllerName, id: id.ToString());

            return(location);
        }
예제 #4
0
        public static Uri GetLocation(this IProvideUrl url, Type controllerType,
                                      string routeName = default)
        {
            if (routeName.IsNullOrWhiteSpace())
            {
                routeName = controllerType.GetCustomAttribute <FunctionViewControllerAttribute, string>(
                    (attr) => attr.Namespace,
                    () => "api");
            }

            var controllerName = controllerType.GetCustomAttribute <FunctionViewControllerAttribute, string>(
                (attr) => attr.Route,
                () => controllerType.Name
                .TrimEnd("Controller",
                         (trimmedName) => trimmedName,
                         (originalName) => originalName)
                .ToLower());

            var location = url.Link(routeName, controllerName: controllerName);

            return(location);
        }