| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Abp.Web.Api.Modeling
- {
- [Serializable]
- public class ControllerApiDescriptionModel
- {
- public string Name { get; }
- public IDictionary<string, ActionApiDescriptionModel> Actions { get; }
- private ControllerApiDescriptionModel()
- {
- }
- public ControllerApiDescriptionModel(string name)
- {
- Name = name;
- Actions = new Dictionary<string, ActionApiDescriptionModel>();
- }
- public ActionApiDescriptionModel AddAction(ActionApiDescriptionModel action)
- {
- if (Actions.ContainsKey(action.Name))
- {
- throw new AbpException(
- $"Can not add more than one action with same name to the same controller. Controller: {Name}, Action: {action.Name}."
- );
- }
- return Actions[action.Name] = action;
- }
- public ControllerApiDescriptionModel CreateSubModel(string[] actions)
- {
- var subModel = new ControllerApiDescriptionModel(Name);
- foreach (var action in Actions.Values)
- {
- if (actions == null || actions.Contains(action.Name))
- {
- subModel.AddAction(action);
- }
- }
- return subModel;
- }
- }
- }
|