예제 #1
0
        [ActionName("resolveSimulatedAnnealingGAPInstance")] // path dell'api.
        public string resolveSimulatedAnnealingGAPInstance(AnnealingParameters paramts)
        {
            GAPInstance Gap = JSONConverter.deserializeGAP(dataDirectory + "\\" + paramts.getFileName());

            return(new BasicHeu(Gap).simulatedAnnealing(paramts.getTemperature(), paramts.getSteps(),
                                                        paramts.getTempDecrease(), paramts.getCoolingScheduleSteps()).ToString());
        }
예제 #2
0
        private void ExportAs_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lastModel != null)
            {
                string result = string.Empty;

                switch (ExportAs.SelectedIndex)
                {
                case 1:
                    var cmlConverter = new CMLConverter();
                    result = cmlConverter.Export(lastModel);
                    break;

                case 2:
                    var sdFileConverter = new SdFileConverter();
                    result = sdFileConverter.Export(lastModel);
                    break;

                case 3:
                    var jsonConverter = new JSONConverter();
                    result = jsonConverter.Export(lastModel);
                    break;
                }

                if (!string.IsNullOrEmpty(result))
                {
                    //Clipboard.SetText(result);
                    //MessageBox.Show("Last loaded model exported to clipboard as CML");
                    textBox1.Text = result + Environment.NewLine;
                }
            }
            ExportAs.SelectedIndex = 0;
            LoadStructure.Focus();
        }
예제 #3
0
        private void SwitchToMulti_OnClick(object sender, RoutedEventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            try
            {
                if (!_loading)
                {
                    object obj = ExecuteJavaScript("GetJSON");
                    if (obj != null)
                    {
                        string mol = obj.ToString();
                        if (!string.IsNullOrEmpty(mol))
                        {
                            JSONConverter jc    = new JSONConverter();
                            Model.Model   model = jc.Import(mol);
                            StructureJson = jc.Export(model);
                            SwapMode();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                new ReportError(Telemetry, TopLeft, module, ex).ShowDialog();
            }
        }
예제 #4
0
        /// <summary>
        /// Prompts the user for input.
        /// Calls ValidateInput() to check for 4 digits.
        /// Then looks up Entries in PINS.txt
        /// </summary>
        /// <returns>Returns True for a Valid PIN that is found in PINS.txt</returns>
        private string[] CheckPIN()
        {
            string Input = _t.GetString();

            if (IsValidInput(Input))
            {
                {
                    string[] users = filer.GetListOfUsers();
                    foreach (var item in users)
                    {
                        User tmp = JSONConverter.JSONToGeneric <User>(item);
                        if (tmp.GetType() == typeof(User))
                        {
                            if (Input.GetHashCode().ToString().Equals(tmp.PIN))
                            {
                                return(new string[2] {
                                    tmp.Status, tmp.FirstName
                                });
                            }
                        }
                    }
                }
                _t.Display("No matching PIN found\n");
            }
            else
            {
                _t.Display("Invalid Input\n");
            }
            return(new string[2] {
                "error", "error"
            });
        }
예제 #5
0
        public string GetHolidayCount(FormCollection collection)
        {
            try
            {
                string        result    = string.Empty;
                BLRegion      objRegion = new BLRegion();
                JSONConverter objJson   = new JSONConverter();

                string fromDate    = collection["fromDate"].ToString();
                string toDate      = collection["toDate"].ToString();
                string companyCode = _objCurr.GetCompanyCode();

                _objData.OpenConnection(companyCode);
                {
                    result = Convert.ToString(_objData.ExecuteScalar("exec SP_hdGetHolidayCount '" + companyCode + "','" + _objCurr.GetUserCode() + "','" + fromDate + "','" + toDate + "','" + _objCurr.GetRegionCode() + "'"));
                }

                #region WeekendDays
                List <MVCModels.HiDoctor_Master.WeekendDaysForARegion> lstWeekend = new List <MVCModels.HiDoctor_Master.WeekendDaysForARegion>();
                lstWeekend = objRegion.GetWeekendDaysForARegion(companyCode, _objCurr.GetRegionCode(), fromDate, toDate);
                #endregion WeekendDays

                return(result + "$" + objJson.Serialize(lstWeekend));
            }
            finally
            {
                _objData.CloseConnection();
            }
        }
예제 #6
0
        public void JSON_SerializeDeserializeListFromFile_Test()
        {
            // arrange
            int             index        = 0;
            List <Products> product_list = new List <Products>
            {
                new AlcoholicDrinks {
                    ProductName = "Лидское", PurchasePrice = 2.3, MurkupCoefficient = 1.1, NumberOfUnits = 50
                },
                new SoftDrinks {
                    ProductName = "Krysler", PurchasePrice = 2.5, MurkupCoefficient = 1.3, NumberOfUnits = 50
                },
                new TobaccoProducts {
                    ProductName = "Winston", PurchasePrice = 2, MurkupCoefficient = 1.3, NumberOfUnits = 50
                }
            };
            double          delta = .001;
            List <Products> product_list_json;

            // act
            JSONConverter.SerializeToFile("test.json", product_list);
            JSONConverter.DeserializeFromFile("test.json", out product_list_json);

            // assert
            foreach (var item in product_list_json)
            {
                Assert.AreEqual(product_list[index].ProductName, item.ProductName);
                Assert.AreEqual(product_list[index].ProductType, item.ProductType);
                Assert.AreEqual(product_list[index].PurchasePrice, item.PurchasePrice, delta);
                Assert.AreEqual(product_list[index].MurkupCoefficient, item.MurkupCoefficient, delta);
                Assert.AreEqual(product_list[index].NumberOfUnits, item.NumberOfUnits, delta);

                index++;
            }
        }
예제 #7
0
        public void JSON_SerializeDeserializeObject_Test()
        {
            // arrange
            Products product = new AlcoholicDrinks("Лидское", 2.3, 1.1, 50);

            string      expecterd_name               = "Лидское";
            double      expecterd_purchasePrice      = 2.3;
            double      expecterd_murkup_coefficient = 1.1;
            double      expecterd_numberOfUnits      = 50;
            TypesOfGood expecterd_productType        = TypesOfGood.AlcoholicDrinks;

            double delta = .001;

            // act
            string   json = JSONConverter.Serialize(product);
            Products product_JSON;

            JSONConverter.Deserialize(json, out product_JSON);

            // assert
            Assert.AreEqual(expecterd_name, product_JSON.ProductName);
            Assert.AreEqual(expecterd_productType, product_JSON.ProductType);
            Assert.AreEqual(expecterd_purchasePrice, product_JSON.PurchasePrice, delta);
            Assert.AreEqual(expecterd_murkup_coefficient, product_JSON.MurkupCoefficient, delta);
            Assert.AreEqual(expecterd_numberOfUnits, product_JSON.NumberOfUnits, delta);
        }
예제 #8
0
 public T SendMessage <T>(T value)
 {
     try { return(JSONConverter.ConvertFromJSONType <T>(SendMessage(value))); }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(default);
예제 #9
0
        private void EditorHost_Load(object sender, EventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            Cursor.Current = Cursors.WaitCursor;

            if (TopLeft.X != 0 && TopLeft.Y != 0)
            {
                Left = (int)TopLeft.X;
                Top  = (int)TopLeft.Y;
            }

            CMLConverter  cc = new CMLConverter();
            JSONConverter jc = new JSONConverter();

            Model.Model model = cc.Import(_cml);

            WpfChemDoodle editor = new WpfChemDoodle();

            editor.Telemetry          = Telemetry;
            editor.ProductAppDataPath = ProductAppDataPath;
            editor.UserOptions        = UserOptions;
            editor.TopLeft            = TopLeft;

            editor.StructureJson     = jc.Export(model);
            editor.IsSingleMolecule  = model.Molecules.Count == 1;
            editor.AverageBondLength = model.MeanBondLength;

            editor.InitializeComponent();
            elementHost1.Child    = editor;
            editor.OnButtonClick += OnWpfButtonClick;

            this.Show();
            Application.DoEvents();
        }
예제 #10
0
        public JsonResult GetAnnouncementFullDetail(string msgCode)
        {
            try
            {
                List <MVCModels.NoticeBoardContentModel>  lstAllMsg          = new List <MVCModels.NoticeBoardContentModel>();
                List <MVCModels.NoticeboardAgentMSGModel> lstPreviousNextMsg = new List <MVCModels.NoticeboardAgentMSGModel>();
                JSONConverter objJson = new JSONConverter();
                StringBuilder sbTbl   = new StringBuilder();
                DataControl.HiDoctor_ActivityFactoryClasses.BL_NoticeBoard objNot = new DataControl.HiDoctor_ActivityFactoryClasses.BL_NoticeBoard();

                DataControl.BLMessaging objMsg = new DataControl.BLMessaging();
                lstAllMsg          = (List <MVCModels.NoticeBoardContentModel>)objNot.GetNoticeBoardPopup(objCurr.GetCompanyCode(), msgCode, objCurr.GetUserCode()).ToList();
                lstPreviousNextMsg = (List <MVCModels.NoticeboardAgentMSGModel>)objMsg.GetPreviousAndNextAnnouncementCode(objCurr.GetCompanyCode(), objCurr.GetUserCode(), msgCode).ToList();

                List <JsonResult> lst = new List <JsonResult> {
                    Json(lstAllMsg, JsonRequestBehavior.AllowGet),
                    Json(lstPreviousNextMsg, JsonRequestBehavior.AllowGet)
                };

                return(Json(lst, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Dictionary <string, string> dicObj = new Dictionary <string, string>();
                dicObj.Add("msgCode", msgCode);
                ExceptionHandler.WriteLog(ex: ex, dic: dicObj);
                return(null);
            }
        }
예제 #11
0
            public static void OnConvertToJSONElement(object obj, JSONElement node)
            {
                Gradient gradient = (Gradient)obj;

                if (gradient != null)
                {
                    JSONElement colorKeysJSONElement = JSONUtils.CreateJSONElement(node.OwnerDocument, JSONConverter.kJSONArrayTag);
                    for (int i = 0; i < gradient.colorKeys.Length; i++)
                    {
                        JSONElement colorKeyJSONElement = JSONUtils.CreateJSONElement(node.OwnerDocument, "ColorKey");
                        JSONConverter.AppendFieldObject(colorKeyJSONElement, gradient.colorKeys[i].color, "color");
                        JSONConverter.AppendFieldObject(colorKeyJSONElement, gradient.colorKeys[i].time, "time");
                        JSONUtils.SafeAppendChild(colorKeysJSONElement, colorKeyJSONElement);
                    }
                    JSONUtils.AddAttribute(node.OwnerDocument, colorKeysJSONElement, JSONConverter.kJSONFieldIdAttributeTag, "colorKeys");
                    JSONUtils.SafeAppendChild(node, colorKeysJSONElement);


                    JSONElement alphasKeyJSONElement = JSONUtils.CreateJSONElement(node.OwnerDocument, JSONConverter.kJSONArrayTag);
                    for (int i = 0; i < gradient.alphaKeys.Length; i++)
                    {
                        JSONElement alphaKeyJSONElement = JSONUtils.CreateJSONElement(node.OwnerDocument, "AlphaKey");
                        JSONConverter.AppendFieldObject(alphaKeyJSONElement, gradient.alphaKeys[i].alpha, "alpha");
                        JSONConverter.AppendFieldObject(alphaKeyJSONElement, gradient.alphaKeys[i].time, "time");
                        JSONUtils.SafeAppendChild(alphasKeyJSONElement, alphaKeyJSONElement);
                    }
                    JSONUtils.AddAttribute(node.OwnerDocument, alphasKeyJSONElement, JSONConverter.kJSONFieldIdAttributeTag, "alphaKeys");
                    JSONUtils.SafeAppendChild(node, alphasKeyJSONElement);
                }
            }
예제 #12
0
        public static async Task <AnimeList> GetAnimeList(NetworkCredential credentials, string Username)
        {
            AnimeList       animeList = new AnimeList();
            HttpWebResponse response  = null;

            try
            {
                response = await SendHttpWebGETRequest(credentials, MAL_URL + "animelist/" + Username + "/load.json", ContentType.JSON);

                if (EnsureStatusCode(response))
                {
                    StreamReader responseStream   = new StreamReader(response.GetResponseStream());
                    string       responseAsString = responseStream.ReadToEnd();
                    animeList = JSONConverter.DeserializeJSon <AnimeList>(responseAsString);
                }
            }
            catch (WebException ex)
            {
                Debug.Write("GetAnimeList: WebException response: " + ex.Status);
            }
            finally
            {
                if (response != null)
                {
                    response.Dispose();
                }
            }
            return(animeList);
        }
예제 #13
0
        public void PopulateCategories()
        {
            var categories = JSONConverter.ReadJsonFile();

            foreach (Category category in categories)
            {
                var auxCategory = _context.Categories.Include(a => a.Questions).Where(a => a.CategoryName == category.CategoryName).FirstOrDefault();
                if (auxCategory != null)
                {
                    for (int i = 0; i < category.Questions.Count; i++)
                    {
                        if (_context.Questions.Where(a => a.QuestionText == category.Questions.ElementAt(i).QuestionText).FirstOrDefault() != null)
                        {
                            auxCategory.Questions.ElementAt(i).CorrectAnswer      = category.Questions.ElementAt(i).CorrectAnswer;
                            auxCategory.Questions.ElementAt(i).WrongAnswer1       = category.Questions.ElementAt(i).WrongAnswer1;
                            auxCategory.Questions.ElementAt(i).WrongAnswer2       = category.Questions.ElementAt(i).WrongAnswer2;
                            auxCategory.Questions.ElementAt(i).WrongAnswer3       = category.Questions.ElementAt(i).WrongAnswer3;
                            auxCategory.Questions.ElementAt(i).QuestionDifficulty = category.Questions.ElementAt(i).QuestionDifficulty;
                        }
                        else
                        {
                            auxCategory.Questions.Add(category.Questions.ElementAt(i));
                        }
                    }
                    Edit(auxCategory);
                }
                else
                {
                    Create(category);
                }
            }
        }
예제 #14
0
        public User AddUser(string userName, string password)
        {
            var url = ApiConstants.BASE_URL + ApiConstants.USER_URL;

            Hashtable data = new Hashtable();

            data.Add("userName", userName);
            data.Add("password", password);

            var request = new Request("POST", url, data);

            request.Send();
            while (!request.isDone)
            {
            }

            var statusCode = request.response.status;

            if (statusCode == 409)
            {
                throw new UserNameAlreadyInUseException();
            }
            if (statusCode != 201)
            {
                throw new SomethingWentWrongException();
            }

            var json = request.response.Text;

            return(JSONConverter.JsonToUser(json));
        }
예제 #15
0
        public void ProductDictionarySerializationCountJSONTest()
        {
            Dictionary <int, Product> products = new Dictionary <int, Product>
            {
                { 1, new Product {
                      Name = "Yamaha 2", Price = 400.99
                  } },
                { 2, new Product {
                      Name = "Ibanez 2111", Price = 402130.99
                  } },
                { 3, new Product {
                      Name = "Cort 242", Price = 4111100.99
                  } },
                { 4, new Product {
                      Name = "Yamaha -4", Price = 4500.99
                  } },
            };

            JSONConverter jscon = new JSONConverter();

            jscon.writeProductsDictionary(products, "products.txt");
            Dictionary <int, Product> deProducts = jscon.readProductsDictionary("products.txt");

            Assert.AreEqual(products.Count, deProducts.Count);
        }
예제 #16
0
        public void ProductDictionarySerializationJSONTest()
        {
            Dictionary <int, Product> products = new Dictionary <int, Product>
            {
                { 0, new Product {
                      Name = "Yamaha 2.0", Price = 3200.99
                  } },
                { 1, new Product {
                      Name = "Yamaha 2", Price = 400.99
                  } },
                { 2, new Product {
                      Name = "Ibanez 2111", Price = 402130.99
                  } },
                { 3, new Product {
                      Name = "Cort 242", Price = 4111100.99
                  } },
                { 4, new Product {
                      Name = "Yamaha -4", Price = 4500.99
                  } },
            };

            JSONConverter jscon = new JSONConverter();

            jscon.writeProductsDictionary(products, "products.txt");
            Dictionary <int, Product> deProducts = jscon.readProductsDictionary("products.txt");

            for (int i = 0; i < products.Count; i++)
            {
                Assert.AreEqual(products[i].ToString(), deProducts[i].ToString());
            }
        }
예제 #17
0
        private void Groups_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var jsonConvertor = new JSONConverter();

            if (Groups.SelectedItem is FunctionalGroup fg)
            {
                if (!string.IsNullOrEmpty(_lastFunctionalGroup))
                {
                    if (Editor.IsDirty)
                    {
                        var temp = Editor.ActiveViewModel.Model.Copy();
                        temp.RescaleForCml();
                        string expansion = jsonConvertor.Export(temp, true);
                        var    fge       = _functionalGroups.FirstOrDefault(f => f.Name.Equals(_lastFunctionalGroup));
                        fge.Expansion = expansion;
                    }
                }

                _lastFunctionalGroup = fg.ToString();

                if (fg.Expansion == null)
                {
                    var model = jsonConvertor.Import("{'a':[{'l':'" + fg.Name + "','x':0,'y':0}]}");
                    Editor.SetModel(model);
                }
                else
                {
                    string groupJson = JsonConvert.SerializeObject(fg.Expansion);
                    var    model     = jsonConvertor.Import(groupJson);
                    Editor.SetModel(model);
                }
            }
        }
예제 #18
0
        private void MainWindow_OnClosing(object sender, CancelEventArgs e)
        {
            if (Editor.IsDirty)
            {
                var jsonConvertor = new JSONConverter();
                var temp          = Editor.ActiveViewModel.Model.Copy();
                temp.RescaleForCml();
                string jsonString = jsonConvertor.Export(temp);
                var    jc         = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString);
                var    fg         = _functionalGroups.FirstOrDefault(f => f.Name.Equals(_lastFunctionalGroup));
                if (fg != null)
                {
                    fg.Expansion = jc;
                }
            }

            List <FunctionalGroup> listOfGroups = new List <FunctionalGroup>();

            foreach (var group in _functionalGroups)
            {
                listOfGroups.Add(group);
            }

            string json = JsonConvert.SerializeObject(listOfGroups,
                                                      Formatting.Indented,
                                                      new JsonSerializerSettings
            {
                DefaultValueHandling = DefaultValueHandling.Ignore
            });

            Clipboard.SetText(json);
            MessageBox.Show("Results on Clipboard !");
        }
            public static void OnConvertToJSONElement(object obj, JSONElement node)
            {
                IDictionary dictionary = (IDictionary)obj;

                Type[] dictionaryTypes = SystemUtils.GetGenericImplementationTypes(typeof(Dictionary <,>), obj.GetType());

                if (dictionaryTypes != null)
                {
                    //Find keys
                    string[] keys = new string[dictionary.Keys.Count];
                    int      i    = 0;
                    foreach (object key in dictionary.Keys)
                    {
                        keys[i++] = Convert.ToString(key);
                    }

                    //Append all child nodes
                    i = 0;
                    foreach (object value in dictionary.Values)
                    {
                        JSONElement arrayItemJSONElement = JSONConverter.ToJSONElement(value, node.OwnerDocument);
                        JSONUtils.AddAttribute(node.OwnerDocument, arrayItemJSONElement, "key", keys[i++]);
                        JSONUtils.SafeAppendChild(node, arrayItemJSONElement);
                    }
                }
            }
예제 #20
0
    public static JSONConverter getInstance()
    {
        if (instance == null)
            instance = new JSONConverter();

        return instance;
    }
예제 #21
0
        private void OnWpfButtonClick(object sender, EventArgs e)
        {
            string       module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";
            WpfEventArgs args   = (WpfEventArgs)e;

            if (args.Button.ToUpper().Equals("OK"))
            {
                DialogResult = DialogResult.OK;
                CMLConverter  cc    = new CMLConverter();
                JSONConverter jc    = new JSONConverter();
                Model.Model   model = jc.Import(args.OutputValue);
                OutputValue = cc.Export(model);
            }

            if (args.Button.ToUpper().Equals("CANCEL"))
            {
                DialogResult = DialogResult.Cancel;
                OutputValue  = "";
            }

            WpfChemDoodle editor = elementHost1.Child as WpfChemDoodle;

            if (editor != null)
            {
                editor.OnButtonClick -= OnWpfButtonClick;
                editor = null;
            }
            Hide();
        }
예제 #22
0
            public static object OnConvertFromJSONElement(object obj, JSONElement node)
            {
                if (node == null)
                {
                    return(obj);
                }

                AnimationCurve curve = new AnimationCurve();

                JSONElement keyframesJSONElement = JSONUtils.FindChildWithAttributeValue(node, JSONConverter.kJSONFieldIdAttributeTag, "keyFrames");

                if (keyframesJSONElement != null)
                {
                    List <Keyframe> keyFrames = new List <Keyframe>();
                    foreach (JSONElement child in keyframesJSONElement.ChildNodes)
                    {
                        Keyframe keyFrame = new Keyframe();
                        keyFrame.inTangent   = JSONConverter.FieldObjectFromJSONElement <float>(child, "inTangent");
                        keyFrame.outTangent  = JSONConverter.FieldObjectFromJSONElement <float>(child, "outTangent");
                        keyFrame.tangentMode = JSONConverter.FieldObjectFromJSONElement <int>(child, "tangentMode");
                        keyFrame.time        = JSONConverter.FieldObjectFromJSONElement <float>(child, "time");
                        keyFrame.value       = JSONConverter.FieldObjectFromJSONElement <float>(child, "value");
                        keyFrames.Add(keyFrame);
                    }
                    curve.keys = keyFrames.ToArray();
                }

                return(curve);
            }
예제 #23
0
        /// <summary>
        /// Posts JSON data.
        /// </summary>
        /// <param name="OnComplete">Called when request is completed.</param>
        /// <param name="OnFail">Called when request fails.</param>
        /// <param name="OnStart">Called when request starts.</param>
        public async void MakeRequest(Action <object> OnComplete, Action <string> OnFail = null,
                                      Action OnStart = null)
        {
            var handler = new HttpClientHandler();

            if (cookieContainer.Count != 0)
            {
                handler.UseCookies      = false;
                handler.CookieContainer = cookieContainer;
            }

            using (var client = new HttpClient(handler))
            {
                if (oAuthKey != null && oAuthValue != null)
                {
                    client.DefaultRequestHeaders.Authorization =
                        new AuthenticationHeaderValue(oAuthKey, oAuthValue);
                }

                // Call OnStart() at the beginning
                if (OnStart != null)
                {
                    OnStart();
                }

                try
                {
                    client.BaseAddress = new Uri(url);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var content = new StringContent(json);

                    var response = await client.PostAsync(url, content);

                    if (response.IsSuccessStatusCode)
                    {
                        var result = await response.Content.ReadAsStringAsync();

                        var jsonObject = JSONConverter.JSONToObject(result);
                        OnComplete(result);
                    }
                    else
                    {
                        if (OnFail != null)
                        {
                            OnFail(response.StatusCode.ToString());
                        }
                    }
                }
                catch (Exception e)
                {
                    if (OnFail != null)
                    {
                        OnFail(e.ToString());
                    }
                }
            }
        }
예제 #24
0
            public static void OnConvertToJSONElement(object obj, JSONElement node)
            {
                //Add to nodes for x and y
                IntRange intRange = (IntRange)obj;

                JSONConverter.AppendFieldObject(node, intRange._min, "min");
                JSONConverter.AppendFieldObject(node, intRange._max, "max");
            }
예제 #25
0
            public static void OnConvertToJSONElement(object obj, JSONElement node)
            {
                string valueName  = ConvertFlagsToString(obj);
                int    valueIndex = Convert.ToInt32(obj);

                JSONConverter.AppendFieldObject(node, valueName, "valueName");
                JSONConverter.AppendFieldObject(node, valueIndex, "valueIndex");
            }
예제 #26
0
            public static void OnConvertToJSONElement(object obj, JSONElement node)
            {
                //Add to nodes for x and y
                Vector2 vector = (Vector2)obj;

                JSONConverter.AppendFieldObject(node, vector.x, "x");
                JSONConverter.AppendFieldObject(node, vector.y, "y");
            }
예제 #27
0
        public JsonResult GetDepots(FormCollection collection)
        {
            Dt = new DataTable();
            Dt = Bl.GetDepots();
            JSONConverter json = new JSONConverter();

            return(Json(json.Serialize(Dt), JsonRequestBehavior.AllowGet));
        }
예제 #28
0
            public static void OnConvertToJSONElement(object obj, JSONElement node)
            {
                string valueName  = Enum.GetName(obj.GetType(), obj);
                int    valueIndex = Convert.ToInt32(obj);

                JSONConverter.AppendFieldObject(node, valueName, "valueName");
                JSONConverter.AppendFieldObject(node, valueIndex, "valueIndex");
            }
예제 #29
0
        public User GetUser(int id)
        {
            var url = ApiConstants.BASE_URL + ApiConstants.USER_URL + "/" + id;
            var www = new WWW(url);

            var user = JSONConverter.JsonToUser(www.text);

            return(user);
        }
            public static void OnConvertToJSONElement(object obj, JSONElement node)
            {
                Quaternion quaternion = (Quaternion)obj;
                Vector3    euler      = quaternion.eulerAngles;

                JSONConverter.AppendFieldObject(node, euler.x, "x");
                JSONConverter.AppendFieldObject(node, euler.y, "y");
                JSONConverter.AppendFieldObject(node, euler.z, "z");
            }
예제 #31
0
        public void TransactionSerializationJSONTest()
        {
            Transaction   transaction = new Transaction(3, 3, "5 maja");
            JSONConverter jscon       = new JSONConverter();

            jscon.writeObject(transaction, "transaction.txt");
            Transaction secondClient = jscon.readTransaction("transaction.txt");

            Assert.AreEqual(transaction.ToString(), secondClient.ToString());
        }