コード例 #1
0
ファイル: Session.cs プロジェクト: x1766233/DCET
        public ETTask <IResponse> CallWithoutException(IRequest request)
        {
            int rpcId = ++RpcId;
            var tcs   = new ETTaskCompletionSource <IResponse>();

            this.requestCallback[rpcId] = (response) =>
            {
                if (response is ErrorResponse)
                {
                    tcs.SetException(new Exception($"Rpc error: {MongoHelper.ToJson(response)}"));
                    return;
                }

                tcs.SetResult(response);
            };

            request.RpcId = rpcId;
            this.Send(request);
            return(tcs.Task);
        }
コード例 #2
0
		private void OnGUI()
		{
			{
				GUILayout.BeginHorizontal();
				string[] filesArray = this.files.ToArray();
				this.selectedIndex = EditorGUILayout.Popup(this.selectedIndex, filesArray);

				string lastFile = this.fileName;
				this.fileName = this.files[this.selectedIndex];

				if (this.fileName != lastFile)
				{
					this.LoadConfig();
				}

				this.newFileName = EditorGUILayout.TextField("文件名", this.newFileName);

				if (GUILayout.Button("添加"))
				{
					this.ClearConfig();
					
					this.startConfig = new StartConfig();
					startConfig.AddComponent<StartConfigDrawer>();
					this.fileName = this.newFileName;
					this.newFileName = "";
					File.WriteAllText(this.GetFilePath(), MongoHelper.ToJson(this.startConfig));
					
					this.files = this.GetConfigFiles();
					this.selectedIndex = this.files.IndexOf(this.fileName);
					this.LoadConfig();
				}

				if (GUILayout.Button("复制"))
				{
					this.fileName = $"{this.fileName}-copy";
					this.Save();
					this.files = this.GetConfigFiles();
					this.selectedIndex = this.files.IndexOf(this.fileName);
					this.newFileName = "";
				}

				if (GUILayout.Button("重命名"))
				{
					if (this.newFileName == "")
					{
						Log.Debug("请输入新名字!");
					}
					else
					{
						File.Delete(this.GetFilePath());
						this.fileName = this.newFileName;
						this.Save();
						this.files = this.GetConfigFiles();
						this.selectedIndex = this.files.IndexOf(this.fileName);
						this.newFileName = "";
					}
				}

				if (GUILayout.Button("删除"))
				{
					File.Delete(this.GetFilePath());
					this.files = this.GetConfigFiles();
					this.selectedIndex = 0;
					this.newFileName = "";
				}

				GUILayout.EndHorizontal();
			}
			
			scrollPos = GUILayout.BeginScrollView(this.scrollPos, true, true);
			
			startConfig.GetComponent<StartConfigDrawer>()?.OnGUI();
			
			GUILayout.EndScrollView();
			
			GUILayout.BeginHorizontal();
			if (GUILayout.Button("保存"))
			{
				this.Save();
			}
			
			if (GUILayout.Button("启动"))
			{
				string arguments = $"--config={this.fileName}";
				ProcessHelper.Run("App.exe", arguments, "../Bin/");
			}
			if (GUILayout.Button("启动数据库"))
			{
				ProcessHelper.Run("mongod", @"--dbpath=db", "../Database/bin/");
			}
			GUILayout.EndHorizontal();
		}
コード例 #3
0
		private void Save()
		{
			string path = this.GetFilePath();
			File.WriteAllText(path, MongoHelper.ToJson(startConfig));
		}
コード例 #4
0
 public override string ToString()
 {
     return(MongoHelper.ToJson(this));
 }