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

GetEvents() private method

private GetEvents ( OSDMap map ) : OSDMap
map OSDMap
return OSDMap
        private OSDMap GetEvents(OSDMap map)
        {
            uint start = map.ContainsKey("Start") ? map["Start"].AsUInteger() : 0;
            uint count = map.ContainsKey("Count") ? map["Count"].AsUInteger() : 0;
            Dictionary<string, bool> sort = new Dictionary<string, bool>();
            Dictionary<string, object> filter = new Dictionary<string, object>();

            OSDMap resp = new OSDMap();
            resp["Start"] = start;
            resp["Total"] = 0;
            resp["Events"] = new OSDArray(0);

            IDirectoryServiceConnector directory = Aurora.DataManager.DataManager.RequestPlugin<IDirectoryServiceConnector>();
            if (directory != null)
            {
                if (map.ContainsKey("Filter") && map["Filter"].Type == OSDType.Map)
                {
                    OSDMap fields = (OSDMap)map["Filter"];
                    foreach (string field in fields.Keys)
                    {
                        filter[field] = fields[field];
                    }
                }
                if (count > 0)
                {
                    if (map.ContainsKey("Sort") && map["Sort"].Type == OSDType.Map)
                    {
                        OSDMap fields = (OSDMap)map["Sort"];
                        foreach (string field in fields.Keys)
                        {
                            sort[field] = int.Parse(fields[field]) != 0;
                        }
                    }

                    OSDArray Events = new OSDArray();
                    directory.GetEvents(start, count, sort, filter).ForEach(delegate(EventData Event)
                    {
                        Events.Add(Event.ToOSD());
                    });
                    resp["Events"] = Events;
                }
                resp["Total"] = (int)directory.GetNumberOfEvents(filter);
            }

            return resp;
        }