You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

using System;
using System.Collections.Generic;
using System.Reflection;
namespace Apewer.Web
{
internal sealed class ApiApplication
{
internal Dictionary<string, ApiFunction> Functions = null;
internal List<ApiFunction> Items = null;
internal Type Type;
internal string Module;
// 主特性和主要属性。
internal ApiAttribute Attribute;
internal string Name;
internal string Lower;
internal string Caption;
internal string Description;
// 附加特性。
internal bool Independent;
internal bool Hidden;
internal ApiFunction Get(string name)
{
if (string.IsNullOrEmpty(name)) return null;
var lower = name.ToLower();
ApiFunction func;
var exist = Functions.TryGetValue(lower, out func);
return func;
}
internal Json ToJson(ApiOptions options)
{
if (Hidden) return null;
var json = Json.NewObject();
json.SetProperty("name", Name);
if (!string.IsNullOrEmpty(Caption)) json.SetProperty("caption", Caption);
if (!string.IsNullOrEmpty(Description)) json.SetProperty("description", Description);
if (options.WithTypeName) json.SetProperty("type", Type.FullName);
if (options.WithModuleName) json.SetProperty("mudule", Module);
return json;
}
}
}