コード例 #1
0
        public override IEnumerable <LoadEntity> GetEntities(LoadContainer targetContainer)
        {
            List <LoadEntity>     list  = new List <LoadEntity>(base.SourceEntities);
            List <LoadEntity>     list2 = new List <LoadEntity>();
            IAllocationConstraint allocationConstraint = targetContainer.Constraint ?? new AnyLoadConstraint();
            Random random = new Random();

            while (list.Count > 0 && (long)list2.Count < this.totalNumberOfEntities)
            {
                int        index      = random.Next(list.Count);
                LoadEntity loadEntity = list[index];
                if (allocationConstraint.Accept(loadEntity))
                {
                    list2.Add(loadEntity);
                }
                list.RemoveAt(index);
            }
            return(list2);
        }
コード例 #2
0
		public override IEnumerable<LoadEntity> GetEntities(LoadContainer targetContainer)
		{
			IAllocationConstraint allocationConstraint = targetContainer.Constraint ?? new AnyLoadConstraint();
			List<LoadEntity> list = new List<LoadEntity>(base.SourceEntities);
			List<LoadEntity> list2 = new List<LoadEntity>();
			ByteQuantifiedSize value = ByteQuantifiedSize.FromBytes(0UL);
			Random random = new Random();
			while (list.Count > 0 && value < this.totalSize)
			{
				int index = random.Next(list.Count);
				LoadEntity loadEntity = list[index];
				if (allocationConstraint.Accept(loadEntity))
				{
					ByteQuantifiedSize byteQuantifiedSize = value + loadEntity.ConsumedLoad.GetSizeMetric(PhysicalSize.Instance);
					if (byteQuantifiedSize < this.totalSize)
					{
						list2.Add(loadEntity);
						value = byteQuantifiedSize;
					}
				}
				list.RemoveAt(index);
			}
			return list2;
		}
コード例 #3
0
 public ConstraintValidationResult(IAllocationConstraint constraint, bool accepted)
 {
     this.Constraint = constraint;
     this.Accepted   = accepted;
 }