当前位置: 首页>>代码示例>>C#>>正文


C# Rests.RestRequestArgs类代码示例

本文整理汇总了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;
        }
开发者ID:matthewgrzegorczyk,项目名称:SPlugin,代码行数:16,代码来源:SPluginApi.cs

示例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 },
            };
        }
开发者ID:UB1AFU,项目名称:ExtraRest,代码行数:18,代码来源:main.cs

示例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}
            };
        }
开发者ID:UB1AFU,项目名称:ExtraRest,代码行数:20,代码来源:main.cs

示例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 } };
        }
开发者ID:Grandpa-G,项目名称:VersionInfo,代码行数:55,代码来源:VersionInfo.cs

示例5: ServerTokenTest

 private object ServerTokenTest(RestRequestArgs args)
 {
     return new RestObject()
     {
         {"response", "Token is valid and was passed through correctly."},
         {"associateduser", args.TokenData.Username}
     };
 }
开发者ID:sylar605,项目名称:TshockCN,代码行数:8,代码来源:RestManager.cs

示例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))},
     };
 }
开发者ID:sylar605,项目名称:TshockCN,代码行数:11,代码来源:RestManager.cs

示例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");
        }
开发者ID:sylar605,项目名称:TshockCN,代码行数:11,代码来源:RestManager.cs

示例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)}
            };
        }
开发者ID:sylar605,项目名称:TshockCN,代码行数:11,代码来源:RestManager.cs

示例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");
 }
开发者ID:sylar605,项目名称:TshockCN,代码行数:8,代码来源:RestManager.cs

示例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 } };
 }
开发者ID:sylar605,项目名称:TshockCN,代码行数:9,代码来源:RestManager.cs

示例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}
            };
        }
开发者ID:sylar605,项目名称:TshockCN,代码行数:16,代码来源:RestManager.cs

示例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");
        }
开发者ID:sylar605,项目名称:TshockCN,代码行数:18,代码来源:RestManager.cs

示例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");
        }
开发者ID:sylar605,项目名称:TshockCN,代码行数:16,代码来源:RestManager.cs

示例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 } };
        }
开发者ID:sylar605,项目名称:TshockCN,代码行数:17,代码来源:RestManager.cs

示例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},
            };
        }
开发者ID:sylar605,项目名称:TshockCN,代码行数:13,代码来源:RestManager.cs


注:本文中的Rests.RestRequestArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。