void DrawBodyMenu()
 {
     GUILayout.BeginHorizontal();
     {
         GUILayout.Label(_loadedPostmanFileName);
         if (GUILayout.Button("Import"))
         {
             string fileFullpath = EditorUtility.OpenFilePanel("CloudBread", "", "");
             if (!string.IsNullOrEmpty(fileFullpath))
             {
                 string json = CBToolEditor.ReadFile(fileFullpath);
                 try
                 {
                     Postman postman = JsonUtility.FromJson <Postman>(json);
                     _postman = postman;
                     _loadedPostmanFileFullPath = fileFullpath;
                     _loadedPostmanFileName     = System.IO.Path.GetFileName(_loadedPostmanFileFullPath);
                 }
                 catch (System.Exception e_)
                 {
                     Debug.LogError(e_);
                 }
             }
         }
     }
     GUILayout.EndHorizontal();
 }
        /// <summary>
        /// json에 있는 element를 string변수로 갖는 클래스나 구조체형태의 텍스트 생성.
        /// </summary>
        /// <param name="structName_">클래스/구조체 이름.</param>
        /// <param name="structType_">class or struct.</param>
        /// <param name="jsonText_">json Text.</param>
        /// <returns></returns>
        static string MakeStructFromJson(string structName_, string structType_, string jsonText_)
        {
            structName_ = structName_.Replace(" ", string.Empty);
            if (structName_.Contains("-"))
            {
                structName_ = structName_.Replace("-", "_");
            }

            string[] element = ExtractElementFromJson(jsonText_);
            if (null == element)
            {
                return(null);
            }

            string variable = "";

            for (int i = 0; i < element.Length; ++i)
            {
                variable += string.Format("            [SerializeField]\n            public string {0};\n", element[i]);
            }
            string body = CBToolEditor.GetClassTextFile("Template.Class");

            return(string.Format(body, structType_, structName_, variable));
        }
        private void DrawBodyRight()
        {
            GUILayout.BeginVertical();
            {
                if (null != _postman && null != _selectedRequest)
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Box(_selectedRequest.method, _boxStyle);
                        EditorGUILayout.TextArea(_requestFullURL, _boxStyle, GUILayout.Width(400));

                        _useMyServer = GUILayout.Toggle(_useMyServer, "Use CB.Setting Server");

                        if (GUILayout.Button("Send"))
                        {
                            ResetBodyRight();
                            RequestPostmanTest(_requestFullURL, _requestPostData, _requestHeaders, delegate(string text_)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(text_))
                                    {
                                        _receiveJson   = text_;
                                        _receiveStruct = GenerateStruct(text_, "Receive");
                                    }
                                }
                                catch (System.Exception e_)
                                {
                                    Debug.Log(e_);
                                }
                            });
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginVertical();
                    {
                        _selectRequestMenuIndex = GUILayout.SelectionGrid(_selectRequestMenuIndex, _requestMenu, 2);

                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Box(_requestMenu[_selectRequestMenuIndex], _boxStyle);

                            if (0 == _selectRequestMenuIndex && GUILayout.Button("struct Print", GUILayout.Width(100)))
                            {
                                string genStructStr = GenerateStruct(_requestPostData, "Post");
                                Debug.Log(genStructStr);
                            }

                            if (0 == _selectRequestMenuIndex && GUILayout.Button("Decrypt Print", GUILayout.Width(100)))
                            {
                                string decryptStr = CBAuthentication.AES_decrypt(CBTool.GetElementValueFromJson(CloudBread._aseEncryptDefine, _requestPostData));
                                Debug.Log(decryptStr);
                            }

                            if (0 == _selectRequestMenuIndex && GUILayout.Button("Generate Protocol", GUILayout.Width(150)))
                            {
                                string url           = _selectedRequest.url.Substring(_selectedRequest.url.IndexOf("api/"));
                                string postStruct    = GenerateStruct(_requestPostData, "Post");
                                string receiveStruct = GenerateStruct(_requestPostData, "Receive");

                                // postData가 있는 경우/없는경우.
                                RequestPostmanTest(_requestFullURL, _requestPostData, _requestHeaders, delegate(string text_)
                                {
                                    try
                                    {
                                        if (!string.IsNullOrEmpty(text_))
                                        {
                                            string body   = CBToolEditor.GetClassTextFile("Template.CBClass");
                                            receiveStruct = GenerateStruct(text_, "Receive");

                                            string fileText = string.Format(body, _selectRequestName, url, postStruct, receiveStruct, string.IsNullOrEmpty(postStruct) ? postStruct : "Post postData_", null == receiveStruct ? null : text_.StartsWith("[") ? "<Receive[]>" : "<Receive>", string.IsNullOrEmpty(postStruct) ? "null" : "JsonUtility.ToJson(postData_)");
                                            string fileName = string.Format("/CloudBread/Protocols/CloudBread.{0}.{1}.cs", _selectedRequest.method, _selectRequestName);

                                            CBToolEditor.SaveTextFileInProject(fileName, fileText);
                                            AssetDatabase.Refresh();
                                        }
                                    }
                                    catch (System.Exception e_)
                                    {
                                        Debug.Log(e_);
                                    }
                                });
                            }
                        }
                        GUILayout.EndHorizontal();

                        _classBodyScroll_rquestDataPos = GUILayout.BeginScrollView(_classBodyScroll_rquestDataPos, GUILayout.Height(100));
                        {
                            if (0 == _selectRequestMenuIndex)
                            {
                                _requestPostData = EditorGUILayout.TextArea(_requestPostData);
                            }
                            else
                            {
                                _requestHeaders = EditorGUILayout.TextArea(_requestHeaders);
                            }
                        }
                        GUILayout.EndScrollView();
                    }
                    GUILayout.EndVertical();
                }

                if (!string.IsNullOrEmpty(_receiveJson))
                {
                    _classBodyScroll_receiveJsonPos = GUILayout.BeginScrollView(_classBodyScroll_receiveJsonPos, GUILayout.Height(position.height * 0.2f));
                    {
                        EditorGUILayout.TextArea(_receiveJson);
                    }
                    GUILayout.EndScrollView();
                }

                if (!string.IsNullOrEmpty(_receiveStruct))
                {
                    _classBodyScroll_receiveStructPos = GUILayout.BeginScrollView(_classBodyScroll_receiveStructPos);
                    {
                        EditorGUILayout.TextArea(_receiveStruct);
                    }
                    GUILayout.EndScrollView();
                }
            }
            GUILayout.EndVertical();
        }