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


C# Region.SetAllowedGroups方法代码示例

本文整理汇总了C#中Region.SetAllowedGroups方法的典型用法代码示例。如果您正苦于以下问题:C# Region.SetAllowedGroups方法的具体用法?C# Region.SetAllowedGroups怎么用?C# Region.SetAllowedGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Region的用法示例。


在下文中一共展示了Region.SetAllowedGroups方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReloadForUnitTest

        public void ReloadForUnitTest(String n)
        {
            using (var reader = database.QueryReader("SELECT * FROM Regions WHERE [email protected]", n))
            {
                Regions.Clear();
                while (reader.Read())
                {
                    int X1 = reader.Get<int>("X1");
                    int Y1 = reader.Get<int>("Y1");
                    int height = reader.Get<int>("height");
                    int width = reader.Get<int>("width");
                    int Protected = reader.Get<int>("Protected");
                    string MergedIDs = reader.Get<string>("UserIds");
                    string name = reader.Get<string>("RegionName");
                    string[] SplitIDs = MergedIDs.Split(',');
                    string owner = reader.Get<string>("Owner");
                    string groups = reader.Get<string>("Groups");
                    int z = reader.Get<int>("Z");

                    Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString(), z);
                    r.SetAllowedGroups(groups);
                    try
                    {
                        for (int i = 0; i < SplitIDs.Length; i++)
                        {
                            int id;

                            if (Int32.TryParse(SplitIDs[i], out id)) // if unparsable, it's not an int, so silently skip
                                r.AllowedIDs.Add(id);
                            else if (SplitIDs[i] == "") // Split gotcha, can return an empty string with certain conditions
                                // but we only want to let the user know if it's really a nonparsable integer.
                                Log.Warn("UnitTest: One of your UserIDs is not a usable integer: " + SplitIDs[i]);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error("Your database contains invalid UserIDs (they should be ints).");
                        Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field.");
                        Log.Error(e.Message);
                        Log.Error(e.StackTrace);
                    }

                    Regions.Add(r);
                }
            }
        }
开发者ID:NyxStudios,项目名称:Regions,代码行数:46,代码来源:RegionManager.cs

示例2: ReloadAllRegions

        public void ReloadAllRegions()
        {
            try
            {
                using (var reader = database.QueryReader("SELECT * FROM Regions WHERE [email protected]", Main.worldID.ToString()))
                {
                    Regions.Clear();
                    while (reader.Read())
                    {
                        int X1 = reader.Get<int>("X1");
                        int Y1 = reader.Get<int>("Y1");
                        int height = reader.Get<int>("height");
                        int width = reader.Get<int>("width");
                        int Protected = reader.Get<int>("Protected");
                        string mergedids = reader.Get<string>("UserIds");
                        string name = reader.Get<string>("RegionName");
                        string owner = reader.Get<string>("Owner");
                        string groups = reader.Get<string>("Groups");
                        int z = reader.Get<int>("Z");

                        string[] splitids = mergedids.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);

                        Region r = new Region(new Rectangle(X1, Y1, width, height), name, owner, Protected != 0, Main.worldID.ToString(), z);
                        r.SetAllowedGroups(groups);
                        try
                        {
                            for (int i = 0; i < splitids.Length; i++)
                            {
                                int id;

                                if (Int32.TryParse(splitids[i], out id)) // if unparsable, it's not an int, so silently skip
                                    r.AllowedIDs.Add(id);
                                else
                                    Log.Warn("One of your UserIDs is not a usable integer: " + splitids[i]);
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Error("Your database contains invalid UserIDs (they should be ints).");
                            Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field.");
                            Log.Error(e.ToString());
                            Log.Error(e.StackTrace);
                        }

                        Regions.Add(r);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
开发者ID:NyxStudios,项目名称:Regions,代码行数:53,代码来源:RegionManager.cs


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