Inheritance: MonoBehaviour
Esempio n. 1
0
        public static List <T> GetReadJsonFileData(string fullFileName, ref ReturnOutput returnOutput)
        {
            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";

            List <T> list     = new List <T>();
            string   fullPath = fullFileName;

            try
            {
                using (StreamReader fi = File.OpenText(fullPath))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    T customer = (T)serializer.Deserialize(fi, typeof(T));
                    list.Add(customer);
                }
            }
            catch (Exception ex)
            {
                string result = ex.Message.ToString();
                HelperText.CreateTextFile("GetReadAllJsonData", result);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = result;
            }
            return(list);
        }
Esempio n. 2
0
        public static List <T> ReadJsonAsObjectListAllData(string jsonFileName, ref ReturnOutput returnOutput)
        {
            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";

            List <T> resultList = null;

            try
            {
                string fullPath = filePath + jsonFileName;

                var jsonText = File.ReadAllText(fullPath, Encoding.GetEncoding("Windows-1254"));
                resultList = JsonConvert.DeserializeObject <List <T> >(jsonText);
            }
            catch (Exception ex)
            {
                string result = ex.Message;
                HelperText.CreateTextFile("ReadJsonAsObjectListAllData", result);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = result;
            }

            return(resultList);
        }
Esempio n. 3
0
        private double GetDragBtuttonElLeft(IWebElement dragBtuttonEl)
        {
            string drBtLeft = dragBtuttonEl.GetAttribute("style");
            string leftstr  = HelperText.getMiddleStr(drBtLeft, "left:", "px", 0);

            return(leftstr.ToDouble(0));
        }
        protected void GetCookiesAndSaveToDb(HyAccount account)
        {
            string str;

            Console.Title = string.Concat("取cookie ", Console.Title);
            string cookiesStr = SelementHelper.GetCookiesSmallStr(this.HySeleniumMgr.WebDriver);

            if ((cookiesStr != null ? cookiesStr.IndexOf("udb_biztoken") == -1 : false))
            {
                account.WebCookie = account.WebCookie ?? cookiesStr;
            }
            else
            {
                account.LoginSucceed = true;
                account.Uid          = HelperText.getMiddleStr(string.Concat(cookiesStr, ";"), "yyuid=", ";", 0).ToLong((long)0);
                string middleStr = HelperText.getMiddleStr(string.Concat(cookiesStr, ";"), "guid=", ";", 0);
                if (middleStr != null)
                {
                    str = middleStr.Trim();
                }
                else
                {
                    str = null;
                }
                account.Guid      = str ?? account.Guid;
                account.WebCookie = cookiesStr ?? account.WebCookie;
                XTrace.WriteLine(string.Concat(account.UserName, " ", account.UserPass, " 有登录成功状态"));
            }
            account.Save();
        }
Esempio n. 5
0
    IEnumerator ShowTutorial(HelperText tutorial)
    {
        ToggleCanvasGroup();
        string[] vs = GetHelperText(tutorial);
        foreach (string s in vs)
        {
            tempTypeSpeed   = typeSpeed;
            tempSentenceEnd = sentenceEnd;
            tempSpace       = space;
            isJuggling      = true;
            i = 0;
            StartCoroutine("juggleSprites");
            StartCoroutine("WriteText", s);
            yield return(new WaitUntil(() => !isWriting));

            isJuggling = false;
            if (!Application.isEditor)
            {
                yield return(new WaitUntil(() => !Input.touchCount.Equals(0)));
            }
            else
            {
                yield return(new WaitUntil(() => Input.GetMouseButtonDown(0)));
            }
        }
        ToggleCanvasGroup();
        done = true;
    }
Esempio n. 6
0
        public static List <T> ReadJsonAsObjectList(string jsonFilePath)
        {
            List <T> resultList = new List <T>();

            try
            {
                string fullPath = filePath + jsonFilePath;

                DirectoryInfo di = new DirectoryInfo(fullPath);
                foreach (var item in di.GetFiles())
                {
                    var     fileData = File.ReadAllText(item.FullName);
                    JObject o1       = JObject.Parse(fileData);

                    var result = o1.ToObject <T>();
                    resultList.Add(result);
                    //result = new List<T>((IEnumerable<T>)o1);
                }
            }
            catch (Exception ex)
            {
                string result = ex.Message;
                HelperText.CreateTextFile("ReadJsonAsObjectList", result);
            }

            return(resultList);
        }
Esempio n. 7
0
        public static T ReadJsonAsObject(string jsonFilePath, ref ReturnOutput returnOutput)
        {
            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";

            try
            {
                string fullPath = filePath + typeof(T).Name + "\\" + jsonFilePath + ".json";

                if (File.Exists(fullPath))
                {
                    string jsonData   = File.ReadAllText(fullPath);
                    T      resultData = JsonConvert.DeserializeObject <T>(jsonData);

                    return(resultData);
                }

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = "File Not Exist";
            }
            catch (Exception ex)
            {
                string result = ex.Message;
                HelperText.CreateTextFile("ReadJsonAsFile", result);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = result;
            }

            return(default(T));
        }
 private void Awake()
 {
     textControl = GetComponent <TextMeshProUGUI>();
     fader       = GetComponent <Fader>();
     if (instance == null)
     {
         instance = this;
     }
 }
Esempio n. 9
0
        public static T UpdateJsonData(T entity, ref ReturnOutput returnOutput, string extensionPathName)
        {
            string errResult = string.Empty;

            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";

            Type t = entity.GetType();

            PropertyInfo prop  = t.GetProperty("Id");
            object       retId = prop.GetValue(entity);

            T data = entity;

            try
            {
                string fullPath = filePath + typeof(T).Name + "\\" + retId.ToString() + ".json";

                if (!string.IsNullOrEmpty(extensionPathName))
                {
                    fullPath = filePath + typeof(T).Name + "\\" + extensionPathName + "\\" + retId.ToString() + ".json";
                }


                if (File.Exists(fullPath))
                {
                    File.Delete(fullPath);

                    string json = JsonConvert.SerializeObject(entity, Formatting.Indented);

                    using (StreamWriter file = File.CreateText(fullPath))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Serialize(file, entity);
                    }
                }
                else
                {
                    errResult = "İşlem yapılacak dosya yok. " + fullPath;
                    HelperText.CreateTextFile("UpdateJsonData", errResult);
                    returnOutput.ErrorCode    = "1002";
                    returnOutput.ErrorMessage = errResult;
                }
            }
            catch (Exception ex)
            {
                errResult = ex.Message.ToString();
                HelperText.CreateTextFile("UpdateJsonData", errResult);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = errResult;
            }

            return(data);
        }
Esempio n. 10
0
        // Write Json
        // https://www.newtonsoft.com/json/help/html/SerializeWithJsonSerializerToFile.htm
        public static ReturnOutput WriteJson(T entity, string extensionPathName = "")
        {
            ReturnOutput returnOutput = new ReturnOutput();

            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";

            try
            {
                int    fileId = 0;
                string sourceFolderPathName = entity.GetType().Name;
                string json = JsonConvert.SerializeObject(entity, Formatting.Indented);

                string fullPath = filePath + sourceFolderPathName;

                if (!string.IsNullOrEmpty(extensionPathName))
                {
                    fullPath             = fullPath + "\\" + extensionPathName;
                    sourceFolderPathName = sourceFolderPathName + "\\" + extensionPathName;
                }

                if (!Directory.Exists(fullPath))
                {
                    Directory.CreateDirectory(fullPath);
                }

                fullPath = fullPath + "\\" + JsonCoreServices.GetNewFileName(filePath, sourceFolderPathName, ref fileId);

                Type t = entity.GetType();

                PropertyInfo prop = t.GetProperty("Id");

                prop.SetValue(entity, fileId, null);



                using (StreamWriter file = File.CreateText(fullPath))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, entity);
                }
            }
            catch (Exception ex)
            {
                string result = ex.Message.ToString();
                HelperText.CreateTextFile("WriteJson", result);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = result;
            }

            return(returnOutput);
        }
Esempio n. 11
0
    // Update the UI box with the string stored in the queue
    // Pops top item off the top and makes the next item in the queue the top
    void UpdateText()
    {
        HelperText currentItem = helperText.Dequeue();

        // Update values
        bodyObject.text = currentItem.Body;

        // Update title if new title
        if (currentItem.Title != "")
        {
            headObject.text = currentItem.Title;
        }
    }
Esempio n. 12
0
        /// <summary>
        ///  // Read All Json File
        //https://stackoverflow.com/questions/35431900/get-all-json-files-from-a-folder-and-then-serialize-in-a-single-json-file-usin
        /// </summary>
        /// <param name="entity">GetAllJsonData(T entity)</param>
        /// <returns>List<T></returns>
        public static List <T> GetReadAllJsonData(string folderName, ref ReturnOutput returnOutput)
        {
            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";

            List <T> list     = new List <T>();
            string   fullPath = filePath + folderName;

            DirectoryInfo di = new DirectoryInfo(fullPath);

            try
            {
                if (di.GetFiles().Length > 0)
                {
                    foreach (var file in di.GetFiles())
                    {
                        using (StreamReader fi = File.OpenText(file.FullName))
                        {
                            JsonSerializer serializer = new JsonSerializer();
                            T customer = (T)serializer.Deserialize(fi, typeof(T));
                            list.Add(customer);
                        }
                    }
                }
                else
                {
                    using (StreamReader fi = File.OpenText(fullPath))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        T customer = (T)serializer.Deserialize(fi, typeof(T));
                        list.Add(customer);
                    }
                }
            }
            catch (Exception ex)
            {
                string result = ex.Message.ToString();
                HelperText.CreateTextFile("GetReadAllJsonData", result);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = result;
            }
            //finally
            //{
            //    return list;
            //}

            return(list);
        }
Esempio n. 13
0
        public static List <T> GetReadAllJsonData(string folderName, int pageCount, int showDataCount, string sortName, ref ReturnOutput returnOutput)
        {
            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";

            List <T> list     = new List <T>();
            string   fullPath = filePath + folderName;

            DirectoryInfo di = new DirectoryInfo(fullPath);

            int fileStartCount  = ((pageCount * showDataCount) - showDataCount) + 1; // 11
            int fileFinishCount = pageCount * showDataCount;                         //

            if (fileFinishCount > di.GetFiles().Length)
            {
                fileFinishCount = di.GetFiles().Length;
            }

            //var data = di.GetFiles().OrderBy(s => s.FullName);

            //Where(s => s.FullName == fileStartCount.ToString() + ".json");

            try
            {
                foreach (var file in di.GetFiles())
                {
                    using (StreamReader fi = File.OpenText(file.FullName))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        T customer = (T)serializer.Deserialize(fi, typeof(T));
                        list.Add(customer);
                    }
                }
            }
            catch (Exception ex)
            {
                string result = ex.Message.ToString();
                HelperText.CreateTextFile("GetReadAllJsonData", result);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = result;
            }
            //finally
            //{
            //    return list;
            //}

            return(list);
        }
Esempio n. 14
0
    void Initialise()
    {
        // Create queue object
        helperText = new Queue <HelperText>();

        // Cycle through the tutorial text list, adding each item to the queue
        foreach (string text in tutorialText)
        {
            // create struct
            HelperText newItem = new HelperText("", text);

            helperText.Enqueue(newItem);
        }

        // Update text, starting showing preloaded tutorial text
        UpdateText();
    }
Esempio n. 15
0
    public string[] GetHelperText(HelperText helper)
    {
        switch (helper)
        {
        case HelperText.ALL_CHARACTERS_COLLECTED:
            return(allCharactersCollected);

        case HelperText.FIRST_LAUNCH:
            return(firstLaunch);

        case HelperText.FIRST_MINIGAME:
            return(firstMinigame);

        default:
            return(error);
        }
    }
Esempio n. 16
0
 protected void ZHInitCaoZuo()
 {
     if (XmlConfig <SeleniumConfig> .Current.XiuGaiNick)
     {
         this.ToGeRenZhongXin(this.HySeleniumMgr.WebDriver);
         string nick = HelperText.RdMaJia(5, false);
         this.OneByOneTaskTryErrF(new Func <IWebDriver, string, bool>(this.HySeleniumMgr.XiuGaiNick), this.HySeleniumMgr, nick);
     }
     if (XmlConfig <SeleniumConfig> .Current.XiuGaiTouXiang)
     {
         this.ToGeRenZhongXin(this.HySeleniumMgr.WebDriver);
         FileInfo pic = ModifyHead.GetHeadRandomPath();
         if (pic != null)
         {
             this.OneByOneTaskTryErrF(new Func <IWebDriver, string, bool>(this.HySeleniumMgr.XiuGaiTouXiang), this.HySeleniumMgr, pic.FullName);
         }
     }
 }
Esempio n. 17
0
        public static T UpdateJsonData(string jsonFilePath, T entity, ref ReturnOutput returnOutput)
        {
            string errResult = string.Empty;

            T data = entity;

            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";

            try
            {
                string fullPath = filePath + jsonFilePath;
                if (File.Exists(fullPath))
                {
                    File.Delete(fullPath);

                    string json = JsonConvert.SerializeObject(entity, Formatting.Indented);

                    using (StreamWriter file = File.CreateText(fullPath))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Serialize(file, entity);
                    }
                }
                else
                {
                    errResult = "İşlem yapılacak dosya yok. " + fullPath;
                    HelperText.CreateTextFile("UpdateJsonData", errResult);
                    returnOutput.ErrorCode    = "1002";
                    returnOutput.ErrorMessage = errResult;
                }
            }
            catch (Exception ex)
            {
                errResult = ex.Message.ToString();
                HelperText.CreateTextFile("UpdateJsonData", errResult);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = errResult;
            }

            return(data);
        }
Esempio n. 18
0
        public static string ReadJsonAsFile(string jsonFilePath)
        {
            string fullPath = filePath + jsonFilePath;
            string result   = "";

            try
            {
                if (File.Exists(fullPath))
                {
                    result = File.ReadAllText(fullPath);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message.ToString();
                HelperText.CreateTextFile("ReadJsonAsFile", result);
            }

            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// Json dosya silme işlemi burad File SystemObject ile yapılır.
        /// </summary>
        /// <param name="DeleteJsonFile"></param>
        /// <returns>string jsonFilePath</returns>
        public static ReturnOutput DeleteJsonFile(string fullPath)
        {
            ReturnOutput returnOutput = new ReturnOutput();

            returnOutput.ErrorCode    = "1000";
            returnOutput.ErrorMessage = "Ok";
            try
            {
                File.Delete(fullPath);
            }
            catch (Exception ex)
            {
                string result = ex.Message.ToString();
                HelperText.CreateTextFile("DeleteJsonFile", result);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = result;
            }

            return(returnOutput);
        }
Esempio n. 20
0
    // Added a new item to the queue
    public void AddItem(string bodyText, string title = "", bool priority = false)
    {
        // Clear queue if priority
        if (priority)
        {
            helperText.Clear();
        }

        // New struct
        HelperText newItem = new HelperText(title, bodyText);

        // Add text to the queue to be displayed
        helperText.Enqueue(newItem);

        // If helper text was empty, reopen it
        if (helperText.Count == 1)
        {
            Open();
            UpdateText();
        }
    }
Esempio n. 21
0
    public bool PlaceOnDropTarget(ItemDropTarget dropTarget)
    {
        if (dropTarget == null)
        {
            Debug.LogError($"Cannot find {nameof(dropTarget)} component");
        }

        //is drop target valid?can we drop this item here?(f.e this key's uid matches the keypillar's allowed uids)
        if (dropTarget.IsValidForItem(this.Uid))
        {
            //empty item slot of current item
            var slot = GetAttachedItemSlot();
            if (slot == null)
            {
                //slot might be null when loading already placed object
                SlotUid = null;
            }
            else
            {
                //placing item in dropTarget so need to empty the inventory slot it occupies
                slot.SetSlotState(null);
                SlotUid = null;
            }

            //restore parent to worldPointCanvas and then perform placement positioning
            RestoreInitialValues();
            dropTarget.PlaceItem(this);
            DropTargetId = dropTarget.Uid;
            alreadyUsed  = true;
            return(true);
        }
        else
        {
            HelperText.DisplayText(StringResources.HelpMessages.Item_InvalidPlacement, Constants.HelpMessage_ShortDuration);
            Debug.LogWarning(string.Format(StringResources.System_Messages.DropTarget_ValidationFailedFormat,
                                           dropTarget.name, this.name, this.Uid));
            return(false);
        }
    }
Esempio n. 22
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     isDragCanceled = false;
     if (!alreadyUsed)
     {
         //allow dragging from item slot or from level if in pickup range
         bool isInRange = false;
         if (isAttachedToItemSlot ||
             (isInRange = IsInPickupRange()))
         {
             //allow to detect drop (fe. on item slots), this wont catch UIraycasts when dragging
             canvasGroup.blocksRaycasts = false;
             SetHigherSortingLayer();
             ToggleItemSlotHighlights(true);
             isDragged = true;
         }
         if (!isAttachedToItemSlot && !isInRange)
         {
             HelperText.DisplayText("Out of range", 1f);
         }
     }
 }
Esempio n. 23
0
        public static T ReadJsonAsObject(string jsonFilePath)
        {
            try
            {
                string fullPath = filePath + typeof(T).Name + "\\" + jsonFilePath + ".json";

                if (File.Exists(fullPath))
                {
                    string jsonData   = File.ReadAllText(fullPath);
                    T      resultData = JsonConvert.DeserializeObject <T>(jsonData);

                    return(resultData);
                }
            }
            catch (Exception ex)
            {
                string result = ex.Message;
                HelperText.CreateTextFile("ReadJsonAsFile", result);
            }

            return(default(T));
        }
Esempio n. 24
0
        //  Change Json File
        //https://stackoverflow.com/questions/21695185/change-values-in-json-file-writing-files
        // https://www.newtonsoft.com/json/help/html/ModifyJson.htm
        public static string ChangeJsonData(string jsonFilePath)
        {
            string result = "OK";

            try
            {
                string fullPath = filePath + jsonFilePath;
                string json     = File.ReadAllText(fullPath);

                dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
                jsonObj["Ad"] = "Numan";

                string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
                File.WriteAllText(fullPath, output);
            }
            catch (Exception ex)
            {
                result = ex.Message.ToString();
                HelperText.CreateTextFile("ChangeJsonData", result);
            }

            return(result);
        }
Esempio n. 25
0
        /// Json dosya taşıma işlemi burad File SystemObject ile yapılır.
        /// typeName demek Contenet demek Model in Classın adı demek
        public static ReturnOutput MoveJsonFile(string fullPath, string destinationPath)
        {
            ReturnOutput returnOutput = new ReturnOutput
            {
                ErrorCode    = "1000",
                ErrorMessage = "Ok"
            };

            try
            {
                FileInfo fi = new FileInfo(fullPath);

                File.Move(fullPath, destinationPath);
            }
            catch (Exception ex)
            {
                string result = ex.Message.ToString();
                HelperText.CreateTextFile("MoveJsonFile", result);

                returnOutput.ErrorCode    = "1001";
                returnOutput.ErrorMessage = result;
            }
            return(returnOutput);
        }
Esempio n. 26
0
        public static List <string> GetReadAllJsonDataReturnString(string folderName)
        {
            List <string> list     = new List <string>();
            string        fullPath = filePath + folderName;

            DirectoryInfo di = new DirectoryInfo(fullPath);

            try
            {
                foreach (var file in di.GetFiles())
                {
                    string result = File.ReadAllText(file.FullName);
                    list.Add(result);
                }
            }
            catch (Exception ex)
            {
                string result = ex.Message.ToString();
                HelperText.CreateTextFile("GetReadAllJsonDataReturnString", result);
            }


            return(list);
        }
        private void OnValidationStateChangedCallback(object sender, EventArgs e)
        {
            if (ValidationMessageFor != null)
            {
                var fieldIdentifier   = FieldIdentifier.Create(ValidationMessageFor);
                var validationMessage = "";
                var separator         = "";

                foreach (var message in EditContext.GetValidationMessages(fieldIdentifier))
                {
                    validationMessage += separator + message;
                    separator          = "<br />";
                }

                InvokeAsync(async() => await JsRuntime.InvokeVoidAsync("MaterialBlazor.MBTextField.setHelperText", ElementReference, HelperTextReference, HelperText.Trim(), HelperTextPersistent, PerformsValidation, !string.IsNullOrEmpty(Value), validationMessage));
            }
        }
 /// <inheritdoc/>
 private protected override async Task InstantiateMcwComponent() => await JsRuntime.InvokeVoidAsync("MaterialBlazor.MBTextField.init", ElementReference, HelperTextReference, HelperText.Trim(), HelperTextPersistent, PerformsValidation);
Esempio n. 29
0
 public void StartTutorial(HelperText tutorial)
 {
     StartCoroutine("ShowTutorial", tutorial);
 }
Esempio n. 30
0
        public string CratePasswor()
        {
            string password = string.Concat(HelperText.CreateRandomString(HelperText.UPCase, 2), string.Format("{0}{1}", HelperText.CreateRandomString(HelperText.LowerCase, 8), HelperGeneral.Random.Next(999, 89999)));

            return(password);
        }