private ACConfiguration BuildConfiguration(DoorControllerDescriptor[] doorControllers, DoorDescriptor[] doors, EventDescriptor[] eventDescriptors)
        {
            var elements = new List <ACElement>();

            // Add element types
            elements.Add(ElementTypes.ServerType);
            elements.Add(ElementTypes.DoorControllerType);

            // Add event types
            elements.AddRange(EventTypes.ServerEventTypes);

            foreach (var eventDescriptor in eventDescriptors)
            {
                var acEventType = TypeConverter.ToACEventType(eventDescriptor, !_disabledEventTypes.Contains(eventDescriptor.EventId));
                elements.Add(acEventType);
            }

            // Add state types
            elements.AddRange(StateTypes.ServerStateTypes);
            elements.AddRange(StateTypes.DoorStateTypes);

            // Add command types
            elements.AddRange(CommandTypes.DoorCommands);

            // Look up the all events, which can be fired on a door
            // OBS: In the Demo Access Control application, events with source "DoorController" are actually fired on the door.
            var doorEventTypeIds = eventDescriptors.Where(e => e.SourceType == "Door" || e.SourceType == "DoorController").Select(ed => ed.EventId.ToString());

            elements.Add(ElementTypes.CreateDoorType(doorEventTypeIds));

            // Look up the all events, which can be fired on an access point
            var apEventTypeIds = eventDescriptors.Where(ed => ed.SourceType == "AccessPoint").Select(ed => ed.EventId.ToString());

            elements.Add(ElementTypes.CreateAccessPointType(apEventTypeIds));

            // Add server element
            elements.Add(TypeConverter.CreateACServer(_client.ServerId, _systemProperties.Address));

            // Add door controllers
            foreach (var doorController in doorControllers)
            {
                elements.Add(TypeConverter.ToACUnit(doorController));
            }

            // Add doors and access points
            foreach (var door in doors)
            {
                door.Enabled = !_disabledDoors.Contains(door.DoorId);
                elements.AddRange(TypeConverter.ToACUnits(door));
            }

            try
            {
                return(ACConfiguration.CreateACConfiguration(DateTime.UtcNow, elements));
            }
            catch (ACConfigurationException ex)
            {
                ACUtil.Log(true, "DemoACPlugin.ConfigurationManager", "Error building configuration: " + ex.Message);
                return(null);
            }
        }