Exemplo n.º 1
0
 public StrongholdChecker(IStrongholdManager strongholdManager, IDbManager dbManager, IScheduler scheduler, ILocker locker)
 {
     this.strongholdManager = strongholdManager;
     this.dbManager         = dbManager;
     this.scheduler         = scheduler;
     this.locker            = locker;
 }
 public LockerWrapper(ILocker locker, Action onBeginLock, Action onEndLock)
 {
     _locker    = locker;
     _onEndLock = onEndLock;
     _locker.Lock();
     onBeginLock();
 }
Exemplo n.º 3
0
        public BarbarianTribeBattlePassiveAction(uint barbarianTribeId,
                                                 ILocker locker,
                                                 IGameObjectLocator gameObjectLocator,
                                                 IDbManager dbManager,
                                                 Formula formula,
                                                 BarbarianTribeBattleProcedure barbarianTribeBattleProcedure,
                                                 IWorld world,
                                                 ISimpleStubGeneratorFactory simpleStubGeneratorFactory)
            : this(locker, gameObjectLocator, dbManager, formula, barbarianTribeBattleProcedure, world, simpleStubGeneratorFactory)
        {
            this.barbarianTribeId              = barbarianTribeId;
            this.locker                        = locker;
            this.gameObjectLocator             = gameObjectLocator;
            this.dbManager                     = dbManager;
            this.formula                       = formula;
            this.barbarianTribeBattleProcedure = barbarianTribeBattleProcedure;
            this.world = world;

            IBarbarianTribe barbarianTribe;

            if (!gameObjectLocator.TryGetObjects(barbarianTribeId, out barbarianTribe))
            {
                throw new Exception("Did not find barb tribe that was supposed to be having a battle");
            }

            simpleStubGenerator = simpleStubGeneratorFactory.CreateSimpleStubGenerator(formula.BarbarianTribeUnitRatios(), formula.BarbarianTribeUnitTypes());
        }
Exemplo n.º 4
0
 public WorkerOrderNumberRepository(
     CassandraStorage <WorkerOrderNumberStorageElement> storage,
     ILocker locker)
 {
     this.storage = storage;
     this.locker  = locker;
 }
Exemplo n.º 5
0
 public CityRewardStrategy(ICity city, IBattleFormulas battleFormulas, Formula formula, ILocker locker)
 {
     this.city           = city;
     this.battleFormulas = battleFormulas;
     this.formula        = formula;
     this.locker         = locker;
 }
Exemplo n.º 6
0
 public StrongholdCommandsModule(IStrongholdManager strongholdManager, IWorld world, ILocker locker, IThemeManager themeManager)
 {
     this.strongholdManager = strongholdManager;
     this.world             = world;
     this.locker            = locker;
     this.themeManager      = themeManager;
 }
Exemplo n.º 7
0
 // Do not add more parameters to this class. If it needs anything pass it in with the method that needs the dependency.
 // We should try to move some of the logic outside of this class since it's getting big and becoming a bag for random methods.
 // Maybe split it up into more specific types.
 public Procedure(IRegionManager regions, Formula formula, IWorld world, ILocker locker)
 {
     this.regions = regions;
     this.formula = formula;
     this.world   = world;
     this.locker  = locker;
 }
Exemplo n.º 8
0
 public LeaderAwareTaskRunner(ILocker locker, string lockId, int lockPingTimeoutInSeconds = 30)
 {
     this.locker = locker;
     this.lockId = lockId;
     this.lockPingTimeoutInSeconds = lockPingTimeoutInSeconds;
     lockKeeperId = GenerateLockKeeperId();
 }
Exemplo n.º 9
0
 public Notification(string code, IPackage package, User user, ILocker locker)
 {
     Code    = code;
     Package = package;
     User    = user;
     Locker  = locker;
 }
Exemplo n.º 10
0
 public PlayersRemover(IPlayerSelector playerSelector, ICityRemoverFactory cityRemoverFactory, IScheduler scheduler, ILocker locker)
 {
     this.cityRemoverFactory = cityRemoverFactory;
     this.scheduler          = scheduler;
     this.locker             = locker;
     this.playerSelector     = playerSelector;
 }
Exemplo n.º 11
0
 public LoginCommandsModule(IActionFactory actionFactory,
                            ITribeManager tribeManager,
                            IDbManager dbManager,
                            ILocker locker,
                            IWorld world,
                            Procedure procedure,
                            ICityFactory cityFactory,
                            ILocationStrategyFactory locationStrategyFactory,
                            IBarbarianTribeManager barbarianTribeManager,
                            CallbackProcedure callbackProcedure,
                            IChannel channel,
                            IThemeManager themeManager,
                            IPlayerFactory playerFactory,
                            ILoginHandler loginHandler)
 {
     this.actionFactory           = actionFactory;
     this.tribeManager            = tribeManager;
     this.dbManager               = dbManager;
     this.locker                  = locker;
     this.world                   = world;
     this.procedure               = procedure;
     this.callbackProcedure       = callbackProcedure;
     this.channel                 = channel;
     this.themeManager            = themeManager;
     this.playerFactory           = playerFactory;
     this.loginHandler            = loginHandler;
     this.cityFactory             = cityFactory;
     this.locationStrategyFactory = locationStrategyFactory;
     this.barbarianTribeManager   = barbarianTribeManager;
 }
Exemplo n.º 12
0
        public static async Task LockForDurationAsync(this ILocker locker, object token, Func <Task> method)
        {
            locker.RequestLock(token);
            await method();

            locker.RequestUnlock(token);
        }
Exemplo n.º 13
0
 public LaborMoveActiveAction(Formula formula, Procedure procedure, ILocker locker, IGameObjectLocator gameObjectLocator)
 {
     this.formula           = formula;
     this.procedure         = procedure;
     this.locker            = locker;
     this.gameObjectLocator = gameObjectLocator;
 }
Exemplo n.º 14
0
        private ILocker GetAvailableLocker(Size size)
        {
            ILocker result = null;

            if (size == Size.Small && SmallLockers.Count > 0)
            {
                result = SmallLockers.Dequeue();
            }

            if (result == null && size == Size.Medium && MediumLockers.Count > 0)
            {
                result = MediumLockers.Dequeue();
            }

            if (result == null && size == Size.Large && LargeLockers.Count > 0)
            {
                result = LargeLockers.Dequeue();
            }

            if (result == null && size == Size.XLarge && XLargeLockers.Count > 0)
            {
                result = XLargeLockers.Dequeue();
            }

            if (result == null)
            {
                throw new Exception("All lockers are full");
            }

            return(result);
        }
 public LeaderAwareTaskRunner(ILocker locker, string lockId, int lockPingTimeoutInSeconds = 30)
 {
     this.locker = locker;
     this.lockId = lockId;
     this.lockPingTimeoutInSeconds = lockPingTimeoutInSeconds;
     lockKeeperId = GenerateLockKeeperId();
 }
Exemplo n.º 16
0
 public ResourceSellActiveAction(ILocker locker,
                                 IWorld world,
                                 Formula formula)
 {
     this.locker  = locker;
     this.world   = world;
     this.formula = formula;
 }
Exemplo n.º 17
0
 protected virtual void OnFamilialLockerChanged(ILocker familialLocker, ILocker oldValue)
 {
     if (State == ViewModelState.CriticalOperation || State == ViewModelState.NonCriticalOperation)
     {
         oldValue?.RequestUnlock(_token);
         familialLocker?.RequestLock(_token);
     }
 }
Exemplo n.º 18
0
 protected virtual void OnFormRestrictorChanged(ILocker formRestrictor, ILocker oldValue)
 {
     if (State == ViewModelState.CriticalOperation)
     {
         oldValue?.RequestUnlock(_token);
         formRestrictor?.RequestLock(_token);
     }
 }
Exemplo n.º 19
0
        public static async Task <TReturn> LockForDurationAsync <TReturn>(this ILocker locker, object token, Func <Task <TReturn> > method)
        {
            locker.RequestLock(token);
            var returnObject = await method();

            locker.RequestUnlock(token);
            return(returnObject);
        }
Exemplo n.º 20
0
 public TribeContributeActiveAction(IGameObjectLocator locator,
                                    Formula formula,
                                    ILocker locker)
 {
     this.locator = locator;
     this.formula = formula;
     this.locker  = locker;
 }
Exemplo n.º 21
0
        public static TReturn LockForDuration <TReturn>(this ILocker locker, object token, Func <TReturn> method)
        {
            locker.RequestLock(token);
            var returnObject = method();

            locker.RequestUnlock(token);
            return(returnObject);
        }
Exemplo n.º 22
0
 public BarbarianTribeCommandsLineModule(IBarbarianTribeManager barbarianTribeManager,
                                         ILocker locker,
                                         IWorld world)
 {
     this.barbarianTribeManager = barbarianTribeManager;
     this.locker = locker;
     this.world  = world;
 }
Exemplo n.º 23
0
 public LockingMessageHook([NotNull] ILocker locker)
 {
     if (locker == null)
     {
         throw new ArgumentNullException("locker");
     }
     this.locker = locker;
 }
Exemplo n.º 24
0
 public ActionWorker(Func <ILockable> lockDelegate, ILocation location, ILocker locker, IScheduler scheduler, IDbManager dbManager, RequirementFormula requirementFormula)
 {
     this.locker             = locker;
     this.scheduler          = scheduler;
     this.dbManager          = dbManager;
     this.requirementFormula = requirementFormula;
     Location     = location;
     LockDelegate = lockDelegate;
 }
Exemplo n.º 25
0
 public void Add(ILocker locker) =>
 OperationWrapper(() => {
     if (_lockers.Contains(locker))
     {
         return;
     }
     locker.LockStatusChanged += Locker_LockStatusChanged;
     _lockers.Add(locker);
 });
Exemplo n.º 26
0
 public CityCommandLineModule(Procedure procedure,
                              IActionFactory actionFactory,
                              ILocker locker,
                              IWorld world)
 {
     this.procedure     = procedure;
     this.actionFactory = actionFactory;
     this.locker        = locker;
     this.world         = world;
 }
Exemplo n.º 27
0
        public static ValueTask DisposeAsync(this ILocker locker)
        {
            if (locker is IAsyncDisposable asyncDisposable)
            {
                return(asyncDisposable.DisposeAsync());
            }

            locker.Dispose();

            return(default);
Exemplo n.º 28
0
 public UnitTrainActiveAction(UnitFactory unitFactory,
                              ILocker locker,
                              IWorld world,
                              Formula formula)
 {
     this.unitFactory = unitFactory;
     this.locker      = locker;
     this.world       = world;
     this.formula     = formula;
 }
Exemplo n.º 29
0
 public RetreatChainAction(IActionFactory actionFactory,
                           IWorld world,
                           Procedure procedure,
                           ILocker locker)
 {
     this.actionFactory = actionFactory;
     this.world         = world;
     this.procedure     = procedure;
     this.locker        = locker;
 }
Exemplo n.º 30
0
 public RemoveAuthorizeCacheEventHanlder(
     IStaticCacheManager staticCacheManager,
     ILogger <RemoveAuthorizeCacheEventHanlder> logger,
     ILocker locker
     )
 {
     _staticCacheManager = staticCacheManager ?? throw new ArgumentNullException(nameof(staticCacheManager));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     _locker             = locker ?? throw new ArgumentNullException(nameof(locker));
 }
Exemplo n.º 31
0
 public UnitUpgradeActiveAction(ILocker locker,
                                IWorld world,
                                Formula formula,
                                UnitFactory unitFactory)
 {
     this.locker      = locker;
     this.world       = world;
     this.formula     = formula;
     this.unitFactory = unitFactory;
 }
Exemplo n.º 32
0
        static void TestPayload(ILocker locker, int threadcount)
        {
            Thread[] threads = new Thread[threadcount];

            Payload payload = new Payload(locker);

            for (var i = 0; i < threadcount; i++)
            {
                var thread = new Thread(new ThreadStart(payload.ThreadX));
                threads[i] = thread;
                thread.Start();
            }

            for (var i = 0; i < threadcount; i++)
                threads[i].Join();
        }
Exemplo n.º 33
0
 public DesktopObserver(ILocker locker)
 {
     locker.RegisterObserver(this);
 }
Exemplo n.º 34
0
 protected RestCalculator(ILocker<Guid, Guid> locker, AccountObject accountObject,
     ExternalTransactionObject externalTransactionObject, InternalTransactionObject internalTransactionObject,
     List<Period> periods)
 {
     Locker = locker;
     AccountObject = accountObject;
     ExternalTransactionObject = externalTransactionObject;
     InternalTransactionObject = internalTransactionObject;
     Periods = periods;
     RetryCount = 3;
     LimitLockWaitForRecalc = 100;
     LimitLockWaitForCheck = 10;
 }
Exemplo n.º 35
0
 public PhoneObserver(ILocker locker)
 {
     _locker = locker;
     _locker.RegisterObserver(this);
 }
Exemplo n.º 36
0
 public SocialObserver(ILocker locker)
 {
     locker.RegisterObserver(this);
 }
Exemplo n.º 37
0
 public Payload(ILocker locker)
 {
     _locker = locker;
 }