示例#1
0
        public IDisposable StartTimer(float seconds, Action onCompleteAction)
        {
            var remainTime = 0f;

            _onChecking       = true;
            _onCompleteAction = onCompleteAction;

            _disposable.DisposeSafe();
            _disposable = Observable
                          .Timer(TimeSpan.Zero, TimeSpan.FromSeconds(UnityEngine.Time.deltaTime))
                          .TimeInterval()
                          .Subscribe(Next);

            return(_disposable);

            // 시간 체크 처리.
            void Next(TimeInterval <long> interval)
            {
                remainTime += (float)interval.Interval.TotalSeconds;
                if (!(remainTime >= seconds))
                {
                    return;
                }
                _onChecking = false;
                _onCompleteAction?.Invoke();
                _disposable.DisposeSafe();
            }
        }
        /// <summary>
        /// Reset puzzle data.
        /// </summary>
        public void InitializePuzzle()
        {
            _puzzleMovementState = PuzzleMovementState.None;
            _movementDisposable.DisposeSafe();
            gameObject.SetActive(true);
            specialObj.Foreach(x => x.SetActive(false));
            _movePositions.Clear();
            var targetPos = _gamePageView.GetLandElement(PuzzleModel.PositionModel).transform.position;

            transform.position = targetPos;
            ChangeShape(PuzzleModel);
        }
示例#3
0
        public static async Task <EventStoreInstance> StartAsync()
        {
            var installedSoftware = await InstallHelper.InstallAsync(SoftwareDescription).ConfigureAwait(false);

            var tcpPort             = TcpHelper.GetFreePort();
            var httpPort            = TcpHelper.GetFreePort();
            var connectionStringUri = new Uri($"tcp://*****:*****@{IPAddress.Loopback}:{tcpPort}");
            var exePath             = Path.Combine(installedSoftware.InstallPath, "EventStore.ClusterNode.exe");

            IDisposable processDisposable = null;

            try
            {
                processDisposable = ProcessHelper.StartExe(
                    exePath,
                    "'admin' user added to $users",
                    "--mem-db=True",
                    "--cluster-size=1",
                    $"--ext-tcp-port={tcpPort}",
                    $"--ext-http-port={httpPort}");

                var connectionSettings = ConnectionSettings.Create()
                                         .EnableVerboseLogging()
                                         .KeepReconnecting()
                                         .SetDefaultUserCredentials(new UserCredentials("admin", "changeit"))
                                         .Build();
                using (var eventStoreConnection = EventStoreConnection.Create(connectionSettings, connectionStringUri))
                {
                    var start = DateTimeOffset.Now;
                    while (true)
                    {
                        if (start + TimeSpan.FromSeconds(10) < DateTimeOffset.Now)
                        {
                            throw new Exception("Failed to connect to EventStore");
                        }

                        try
                        {
                            await eventStoreConnection.ConnectAsync().ConfigureAwait(false);

                            break;
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Failed to connect, retrying");
                        }
                    }
                }
            }
            catch (Exception)
            {
                processDisposable.DisposeSafe("Failed to dispose EventStore process");
                throw;
            }

            return(new EventStoreInstance(
                       connectionStringUri,
                       processDisposable));
        }
示例#4
0
        public static async Task <ElasticsearchInstance> StartAsync()
        {
            if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("JAVA_HOME")))
            {
                throw new InvalidOperationException("The 'JAVA_HOME' environment variable is required");
            }

            var installedSoftware = await InstallHelper.InstallAsync(SoftwareDescription).ConfigureAwait(false);

            var version     = SoftwareDescription.Version;
            var installPath = Path.Combine(installedSoftware.InstallPath, $"elasticsearch-{version.Major}.{version.Minor}.{version.Build}");

            var tcpPort  = TcpHelper.GetFreePort();
            var exePath  = Path.Combine(installPath, "bin", "elasticsearch.bat");
            var nodeName = $"node-{Guid.NewGuid().ToString("N")}";

            var settings = new Dictionary <string, string>
            {
                { "http.port", tcpPort.ToString() },
                { "node.name", nodeName },
                { "index.number_of_shards", "1" },
                { "index.number_of_replicas", "0" },
                { "gateway.expected_nodes", "1" },
                { "discovery.zen.ping.multicast.enabled", "false" },
                { "cluster.routing.allocation.disk.threshold_enabled", "false" }
            };
            var configFilePath = Path.Combine(installPath, "config", "elasticsearch.yml");

            if (!File.Exists(configFilePath))
            {
                throw new ApplicationException($"Could not find config file at '{configFilePath}'");
            }
            File.WriteAllLines(configFilePath, settings.Select(kv => $"{kv.Key}: {kv.Value}"));

            IDisposable processDisposable = null;

            try
            {
                processDisposable = ProcessHelper.StartExe(exePath,
                                                           $"[${nodeName}] started");

                var elasticsearchInstance = new ElasticsearchInstance(
                    new Uri($"http://127.0.0.1:{tcpPort}"),
                    processDisposable);

                await elasticsearchInstance.WaitForGeenStateAsync().ConfigureAwait(false);

                await elasticsearchInstance.DeleteEverythingAsync().ConfigureAwait(false);

                return(elasticsearchInstance);
            }
            catch (Exception)
            {
                processDisposable.DisposeSafe("Failed to dispose Elasticsearch process");
                throw;
            }
        }
示例#5
0
 protected void Init()
 {
     Errors.Clear();
     Results.Clear();
     Error   = null;
     Result  = default(T);
     Counter = 0;
     Subscription.DisposeSafe();
     Subscriptions.DisposeSafe();
     Subscriptions = new CompositeDisposable();
 }
示例#6
0
 public void OneTimeTearDown()
 {
     _backgroundJobServer.DisposeSafe("Hangfire backgroung job server");
     _webApp.DisposeSafe("Web APP");
     _msSqlDatabase.DisposeSafe("MSSQL database");
 }
示例#7
0
 public void Clear()
 {
     TimeCheckDisposable.DisposeSafe();
     TimeCheckEvent.CompleteEvent?.Invoke();
 }
示例#8
0
 public void TearDown()
 {
     _eventStore.DisposeSafe("EventStore shutdown");
 }