本文整理汇总了C#中Rests.RestRequestArgs类的典型用法代码示例。如果您正苦于以下问题:C# RestRequestArgs类的具体用法?C# RestRequestArgs怎么用?C# RestRequestArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RestRequestArgs类属于Rests命名空间,在下文中一共展示了RestRequestArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllPlayersKills
private object AllPlayersKills(RestRequestArgs args)
{
// Gets and checks if result (kills) are not empty
var AllKills = DB.GetAllKills();
if (AllKills == null)
{
return RestError("Empty database");
}
var Result = new RestObject();
foreach (var Row in AllKills)
{
Result.Add(Row.Key, Row.Value);
}
return Result;
}
示例2: Staff
public static RestObject Staff(RestRequestArgs args)
{
GroupManager groupmanager = new GroupManager(TShock.DB);
UserManager usermanager = new UserManager(TShock.DB);
List<string> groups = groupmanager.groups.FindAll(g => g.HasPermission("tshock.admin.kick")).Select(g => g.Name).ToList();
List<User> users = usermanager.GetUsers().Where(u => groups.Contains(u.Group)).ToList();
Dictionary<string, List<string>> RestGroups = new Dictionary<string, List<string>>();
for (int i = 0; i < groups.Count; i++)
RestGroups[groups[i]] = users.Where(u => u.Group == groups[i]).Select(u => u.Name).ToList();
return new RestObject()
{
{ "StaffList", RestGroups },
};
}
示例3: WhiteList
public static RestObject WhiteList(RestRequestArgs args)
{
string[] whitelist = new[] { "" };
try
{
using (StreamReader sr = new StreamReader(File.Open(Path.Combine(TShock.SavePath, "whitelist.txt"), FileMode.Open)))
{
whitelist = sr.ReadToEnd().Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
}
}
catch
{
whitelist = new[] { "Whitelist not found!" };
}
return new RestObject()
{
{ "WhiteList", whitelist}
};
}
示例4: getPlugins
private object getPlugins(RestRequestArgs args)
{
List<PluginList> pluginList = new List<PluginList>();
PluginList rec = null;
for (int i = 0; i < ServerApi.Plugins.Count; i++)
{
PluginContainer pc = ServerApi.Plugins.ElementAt(i);
Console.WriteLine(String.Format("{0} {1} {2} {3}", pc.Plugin.Name, pc.Plugin.Description, pc.Plugin.Author, pc.Plugin.Version), Color.LightSalmon);
rec = new PluginList(pc.Plugin.Name, pc.Plugin.Description, pc.Plugin.Author, pc.Plugin.Version.ToString());
pluginList.Add(rec);
}
/*
string ServerPluginsDirectoryPath = Path.Combine(Environment.CurrentDirectory, TerrariaApi.Server.ServerApi.PluginsPath);
string[] plugins = Directory.GetFiles(ServerPluginsDirectoryPath, "*.DLL");
Console.WriteLine(ServerPluginsDirectoryPath);
string excludeDLL = "bcrypt.net.dllhttpserver.dllmono.data.sqlite.dllmysql.data.dllmysql.web.dllnewtonsoft.json.dlltshockapi.dll";
string version;
string fileName;
Assembly asembly = null;
string pluginName = "";
Version APIversion = null;
CustomAttributeData VersionAttribute;
foreach (string path in plugins)
{
fileName = Path.GetFileName(path);
Console.WriteLine(path);
if (!excludeDLL.Contains(fileName.ToLower()))
{
asembly = Assembly.LoadFrom(path);
Console.Write(fileName);
try
{
version = asembly.FullName;
Console.WriteLine(version);
IEnumerable<TypeInfo> df = asembly.DefinedTypes;// CustomAttributes.First(Attr => Attr.AttributeType.Name == "ApiVersionAttribute");
VersionAttribute = asembly.GetType(df.First().ToString()).CustomAttributes.First(Attr => Attr.AttributeType.Name == "ApiVersionAttribute");
APIversion = new Version((int)VersionAttribute.ConstructorArguments[0].Value, (int)VersionAttribute.ConstructorArguments[1].Value);
Console.WriteLine(df.First().ToString() + ":" + APIversion.ToString());
}
catch (Exception ex)
{
TShock.Log.Error(ex.ToString());
Console.WriteLine(ex.StackTrace);
version = "??";
}
Console.WriteLine(fileName + ":" + version);
}
}
*/
return new RestObject() { { "Plugins", pluginList } };
}
示例5: ServerTokenTest
private object ServerTokenTest(RestRequestArgs args)
{
return new RestObject()
{
{"response", "Token is valid and was passed through correctly."},
{"associateduser", args.TokenData.Username}
};
}
示例6: ServerStatus
private object ServerStatus(RestRequestArgs args)
{
var activeplayers = Main.player.Where(p => null != p && p.active).ToList();
return new RestObject()
{
{"name", TShock.Config.ServerName},
{"port", Convert.ToString(Netplay.ListenPort)},
{"playercount", Convert.ToString(activeplayers.Count())},
{"players", string.Join(", ", activeplayers.Select(p => p.name))},
};
}
示例7: ServerRestart
private object ServerRestart(RestRequestArgs args)
{
if (!GetBool(args.Parameters["confirm"], false))
return RestInvalidParam("confirm");
// Inform players the server is shutting down
var reason = string.IsNullOrWhiteSpace(args.Parameters["message"]) ? "Server is restarting" : args.Parameters["message"];
TShock.Utils.RestartServer(!GetBool(args.Parameters["nosave"], false), reason);
return RestResponse("The server is shutting down and will attempt to restart");
}
示例8: ServerMotd
private object ServerMotd(RestRequestArgs args)
{
string motdFilePath = Path.Combine(TShock.SavePath, "motd.txt");
if (!File.Exists(motdFilePath))
return this.RestError("The motd.txt was not found.", "500");
return new RestObject()
{
{"motd", File.ReadAllLines(motdFilePath)}
};
}
示例9: ServerBroadcast
private object ServerBroadcast(RestRequestArgs args)
{
var msg = args.Parameters["msg"];
if (string.IsNullOrWhiteSpace(msg))
return RestMissingParam("msg");
TSPlayer.All.SendInfoMessage(msg);
return RestResponse("The message was broadcasted successfully");
}
示例10: GroupList
private object GroupList(RestRequestArgs args)
{
var groups = new ArrayList();
foreach (Group group in TShock.Groups)
{
groups.Add(new Dictionary<string, object> {{"name", group.Name}, {"parent", group.ParentName}, {"chatcolor", group.ChatColor}});
}
return new RestObject() { { "groups", groups } };
}
示例11: GroupInfo
private object GroupInfo(RestRequestArgs args)
{
var ret = GroupFind(args.Parameters);
if (ret is RestObject)
return ret;
Group group = (Group)ret;
return new RestObject() {
{"name", group.Name},
{"parent", group.ParentName},
{"chatcolor", string.Format("{0},{1},{2}", group.R, group.G, group.B)},
{"permissions", group.permissions},
{"negatedpermissions", group.negatedpermissions},
{"totalpermissions", group.TotalPermissions}
};
}
示例12: GroupDestroy
private object GroupDestroy(RestRequestArgs args)
{
var ret = GroupFind(args.Parameters);
if (ret is RestObject)
return ret;
Group group = (Group)ret;
try
{
TShock.Groups.DeleteGroup(group.Name, true);
}
catch (Exception e)
{
return RestError(e.Message);
}
return RestResponse("Group '" + group.Name + "' deleted successfully");
}
示例13: GroupCreate
private object GroupCreate(RestRequestArgs args)
{
var name = args.Parameters["group"];
if (string.IsNullOrWhiteSpace(name))
return RestMissingParam("group");
try
{
TShock.Groups.AddGroup(name, args.Parameters["parent"], args.Parameters["permissions"], args.Parameters["chatcolor"]);
}
catch (Exception e)
{
return RestError(e.Message);
}
return RestResponse("Group '" + name + "' created successfully");
}
示例14: BanListV2
private object BanListV2(RestRequestArgs args)
{
var banList = new ArrayList();
foreach (var ban in TShock.Bans.GetBans())
{
banList.Add(
new Dictionary<string, string>
{
{"name", null == ban.Name ? "" : ban.Name},
{"ip", null == ban.IP ? "" : ban.IP},
{"reason", null == ban.Reason ? "" : ban.Reason},
}
);
}
return new RestObject() { { "bans", banList } };
}
示例15: BanInfoV2
private object BanInfoV2(RestRequestArgs args)
{
var ret = BanFind(args.Parameters);
if (ret is RestObject)
return ret;
Ban ban = (Ban)ret;
return new RestObject() {
{"name", null == ban.Name ? "" : ban.Name},
{"ip", null == ban.IP ? "" : ban.IP},
{"reason", null == ban.Reason ? "" : ban.Reason},
};
}