/// <summary>
        /// Erzeugt eine neue Planung.
        /// </summary>
        /// <param name="resource">Das zugehörige Gerät.</param>
        /// <param name="schedulePlan">Die zugehörige Gesamtplanung.</param>
        /// <param name="decryptionCounter">Die Zähler für die Entschlüsselung.</param>
        /// <param name="allocations">Optional alle bereits vorgenommenen Zuordnungen.</param>
        /// <param name="planTime">Der aktuelle Planungsbeginn, sofern bekannt.</param>
        /// <exception cref="ArgumentNullException">Es wurde kein Gerät angegeben.</exception>
        public ResourcePlan(IScheduleResource resource, SchedulePlan schedulePlan, HashSet <Guid> decryptionCounter = null, AllocationMap allocations = null, DateTime?planTime = null)
        {
            // Remember
            SchedulePlan = schedulePlan;
            Resource     = resource;

            // Register a single decryption counter
            DecryptionCounters = decryptionCounter ?? new HashSet <Guid> {
                schedulePlan.RegisterDecryption(Resource.Decryption.MaximumParallelSources)
            };

            // Check for allocation
            if (allocations != null)
            {
                // Just clone
                Allocations = allocations.Clone(planTime);
            }
            else
            {
                // Number of sources we may use
                var sourceLimit = resource.SourceLimit;
                if (sourceLimit < 1)
                {
                    sourceLimit = int.MaxValue;
                }

                // Create brand new
                Allocations = new AllocationMap(sourceLimit, CheckForSourceGroupMatch);
            }
        }