Exemple #1
0
        private List <Entity> GetElites()
        {
            population = population.OrderBy(x => x.Fitness).ToArray();
            //var luckyOnes = gen.Next(0, population.Length - ElitismCount - 1 / 2);
            var elites = new Entity[ElitismCount];

            Array.Copy(population, 0, elites, 0, ElitismCount);
            return(elites.ToList());
        }
Exemple #2
0
 /// <summary>
 /// Get list of entities
 /// </summary>
 /// <returns></returns>
 public IList <T> GetAll(bool allowTracking = true)
 {
     if (allowTracking)
     {
         return(Entity.ToList());
     }
     else
     {
         return(Entity.AsNoTracking().ToList());
     }
 }
		private CollectionDiffWithValue<Entity, Entity> TestSyncWithValue(Entity[] oldItems, EntityProto[] newItems, 
			int addedCount = 0, int removedCount = 0, int editedCount = 0, int unchangedCount = 0) {
			
			var list = oldItems.ToList();
			var result = CollectionHelper.SyncWithContent(list, newItems, EqualityEntity, FacEntity, Update, null);

			Assert.IsNotNull(result, "result is not null");
			Assert.AreEqual(addedCount > 0 || removedCount > 0 || editedCount > 0, result.Changed, "is changed");
			Assert.AreEqual(addedCount, result.Added.Length, "Aadded");
			Assert.AreEqual(editedCount, result.Edited.Length, "Edited");
			Assert.AreEqual(removedCount, result.Removed.Length, "Removed");
			Assert.AreEqual(unchangedCount, result.Unchanged.Length, "Unchanged");
			return result;

		}
Exemple #4
0
        /// <summary>
        /// Return the filtered list of entities related to the specified entity type and applying the
        /// specified filter from a JSON-formatted text file.
        /// </summary>
        /// <param name="entity">The entity type</param>
        /// <param name="filter">The Filter</param>
        /// <returns>The filtered list of entities</returns>
        public IList <Entity> GetEntities(Entity entity, FilterInfo filter)
        {
            LoggerHelper.Info("Start");
            List <Entity> filteredItems = new List <Entity>();

            try
            {
                IList <Entity> list = GetEntities(entity);
                filter.Total = list.Count;

                filteredItems = (List <Entity>)list;

                //Merging tables
                MergeData(filteredItems, entity);

                //Filtering entities
                filteredItems = FilterEntities(list, entity, filter);

                //Sorting results
                if (filter != null && filter.SortColumns.Count > 0)
                {
                    ((List <Entity>)filteredItems).Sort((x, y) => SortEntities(x, y, filter));
                }

                //Returning only the number of records requested
                filter.FilteredRecords = filteredItems.Count;
                if (filter.Lenght > 0)
                {
                    int      length = filteredItems.Count < filter.Lenght ? filteredItems.Count : filter.Lenght;
                    Entity[] array  = new Entity[length];
                    filteredItems.CopyTo(filter.Start, array, 0, length);

                    filteredItems = array.ToList();
                }
            }
            catch (Exception e)
            {
                LoggerHelper.Error("Unable to fetch " + entity.GetTableName() + " list.", e);
                throw new Exception("Unable to fetch " + entity.GetTableName() + " list.", e);
            }
            finally
            {
                LoggerHelper.Info("End");
            }

            return(filteredItems);
        }
Exemple #5
0
        public override void OnStart()
        {
            var player1       = new WhiteBread(_breadTexture, PlayerIndex.One);
            var player2       = new WhiteBread(_breadTexture, PlayerIndex.Two);
            var spritePointer = new SpritePointer();

            var entities = new Entity[]
            {
                player1,
                player2,
                spritePointer,
                new Background(_backgroundTexture)
            };

            entities.ToList().ForEach(x => AddEntity(x));

            var systems = new EntitySystem[]
            {
                new FacingSystem(spritePointer, player1, player2),

                // FighterStateSystems
                new CrouchSystem(),
                new CrouchAttackSystem(),
                new HurtSystem(),
                new IdleSystem(),
                new NeutralAttackSystem(),
                new JumpSystem(),
                new WalkSystem(),
                // After FighterStateSystemsProcessing
                new StompCollisionSystem(),
                new BumpbackSystem(),
                new GravitySystem(),
                new BoundarySystem(),

                // Misc
                new WinSystem(),
                new ResetSystem()
            };

            systems.ToList().ForEach(x => AddEntityProcessor(x));
        }
 /// <summary>
 /// Returns all user's analytical operations
 /// </summary>
 /// <returns></returns>
 public List <UserAnalyticsOperation> GetAll()
 {
     return(Entity.ToList());
 }
 public ICollection <T> FindAll()
 {
     return(Entity.ToList());
 }
        /// <summary>
        /// Issues a <c>CompundCreateRequest</c> to the target <c>CrmService</c>.
        /// </summary>
        /// <param name="entity">The <c>Entity</c> to be created.</param> 
        /// <param name="children">The <c>Array</c> of <c>Entity</c> objects that contains the children.</param>
        protected void CreateNewCompoundEntity(Entity entity, Entity[] children)
        {
            if (entity == null)
            {
                throw new AdapterException(string.Format(CultureInfo.CurrentCulture, Resources.ArgumentNullExceptionMessage), new ArgumentNullException("entity")) { ExceptionId = AdapterException.SystemExceptionGuid };
            }

            entity.Attributes.Remove(CRM2011AdapterUtilities.IsNew);
            OptionSetValue state = null;
            OptionSetValue status = null;

            state = RemoveStateCode(entity);
            if (state != null)
            {
                status = RemoveStatusCode(entity);
            }

            entity.RelatedEntities.Add(new Relationship((entity.LogicalName == "salesorder" ? "order" : entity.LogicalName) + "_details"), new EntityCollection(children.ToList()));
            CreateRequest request = new CreateRequest() { Target = entity };
            if (this.DoesDetectDuplicates == true)
            {
                request["SuppressDuplicateDetection"] = false;
            }

            PrepEntityForCreate(entity);
            this.CallCrmExecuteWebMethod(request);
            this.ApplyStateAndStatus(entity, state, status);
        }