示例#1
0
        public void RestorePreviousState(ref Round round, ref ParticipatorsContainer container)
        {
            if (round.RoundNumber != 1)
            {
                round.RoundNumber--;

                List<List<ObjectParticipator>> tmpObjects = new List<List<ObjectParticipator>>() {
                new List<ObjectParticipator>() { ChoosedObjects.Last(), ExcludedObjects.Last() }};
                tmpObjects.AddRange(round.Pairs);

                round.Pairs = tmpObjects;

                container.RemainderOfInitialCapacity++;
                container.NextRoundObjectsArray.Remove(container.NextRoundObjectsArray.Last());
            }
            else
            {
                round = (Round)PreviousStageRound.Clone();
                container = (ParticipatorsContainer)PreviousPContainer.Clone();
            }

            ChoosedObjects.Remove(ChoosedObjects.Last());
            ExcludedObjects.Remove(ExcludedObjects.Last());

        }
示例#2
0
 public void InitializePreviousState(Round round, ParticipatorsContainer container)
 {
     PreviousStageRound = (Round)round.Clone();
     PreviousPContainer = (ParticipatorsContainer)container.Clone();
     ExcludedObjects.Add(round.Pairs[0].First());
     ExcludedObjects.Add(round.Pairs[0].Last());
 }
示例#3
0
        protected IEnumerable <EntityWithOperation> GetEntitiesWithOperationFromClass(Type source)
        {
            var excluded = ExcludedObjects.ToArray();

            var properties = source.GetProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
                             .Where(e => e.GetCustomAttribute <InlineDataAttribute>() != null)
                             .ToArray();

            ////todo: does it make sense ?
            //var method = source.GetMethod("Update", BindingFlags.Public | BindingFlags.Static);
            //method?.Invoke(null, null);

            var entities = new List <EntityWithOperation>();

            var enumerables = properties.Where(e => typeof(IEnumerable).IsAssignableFrom(e.PropertyType))
                              .Select(e => new
            {
                data = e.GetValue(null) as IEnumerable,
                e.GetCustomAttribute <InlineDataAttribute>().OperationKind
            });

            foreach (var enumerable in enumerables)
            {
                var enumerator = enumerable.data.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    entities.Add(new EntityWithOperation(enumerator.Current, enumerable.OperationKind));
                }
            }

            entities.AddRange
            (
                properties.Where(e => !typeof(IEnumerable).IsAssignableFrom(e.PropertyType))
                .Select(e => new EntityWithOperation
                        (
                            e.GetValue(null),
                            e.GetCustomAttribute <InlineDataAttribute>().OperationKind
                        ))
            );

            return(entities.Where(e => !excluded.Contains(e.Entity)).ToArray());
        }
示例#4
0
 public void UpdateObjectsLists(ObjectParticipator choosedObject)
 {
     ChoosedObjects.Add(choosedObject);
     ExcludedObjects.Remove(choosedObject);
 }