public void RunTestDefinition(JsonDrivenTestCase testCase) { var test = testCase.Test; CheckServerRequirements(test); var connectionMap = new ConcurrentDictionary <string, IConnection>(); var eventCapturer = new EventCapturer(); var tasks = new ConcurrentDictionary <string, Task>(); JsonDrivenHelper.EnsureAllFieldsAreValid(test, Schema.AllFields); var isUnit = EnsureStyle(test) == Schema.Styles.unit; var(connectionPool, failPoint, cluster, eventsFilter) = SetupConnectionData(test, eventCapturer, isUnit); using var disposableBundle = new DisposableBundle(failPoint, connectionPool, cluster); ResetConnectionId(); var operations = testCase.Test.GetValue(Schema.operations).AsBsonArray; var async = testCase.Test.GetValue(Schema.async).ToBoolean(); Exception exception = null; foreach (var operation in operations.Cast <BsonDocument>()) { ExecuteOperation( operation, eventCapturer, connectionMap, tasks, connectionPool, async, out exception); if (exception != null) { break; } } #if WINDOWS AssertError(test, exception); AssertEvents(test, eventCapturer, eventsFilter); #endif }
public async Task BuildBase(BaseDescription baseDescription) { var bundle = await AssetBundle.LoadFromFileAsync(Path.Combine(Constants.AssetBundlesPath, baseDescription.bundleName)); using (var disposable = new DisposableBundle(bundle)) { var sceneName = Path.GetFileNameWithoutExtension(disposable.GetAllScenePaths()[0]); await Scenes.LoadBaseScene(sceneName); SetupBaseLayout(baseDescription); SetupUpgrades(baseDescription); SetupAdditionalData(baseDescription); if (baseDescription.isAttacking) { SpawnPlayerSpaceship(); } onBaseBuilt.Raise(baseDescription); } }
RectTransform GenerateScrollContent <T>(List <T> dataList, int mainPivotVectorValue) { if (_currentDisposable == null) { _currentDisposable = new DisposableBundle(); } var rootTransform = GetComponent <RectTransform>(); var scrollRect = CreateScrollRect(rootTransform); var scrollRectTransform = scrollRect.GetComponent <RectTransform>(); var viewport = CreateViewport(scrollRectTransform); var content = CreateContent(viewport, _scrollType, _arrangementType, dataList, mainPivotVectorValue, _columnLimit); scrollRect.content = content; scrollRect.viewport = viewport; SetScrollbar(scrollRect); _currentDisposable.Add(new GameObjectDisposable(content.gameObject)); _currentDisposable.Add(new GameObjectDisposable(viewport.gameObject)); _currentDisposable.Add(new GameObjectDisposable(scrollRect.gameObject)); return(content); }
List <IScrollableCell <T> > GenerateCellList <T>(GameObject cellPrefab, List <T> dataList, Transform cellRoot, out IDisposable cellDisposable) { DisposableBundle disposable = new DisposableBundle(); var rootTransform = GetComponent <RectTransform>(); int cellNum = 0; switch (_scrollType) { case ScrollType.Horizontal: cellNum = (Mathf.CeilToInt(rootTransform.rect.width / _cellSize.x) + 1) * _columnLimit; break; case ScrollType.Vertical: cellNum = (Mathf.CeilToInt(rootTransform.rect.height / _cellSize.y) + 1) * _columnLimit; break; } List <IScrollableCell <T> > result = new List <IScrollableCell <T> >(); for (int i = 0; i < cellNum; i++) { if (i >= dataList.Count) { continue; } var cellObject = GameObject.Instantiate(cellPrefab); IScrollableCell <T> cell = cellObject.GetComponent <IScrollableCell <T> >(); cell.SetValue(dataList[i]); Transform cellTransform = cell.transform; cellTransform.SetParent(cellRoot); cellTransform.localScale = Vector3.one; cellTransform.rotation = cellRoot.rotation; result.Add(cell); disposable.Add(new GameObjectDisposable(cellObject)); } cellDisposable = disposable; return(result); }
//private void _saveSelectedAsEmfToolStripMenuItem_Click(object sender, EventArgs e) { // if (_currentEditorCanvas == null) { // return; // } // var dialog = new SaveFileDialog(); // dialog.RestoreDirectory = true; // dialog.ShowHelp = true; // dialog.Filter = "EMF Files(*.emf)|*.emf"; // if (dialog.ShowDialog(this) == DialogResult.OK) { // _currentEditorCanvas.SaveSelectedAsEmf(dialog.FileName); // } // dialog.Dispose(); //} //private void _saveSelectedAsPngToolStripMenuItem_Click(object sender, EventArgs e) { // if (_currentEditorCanvas == null) { // return; // } // var dialog = new SaveFileDialog(); // dialog.RestoreDirectory = true; // dialog.ShowHelp = true; // dialog.Filter = "PNG Files(*.png)|*.png"; // if (dialog.ShowDialog(this) == DialogResult.OK) { // _currentEditorCanvas.SaveSelectedAsPng(dialog.FileName); // } // dialog.Dispose(); //} private void _sendMailToolStripMenuItem_Click(object sender, EventArgs e) { try { using (var dialog = new SendMailForm()) { dialog.Font = _theme.CaptionFont; dialog.Subject = _PageContent.MemoInfo.Title; dialog.From = _app.WindowSettings.MailFrom; dialog.To = _app.WindowSettings.MailTo; dialog.SmtpServer = _app.WindowSettings.SmtpServer; dialog.SmtpPort = _app.WindowSettings.SmtpPort; dialog.SmtpEnableAuth = _app.WindowSettings.SmtpEnableAuth; dialog.SmtpUserName = _app.WindowSettings.SmtpUserName; dialog.SmtpPassword = CryptoUtil.DecryptSmtpPassword(_app.WindowSettings.SmtpPassword); dialog.SmtpEnableSsl = _app.WindowSettings.SmtpEnableSsl; if (dialog.ShowDialog(this) == DialogResult.OK) { var client = new SmtpClient(dialog.SmtpServer, dialog.SmtpPort); if (dialog.SmtpEnableAuth) { client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(dialog.SmtpUserName, dialog.SmtpPassword); } else { client.UseDefaultCredentials = true; } client.EnableSsl = dialog.SmtpEnableSsl; client.Timeout = 100000; client.SendCompleted += HandleSmtpClientSendComplete; var msg = new MailMessage(dialog.From, dialog.To); /// HandleSmtpClientSendCompleteでDispose()される msg.BodyEncoding = Encoding.UTF8; msg.Subject = dialog.Subject; switch (dialog.Body) { case SendMailForm.BodyKind.Text: msg.Body = MemoTextUtil.GetText(_currentEditorCanvas, null, false); client.SendAsync(msg, msg); break; case SendMailForm.BodyKind.Image: using (var img = _currentEditorCanvas.CreateBitmap(1f, Size.Empty)) { var conv = new ImageConverter(); var bytes = (byte[])conv.ConvertTo(img, typeof(byte[])); var mem = new MemoryStream(bytes); var args = new DisposableBundle(new IDisposable[] { msg, mem, }); msg.Attachments.Add(new Attachment(mem, "note.png")); client.SendAsync(msg, args); } break; case SendMailForm.BodyKind.TextAndImage: msg.Body = MemoTextUtil.GetText(_currentEditorCanvas, null, false); using (var img = _currentEditorCanvas.CreateBitmap(1f, Size.Empty)) { var conv = new ImageConverter(); var bytes = (byte[])conv.ConvertTo(img, typeof(byte[])); var mem = new MemoryStream(bytes); var args = new DisposableBundle(new IDisposable[] { msg, mem, }); msg.Attachments.Add(new Attachment(mem, "note.png")); client.SendAsync(msg, args); } break; } _app.WindowSettings.MailFrom = dialog.From; _app.WindowSettings.MailTo = dialog.To; _app.WindowSettings.SmtpServer = dialog.SmtpServer; _app.WindowSettings.SmtpPort = dialog.SmtpPort; _app.WindowSettings.SmtpEnableAuth = dialog.SmtpEnableAuth; _app.WindowSettings.SmtpUserName = dialog.SmtpUserName; _app.WindowSettings.SmtpPassword = CryptoUtil.EncryptSmtpPassword(dialog.SmtpPassword); _app.WindowSettings.SmtpEnableSsl = dialog.SmtpEnableSsl; } } } catch (Exception ex) { Logger.Warn("Can't send mail.", ex); MessageBox.Show( this, "メールの送信に失敗しました。" + Environment.NewLine + ex.Message, "メールの送信エラー", MessageBoxButtons.OK, MessageBoxIcon.Error ); } }
public IDisposable SetDatas <T>(IEnumerable <T> datas) { // Dispose before scroll if (_currentDisposable != null) { _currentDisposable.Dispose(); _currentDisposable = null; } ; _currentDisposable = new DisposableBundle(); if (_cellPrefab == null) { Debug.LogError("Prefab not found."); return(_currentDisposable); } if (_cellPrefab.GetComponent <IScrollableCell <T> >() == null) { Debug.LogError("No corresponding type of component is does not exist to this Prefab."); return(_currentDisposable); } int mainPivotVectorValue; int subPivotVectorValue; float baseCellPosition; switch (_scrollType) { case ScrollType.Horizontal: mainPivotVectorValue = _arrangementType == ArrangementType.LeftDownToRightUp || _arrangementType == ArrangementType.LeftUpToRightDown ? 1 : -1; subPivotVectorValue = _arrangementType == ArrangementType.LeftDownToRightUp || _arrangementType == ArrangementType.RightDownToLeftUp ? 1 : -1; break; case ScrollType.Vertical: mainPivotVectorValue = _arrangementType == ArrangementType.LeftDownToRightUp || _arrangementType == ArrangementType.RightDownToLeftUp ? 1 : -1; subPivotVectorValue = _arrangementType == ArrangementType.LeftDownToRightUp || _arrangementType == ArrangementType.LeftUpToRightDown ? 1 : -1; break; default: throw new Exception(string.Format("ScrollType <{0}> does not exist.", _scrollType)); } baseCellPosition = GetScrollTypeValue(_scrollType, _cellSize) * mainPivotVectorValue; List <T> dataList = datas.ToList(); // Generate Scroll items IDisposable cellDisposable; var cellRoot = GenerateScrollContent(dataList, mainPivotVectorValue); var cellList = GenerateCellList(_cellPrefab, dataList, cellRoot, out cellDisposable); _currentDisposable.Add(cellDisposable); // Move to init position cellList.ForEach(cell => UpdateCellPosition(cell, cell.GetValue(), dataList, mainPivotVectorValue, subPivotVectorValue, baseCellPosition)); // Start scroll coroutine var coroutine = StartCoroutine(UpdateCells(cellRoot, dataList, cellList, _scrollType, mainPivotVectorValue, subPivotVectorValue, baseCellPosition)); _currentDisposable.Add(new CoroutineDisposable(coroutine, this)); return(_currentDisposable); }