Ejemplo n.º 1
0
    public GridEventManager(ISetting setting, IGrid grid, IGroupFactory groupFactory)
    {
        _grid         = grid;
        _groupFactory = groupFactory;

        _setting = setting;
    }
Ejemplo n.º 2
0
    public void Initialize(ISetting setting, IGroupFactory groupFactory)
    {
        _setting      = setting;
        _groupFactory = groupFactory;
        SetState(GridStates.GameOver);
        if (_setting.GetGameText(GameTextType.GameMessageCenter) == null)
        {
            _gameTextCenter = NullGameText.Instance;
        }
        else
        {
            _gameTextCenter = _setting.GetGameText(GameTextType.GameMessageCenter);
        }

        _cpuManager = new CPUManager(this, _setting);

        // initialize highscore if it is a player game.
        if (_setting.IsPlayer)
        {
            _highScoreManager = new HighScoreManager();
        }

        if (_highScoreManager != null)
        {
            DisplayStartMessageAndHighScore();
        }
    }
Ejemplo n.º 3
0
 public ReadyForNextGroupState(ISetting setting, IGrid grid, IGroupFactory groupFactory, OnDeleteEndEventHandler onDeleteEndEvent)
 {
     _setting          = setting;
     _grid             = grid;
     _groupFactory     = groupFactory;
     _onDeleteEndEvent = onDeleteEndEvent;
 }
Ejemplo n.º 4
0
    public GridEventManager(ISetting setting, IGrid grid, IGroupFactory groupFactory)
    {
        _grid = grid;
        _groupFactory = groupFactory;

        _setting = setting;
    }
Ejemplo n.º 5
0
 public ReadyForNextGroupState(ISetting setting, IGrid grid, IGroupFactory groupFactory, OnDeleteEndEventHandler onDeleteEndEvent)
 {
     _setting = setting;
     _grid = grid;
     _groupFactory = groupFactory;
     _onDeleteEndEvent = onDeleteEndEvent;
 }
Ejemplo n.º 6
0
 public GroupService(IGroupFactory groupFactory, IEfRepository <Group> groupRepository,
                     IUnitOfWork unitOfWork, IUserService userService)
 {
     this.groupFactory    = groupFactory;
     this.groupRepository = groupRepository;
     this.unitOfWork      = unitOfWork;
 }
Ejemplo n.º 7
0
    public void InitializeFactoriesAndSetting()
    {
        //blockViewSpawner = Substitute.For<IBlockViewSpawner>();
        blockFactory = new BlockFactory(blockViewSpawner);
        groupFactory = new GroupFactory(blockFactory);

        setting = TestSetting.Get();
    }
Ejemplo n.º 8
0
    public void InitializeFactoriesAndSetting()
    {
        //blockViewSpawner = Substitute.For<IBlockViewSpawner>();
        blockFactory = new BlockFactory(blockViewSpawner);
        groupFactory = new GroupFactory(blockFactory);

        setting = TestSetting.Get();
    }
Ejemplo n.º 9
0
 public Engine(IData data, IInputReader reader, IOutputWriter writer, IWarEffectFactory warFactory, IAttackTypeFactory attackFactory, IGroupFactory groupFactory)
 {
     this.data = data;
     this.reader = reader;
     this.writer = writer;
     this.warFactory = warFactory;
     this.attackTypeFectory = attackFactory;
     this.groupFactory = groupFactory;
 }
Ejemplo n.º 10
0
 public CreateGroupViewModel(IGroupService groupService,
                             IGroupFactory groupFactory,
                             IFrameNavigationService navigationService,
                             IUserService userService) : base(navigationService)
 {
     _groupService = groupService;
     _groupFactory = groupFactory;
     _userService  = userService;
 }
Ejemplo n.º 11
0
        public virtual GroupCollection <T> Perform(
            IReadOnlyCollection <T> items,
            int level,
            Group <T> parent)
        {
            GroupDescriptorCollection groupDescriptors = this.index.CollectionView.GroupDescriptors;

            if (level >= groupDescriptors.Count)
            {
                return(GroupCollection <T> .Empty);
            }
            IGroupFactory <T>   groupFactory = this.index.CollectionView.GroupFactory;
            GroupCollection <T> cachedGroups = this.GetCachedGroups(items, level);

            if (!GroupBuilder <T> .IsValid(level, groupDescriptors))
            {
                cachedGroups?.Dispose();
                return(groupFactory.CreateCollection((IList <Group <T> >)GroupBuilder <T> .Empty));
            }
            IComparer <Group <T> > comparer = Activator.CreateInstance(this.Comparer.GetType()) as IComparer <Group <T> > ?? this.Comparer;

            if (comparer is GroupComparer <T> )
            {
                ((GroupComparer <T>)comparer).Directions = this.GetComparerDirections(level);
            }
            AvlTree <Group <T> > avlTree1 = new AvlTree <Group <T> >(comparer);
            AvlTree <Group <T> > avlTree2 = new AvlTree <Group <T> >((IComparer <Group <T> >) new GroupComparer <T>(this.GetComparerDirections(level)));

            foreach (T key1 in !this.CollectionView.CanPage || level != 0 || !this.CollectionView.PagingBeforeGrouping ? (IEnumerable <T>)items : (IEnumerable <T>) this.index.GetItemsOnPage(this.CollectionView.PageIndex))
            {
                object    key2   = this.GroupPredicate(key1, level);
                Group <T> group1 = (Group <T>) new DataItemGroup <T>(key2);
                Group <T> group2 = avlTree2.Find(group1);
                if (group2 == null)
                {
                    group2 = this.GetGroup(cachedGroups, group1, parent, key2, level);
                    avlTree2.Add(group2);
                }
                group2.Items.Add(key1);
                if (this.itemGroupsCache.ContainsKey(key1))
                {
                    this.itemGroupsCache[key1] = group2;
                }
                else
                {
                    this.itemGroupsCache.Add(key1, group2);
                }
            }
            for (int index = 0; index < avlTree2.Count; ++index)
            {
                avlTree1.Add(avlTree2[index]);
            }
            cachedGroups?.Dispose();
            return(groupFactory.CreateCollection((IList <Group <T> >)avlTree1));
        }
Ejemplo n.º 12
0
        private static GroupingResults GenerateBottomLevelsFromSourceParallel(ParallelState state)
        {
            HashSet <object>[] uniqueFilterItems;
            List <object>      items;

            SortAndFilterItems(state, out uniqueFilterItems, out items);

            if (!state.HasDescriptions)
            {
                IGroupFactory groupFactory = state.ValueProvider.GetGroupFactory();
                Group         rowRootGroup = CreateGrandTotal(groupFactory);
                rowRootGroup.SetItems(items);
                Group columnRootGroup = CreateGrandTotal(groupFactory);
                IDictionary <Coordinate, AggregateValue[]> aggregates = new Dictionary <Coordinate, AggregateValue[]>();
                return(new GroupingResults(rowRootGroup, columnRootGroup, groupFactory)
                {
                    Aggregates = aggregates, UniqueFilterItems = uniqueFilterItems
                });
            }

            int maxDegreeOfParallelism = Math.Max(1, state.MaxDegreeOfParallelism);
            int itemCount  = state.ItemCount;
            int remainder  = itemCount % maxDegreeOfParallelism;
            int multiplier = (itemCount / maxDegreeOfParallelism) + (remainder > 0 ? 1 : 0);

            List <Task <GroupingResults> > tasks = new List <Task <GroupingResults> >(maxDegreeOfParallelism);

            for (int i = 0; i < maxDegreeOfParallelism; i++)
            {
                int start = i * multiplier;
                int end   = Math.Min((i + 1) * multiplier, itemCount);

                BottomLevelGroupingTaskState taskState = new BottomLevelGroupingTaskState()
                {
                    ParallelState = state, Start = start, End = end
                };
                var task = Task.Factory.StartNew <GroupingResults>(ProcessItems, taskState, state.CancellationToken, TaskCreationOptions.LongRunning | TaskCreationOptions.AttachedToParent, state.TaskScheduler);

                tasks.Add(task);
            }

            Task.WaitAll(tasks.ToArray());
            GroupingResults result = tasks[0].Result;

            for (int i = 1; i < tasks.Count; i++)
            {
                result.Merge(tasks[i].Result);
            }

            result.UniqueFilterItems = uniqueFilterItems;
            return(result);
        }
Ejemplo n.º 13
0
 private void InitializeFields()
 {
     this.filter           = (Predicate <TDataItem>)null;
     this.filterExpression = string.Empty;
     this.filterContext    = new StringCollection();
     this.sortDescriptorCollectionFactory = (ISortDescriptorCollectionFactory) new DefaultSortDescriptorCollectionFactory();
     this.sortDescriptors = this.SortDescriptorCollectionFactory.CreateCollection();
     this.sortDescriptors.CollectionChanged += new NotifyCollectionChangedEventHandler(this.sortDescriptors_CollectionChanged);
     this.groupFactory = (IGroupFactory <TDataItem>) new DefaultGroupFactory <TDataItem>();
     this.groupDescriptorCollectionFactory = (IGroupDescriptorCollectionFactory) new DefaultGroupDescriptorCollectionFactory();
     this.groupDescriptors = this.GroupDescriptorCollectionFactory.CreateCollection();
     this.groupDescriptors.CollectionChanged += new NotifyCollectionChangedEventHandler(this.groupDescriptors_CollectionChanged);
 }
Ejemplo n.º 14
0
    public void Init()
    {
        testSetting = TestSetting.Get();
        game = new Game(testSetting);
        cameraManager = Substitute.For<ICameraManager>();
        backgroundFactory = Substitute.For<IBackgroundFactory>();
        gridFactory = Substitute.For<IGridFactory>();
        groupFactory = Substitute.For<IGroupFactory>();

        game.CameraManager = cameraManager;
        game.BackgroundFactory = backgroundFactory;
        game.GridFactory = gridFactory;
        game.GroupFactory = groupFactory;
    }
Ejemplo n.º 15
0
 public Engine(
     IInputReader reader,
     IOutputWriter writer,
     ICommandDispatcher commandDispatcher,
     IGroupFactory groupFactory,
     IWarEffectFactory warEffectFactory,
     IAttackFactory attackFactory,
     IDatabase db)
 {
     this.writer                   = writer;
     this.reader                   = reader;
     this.commandDispatcher        = commandDispatcher;
     this.commandDispatcher.Engine = this;
     this.GroupFactory             = groupFactory;
     this.WarEffectFactory         = warEffectFactory;
     this.AttackFactory            = attackFactory;
     this.Db = db;
 }
Ejemplo n.º 16
0
 public MessageHub(
     IUnitOfWork unitOfWork,
     IMapper mapper,
     IMessageFactory messageFactory,
     IGroupFactory groupFactory,
     IConnectionFactory connectionFactory,
     PresenceTracker presenceTracker,
     IHubContext <PresenceHub> presenceHub
     )
 {
     this.unitOfWork        = unitOfWork;
     this.mapper            = mapper;
     this.messageFactory    = messageFactory;
     this.groupFactory      = groupFactory;
     this.connectionFactory = connectionFactory;
     this.presenceTracker   = presenceTracker;
     this.presenceHub       = presenceHub;
 }
Ejemplo n.º 17
0
        internal Group CreateGroupByName(object groupName, IGroupFactory groupFactor)
        {
            if (groupName == null)
            {
                groupName = NullValue.Instance;
            }

            Group group;

            if (!this.GroupsByName.TryGetValue(groupName, out group))
            {
                group = groupFactor.CreateGroup(groupName);
                group.InternalParent = this;
                this.GroupsByName.Add(groupName, group);
                this.InsertItem(-1, group, null);
            }

            return(group);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// This method should be used only after TryGetGroup returns false.
        /// </summary>
        /// <param name="groupName">The groupName.</param>
        /// <param name="groupFactory">The factory that will create new groups.</param>
        /// <param name="sortComparer">The groupName comparer.</param>
        /// <returns>Returns the index of the newly added group.</returns>
        internal int AddGroupByName(object groupName, IGroupFactory groupFactory, IComparer <object> sortComparer)
        {
            if (groupName == null)
            {
                groupName = NullValue.Instance;
            }

            System.Diagnostics.Debug.Assert(!this.GroupsByName.ContainsKey(groupName), "This method should not be called for existing groupName!");

            Group group;

            if (!this.GroupsByName.TryGetValue(groupName, out group))
            {
                group = groupFactory.CreateGroup(groupName);
                group.InternalParent = this;
                this.GroupsByName.Add(groupName, group);
                return(this.InsertItem(-1, group, sortComparer));
            }
            else
            {
                return(this.itemsList.IndexOf(group));
            }
        }
Ejemplo n.º 19
0
 public void Init()
 {
     groupFactory = Substitute.For<IGroupFactory>();
     groupStock = new GroupStock(groupFactory);
     groupStock.StockDisplayConfig = stockPositions;
 }
Ejemplo n.º 20
0
 public GridFactory(ISetting setting, IGroupFactory groupFactory)
 {
     _setting = setting;
     _groupFactory = groupFactory;
 }
Ejemplo n.º 21
0
    public void Initialize(ISetting setting, IGroupFactory groupFactory)
    {
        _setting = setting;
        _groupFactory = groupFactory;
        SetState(GridStates.GameOver);
        if (_setting.GetGameText(GameTextType.GameMessageCenter) == null)
        {
            _gameTextCenter = NullGameText.Instance;
        }
        else
        {
            _gameTextCenter = _setting.GetGameText(GameTextType.GameMessageCenter);
        }

        _cpuManager = new CPUManager(this, _setting);

        // initialize highscore if it is a player game.
        if (_setting.IsPlayer)
        {
            _highScoreManager = new HighScoreManager();
        }

        if(_highScoreManager != null)
        {
            DisplayStartMessageAndHighScore();
        }
    }
Ejemplo n.º 22
0
 public void Init()
 {
     groupFactory = Substitute.For <IGroupFactory>();
     groupStock   = new GroupStock(groupFactory);
     groupStock.StockDisplayConfig = stockPositions;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Performs the grouping operation for specified items.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="level">The level.</param>
        /// <param name="parent">The parent.</param>
        /// <returns></returns>
        public virtual GroupCollection <T> Perform(IReadOnlyCollection <T> items, int level, Group <T> parent)
        {
            GroupDescriptorCollection groupDescriptors = this.index.CollectionView.GroupDescriptors;

            if (level >= groupDescriptors.Count)
            {
                return(GroupCollection <T> .Empty);
            }
            IGroupFactory <T> groupFactory = this.index.CollectionView.GroupFactory;

            GroupCollection <T> cache = GetCachedGroups(items, level);

            if (!IsValid(level, groupDescriptors))
            {
                if (cache != null)
                {
                    cache.Dispose();
                }
                return(this.index.CollectionView.GroupFactory.CreateCollection(GroupBuilder <T> .Empty));
            }

            IComparer <Group <T> > newComparer = Activator.CreateInstance(this.Comparer.GetType()) as IComparer <Group <T> >;

            if (newComparer == null)
            {
                newComparer = this.Comparer;
            }
            if (newComparer is GroupComparer <T> )
            {
                ((GroupComparer <T>)newComparer).Directions = this.GetComparerDirections(level);
            }

            AvlTree <Group <T> > groupList = new AvlTree <Group <T> >(newComparer);
            AvlTree <Group <T> > list      = new AvlTree <Group <T> >(new GroupComparer <T>(this.GetComparerDirections(level)));

            foreach (T item in items)
            {
                object    key = this.GroupPredicate(item, level);
                Group <T> group, newGroup = new DataItemGroup <T>(key);
                group = list.Find(newGroup); groupList.Find(newGroup);
                if (group == null)
                {
                    group = GroupBuilder <T> .GetCachedGroup(cache, newGroup);

                    if (group == null)
                    {
                        group = groupFactory.CreateGroup(key, parent);
                        DataItemGroup <T> dataGroup = group as DataItemGroup <T>;
                        dataGroup.GroupBuilder = this;
                    }

                    list.Add(group);// groupList.Add(group);
                }

                group.Items.Add(item);
            }

            for (int i = 0; i < list.Count; i++)
            {
                groupList.Add(list[i]);
            }

            if (cache != null)
            {
                cache.Dispose();
            }

            return(groupFactory.CreateCollection(groupList));
        }
Ejemplo n.º 24
0
 public void Init()
 {
     gridMock = Substitute.For<IGrid>();
     groupFactoryMock = Substitute.For<IGroupFactory>();
 }
Ejemplo n.º 25
0
 public void Init()
 {
     gridMock         = Substitute.For <IGrid>();
     groupFactoryMock = Substitute.For <IGroupFactory>();
 }
Ejemplo n.º 26
0
 public GroupStock(IGroupFactory groupFactory)
 {
     _groupFactory = groupFactory;
     _groupStocks = new List<IGroup>();
 }
Ejemplo n.º 27
0
 public GroupService(IGroupRepository repository, IGroupFactory factory)
 {
     this.Repository = repository;
     this.Factory = factory;
 }
Ejemplo n.º 28
0
 public World(IInpputReader reader, IOutputWriter writer, IGroupFactory groupFactory)
 {
     this.Reader = reader;
     this.Writer = writer;
     this.GroupFactory = groupFactory;
 }
Ejemplo n.º 29
0
 public GroupStock(IGroupFactory groupFactory)
 {
     _groupFactory = groupFactory;
     _groupStocks  = new List <IGroup>();
 }
Ejemplo n.º 30
0
 public GridFactory(ISetting setting, IGroupFactory groupFactory)
 {
     _setting      = setting;
     _groupFactory = groupFactory;
 }