Aurora.Services.WebAPIHandler.GetRegions C# (CSharp) Method

GetRegions() private method

private GetRegions ( OSDMap map ) : OSDMap
map OSDMap
return OSDMap
        private OSDMap GetRegions(OSDMap map)
        {
            OSDMap resp = new OSDMap();
            RegionFlags includeFlags = map.ContainsKey("RegionFlags") ? (RegionFlags)map["RegionFlags"].AsInteger() : RegionFlags.RegionOnline;
            RegionFlags excludeFlags = map.ContainsKey("ExcludeRegionFlags") ? (RegionFlags)map["ExcludeRegionFlags"].AsInteger() : 0;
            int start = map.Keys.Contains("Start") ? map["Start"].AsInteger() : 0;
            if (start < 0)
            {
                start = 0;
            }
            int count = map.Keys.Contains("Count") ? map["Count"].AsInteger() : 10;
            if (count < 0)
            {
                count = 1;
            }

            IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin<IRegionData>();

            Dictionary<string, bool> sort = new Dictionary<string, bool>();

            string[] supportedSort = new string[3]{
                "SortRegionName",
                "SortLocX",
                "SortLocY"
            };

            foreach (string sortable in supportedSort)
            {
                if (map.ContainsKey(sortable))
                {
                    sort[sortable.Substring(4)] = map[sortable].AsBoolean();
                }
            }

            List<GridRegion> regions = regiondata.Get(includeFlags, excludeFlags, (uint)start, (uint)count, sort);
            OSDArray Regions = new OSDArray();
            foreach (GridRegion region in regions)
            {
                Regions.Add(GridRegion2WebOSD(region));
            }

            MainConsole.Instance.Trace("Total regions: " + regiondata.Count(includeFlags, excludeFlags));

            resp["Start"] = OSD.FromInteger(start);
            resp["Count"] = OSD.FromInteger(count);
            resp["Total"] = OSD.FromInteger((int)regiondata.Count(includeFlags, excludeFlags));
            resp["Regions"] = Regions;
            return resp;
        }