public ContentControllerMetaData(Type controllerType, string actionName = "Index") { ActionName = actionName; ControllerType = controllerType; ControllerName = controllerType.Name; // remove "Controller" from class name if (ControllerName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase)) { ControllerName = ControllerName.Substring(0, ControllerName.Length - "Controller".Length); } }
public ResourceInfo( AutumnDataSettings dataSettings, EntityInfo entityInfo, string defaultApiVersion, IReadOnlyDictionary <HttpMethod, Type> proxyRequestTypes, ResourceAttribute resourceAttribute) { EntityInfo = entityInfo; ProxyRequestTypes = proxyRequestTypes ?? throw new ArgumentNullException(nameof(proxyRequestTypes)); ApiVersion = Regex.Match(resourceAttribute.Version ?? string.Empty, "v[0-9]+", RegexOptions.IgnoreCase).Success ? resourceAttribute.Version : defaultApiVersion; Name = resourceAttribute.Name ?? entityInfo.EntityType.Name; if (dataSettings.Parent.NamingStrategy != null) { ControllerName = dataSettings.Parent.NamingStrategy.GetPropertyName(Name, false); } if (dataSettings.PluralizeController && !ControllerName.EndsWith("s")) { ControllerName = string.Concat(ControllerName, "s"); } var ignoreOperations = new List <HttpMethod>(); if (!resourceAttribute.Insertable) { ignoreOperations.Add(HttpMethod.Post); } if (!resourceAttribute.Updatable) { ignoreOperations.Add(HttpMethod.Put); } if (!resourceAttribute.Deletable) { ignoreOperations.Add(HttpMethod.Delete); } IgnoreOperations = new ReadOnlyCollection <HttpMethod>(ignoreOperations); }