ToString() public méthode

public ToString ( ) : string
Résultat string
        public static IncidentConfig ParseIncident(JSON json)
        {
            IncidentConfig config = new IncidentConfig(
                json.ToUInt(ID_CRC),
                json.ToString(ID),
                json.ToString(NAME)
                );

            return(config);
        }
 internal override string AsString(OutputOptions inOptions = OutputOptions.None)
 {
     if ((inOptions & OutputOptions.Base64) != 0)
     {
         return(m_Root.ToBase64());
     }
     if ((inOptions & OutputOptions.PrettyPrint) != 0)
     {
         return(m_Root.ToString(3));
     }
     return(m_Root.ToString());
 }
        private static ResponseConfig ParseResponse(JSON json)
        {
            ResponseConfig config = new ResponseConfig(
                json.ToUInt(ID_CRC),
                json.ToString(ID),
                json.ToString(NAME),
                json.ToFloat(TIME),
                json.ToInt(POINTS)
                );

            return(config);
        }
Exemple #4
0
        public static VegetableConfig ParseVegetable(JSON json)
        {
            VegetableConfig config = new VegetableConfig(
                json.ToUInt(VEGETABLE_ID_CRC),
                json.ToString(VEGETABLE_ID),
                json.ToString(NAME),
                json.ToString(DIFFICULTY),
                json.ToFloat(TIME_TO_INCIDENT),
                json.ToFloat(TIME_TO_EAT),
                json.ToInt(POINTS)
                );

            return(config);
        }
Exemple #5
0
 //Responses
 private void entitycreateResponse(JSON root, string objectHashCode)
 {
     if (EntityDictionary.ContainsKey(objectHashCode) && root.fields.ContainsKey("id"))
     {
         Entity curobject = EntityDictionary[objectHashCode];
         EntityDictionary.Add(root.ToString("id"), curobject);
         EntityDictionary.Remove(objectHashCode);
         curobject.id = root.ToString("id");
     }
     else
     {
         Debug.Log("Unknown object sign hashcode=" + objectHashCode);
     }
 }
        public static LevelConfig ParseLevel(JSON json)
        {
            LevelConfig config = new LevelConfig(
                json.ToUInt(ID_CRC),
                json.ToString(ID),
                json.ToString(NAME),
                json.ToInt(TIME),
                json.ToInt(CHILDREN_COUNT),
                json.ToInt(TABLE_COUNT),
                json.ToInt(PLAYER_COUNT)
                );

            return(config);
        }
Exemple #7
0
    //=============================================================================

    void SetupNewsFlash(string InputText)
    {
        JSON Decoder = new JSON();

        Decoder.serialized = InputText;

        JSON NewsDataJSON = Decoder.ToJSON("newsData");

        int PopupVersion      = NewsDataJSON.ToInt("version");
        int LiveDataVersion   = NewsDataJSON.ToInt("liveDataVersion");
        int CouponCodesActive = NewsDataJSON.ToInt("couponCodesActive");

        PlayerPrefs.SetInt("couponCodesActive", CouponCodesActive);

        // Do we need to download live data?
        if (LiveDataVersion > PlayerPrefs.GetInt("LiveDataVersion", PreHelpers.GetLiveDataVersion()))
        {
            Debug.Log("Updating live data!");
            //PlayerPrefsWrapper.SetInt( "LiveDataVersion" , LiveDataVersion );
            StartCoroutine(GetLiveData(LiveDataVersion, NewsDataJSON.ToString("liveDataURL")));
        }
        else
        {
            Debug.Log("Don't need to update live data - our version:" + PlayerPrefs.GetInt("LiveDataVersion", PreHelpers.GetLiveDataVersion()) + " remote version:" + LiveDataVersion);
        }
    }
Exemple #8
0
        public Boolean SubmitRequest()
        {
            String  PostData;
            Boolean Ret;
            String  ResPath;

            ResponseData = new POSTRequest.ResponseData();

            Helper.SafeKill(ResponsePath + WFConstants.API_REQ_READ);
            Helper.SafeKill(ResponsePath + WFConstants.API_RESP_READ);

            objReq.get_Member("SessionKey", true).SetValue(SessionKey);
            objReq.get_Member("tableid", true).SetValue(tableid);

            JSONValue objData = objReq.get_Member("data", true);

            objData.get_Member("OPERATION", true).SetValue(Operation);
            objData.get_Member("pattern", true).SetValue(pattern);
            //objData.get_Member("DATAELEMENT", true).SetValue(DATAELEMENT);
            objData.get_Member("MAXCOUNT", true).SetValue(Maxcount);

            ResPath  = ResponsePath + WFConstants.API_RESP_READ;
            PostData = objJSON.ToString(objReq);
            File.WriteAllText(ResponsePath + WFConstants.API_REQ_READ, PostData);

            Ret = POSTRequest.HttpPostRequest(Url, PostData, ref ResponseData, ResPath);
            return(Ret);
        }
Exemple #9
0
        public Boolean SubmitRequest()
        {
            String  PostData;
            Boolean Ret;
            String  ResPath;

            ResponseData = new POSTRequest.ResponseData();

            Helper.SafeKill(ResponsePath + WFConstants.API_REQ_UPLOAD);
            Helper.SafeKill(ResponsePath + WFConstants.API_RESP_UPLOAD);

            objReq.get_Member("SessionKey", true).SetValue(SessionKey);
            objReq.get_Member("is_new", true).SetValue(is_new);
            objReq.get_Member("ImageRef", true).SetValue(ImageRef);
            objReq.get_Member("filehash", true).SetValue(FileHash);
            objReq.get_Member("ConvertToPDF", true).SetValue(int.Parse(ConvertToPDF));
            objReq.get_Member("FileName", true).SetValue(FileName);

            ResPath  = ResponsePath + WFConstants.API_RESP_UPLOAD;
            PostData = objJSON.ToString(objReq);
            File.WriteAllText(ResponsePath + WFConstants.API_REQ_UPLOAD, PostData);

            Ret = POSTRequest.HttpPostRequest(Url, PostData, ref ResponseData, ResPath, FilePath);

            return(Ret);
        }
Exemple #10
0
        public virtual void TestFinalState()
        {
            StartupProgressTestHelper.SetStartupProgressForFinalState(startupProgress);
            string respBody = DoGetAndReturnResponseBody();

            NUnit.Framework.Assert.IsNotNull(respBody);
            IDictionary <string, object> expected = ImmutableMap.Builder <string, object>().Put
                                                        ("percentComplete", 1.0f).Put("phases", Arrays.AsList <object>(ImmutableMap.Builder
                                                                                                                       <string, object>().Put("name", "LoadingFsImage").Put("desc", "Loading fsimage").
                                                                                                                       Put("status", "COMPLETE").Put("percentComplete", 1.0f).Put("steps", Sharpen.Collections
                                                                                                                                                                                  .SingletonList <object>(ImmutableMap.Builder <string, object>().Put("name", "Inodes"
                                                                                                                                                                                                                                                      ).Put("desc", "inodes").Put("count", 100L).Put("total", 100L).Put("percentComplete"
                                                                                                                                                                                                                                                                                                                        , 1.0f).Build())).Build(), ImmutableMap.Builder <string, object>().Put("name", "LoadingEdits"
                                                                                                                                                                                                                                                                                                                                                                                               ).Put("desc", "Loading edits").Put("status", "COMPLETE").Put("percentComplete",
                                                                                                                                                                                                                                                                                                                                                                                                                                                            1.0f).Put("steps", Sharpen.Collections.SingletonList <object>(ImmutableMap.Builder
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          <string, object>().Put("count", 200L).Put("file", "file").Put("size", 1000L).Put
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ("total", 200L).Put("percentComplete", 1.0f).Build())).Build(), ImmutableMap.Builder
                                                                                                                       <string, object>().Put("name", "SavingCheckpoint").Put("desc", "Saving checkpoint"
                                                                                                                                                                              ).Put("status", "COMPLETE").Put("percentComplete", 1.0f).Put("steps", Sharpen.Collections
                                                                                                                                                                                                                                           .SingletonList <object>(ImmutableMap.Builder <string, object>().Put("name", "Inodes"
                                                                                                                                                                                                                                                                                                               ).Put("desc", "inodes").Put("count", 300L).Put("total", 300L).Put("percentComplete"
                                                                                                                                                                                                                                                                                                                                                                                 , 1.0f).Build())).Build(), ImmutableMap.Builder <string, object>().Put("name", "SafeMode"
                                                                                                                                                                                                                                                                                                                                                                                                                                                        ).Put("desc", "Safe mode").Put("status", "COMPLETE").Put("percentComplete", 1.0f
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ).Put("steps", Sharpen.Collections.SingletonList <object>(ImmutableMap.Builder <string
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 , object>().Put("name", "AwaitingReportedBlocks").Put("desc", "awaiting reported blocks"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ).Put("count", 400L).Put("total", 400L).Put("percentComplete", 1.0f).Build())).Build
                                                                                                                           ())).Build();

            NUnit.Framework.Assert.AreEqual(JSON.ToString(expected), FilterJson(respBody));
        }
Exemple #11
0
        public Boolean SubmitRequest()
        {
            String  PostData;
            Boolean Ret;
            String  ResPath;

            ResponseData = new POSTRequest.ResponseData();
            Helper.SafeKill(ResponsePath + WFConstants.API_REQ_GETWORKITEM);
            Helper.SafeKill(ResponsePath + WFConstants.API_RESP_GETWORKITEM);

            objReq.get_Member("SessionKey", true).SetValue(SessionKey);
            JSONValue objData = objReq.get_Member("data", true);

            if (WorkID != 0)
            {
                objData.get_Member("Id", true).SetValue(WorkID);
            }
            else
            {
                objData.get_Member("Appdata1", true).SetValue(Appdata1);
            }

            ResPath  = ResponsePath + WFConstants.API_RESP_GETWORKITEM;
            PostData = objJSON.ToString(objReq);
            File.WriteAllText(ResponsePath + WFConstants.API_REQ_GETWORKITEM, PostData);

            Ret = POSTRequest.HttpPostRequest(Url, PostData, ref ResponseData, ResPath);
            return(Ret);
        }
Exemple #12
0
        /// <summary>Implements getLiveNodeManagers()</summary>
        /// <returns>JSON formatted string containing statuses of all node managers</returns>
        public virtual string GetLiveNodeManagers()
        {
            // RMNMInfoBeans
            ICollection <RMNode>     nodes     = this.rmContext.GetRMNodes().Values;
            IList <RMNMInfo.InfoMap> nodesInfo = new AList <RMNMInfo.InfoMap>();

            foreach (RMNode ni in nodes)
            {
                SchedulerNodeReport report = scheduler.GetNodeReport(ni.GetNodeID());
                RMNMInfo.InfoMap    info   = new RMNMInfo.InfoMap();
                info["HostName"]           = ni.GetHostName();
                info["Rack"]               = ni.GetRackName();
                info["State"]              = ni.GetState().ToString();
                info["NodeId"]             = ni.GetNodeID();
                info["NodeHTTPAddress"]    = ni.GetHttpAddress();
                info["LastHealthUpdate"]   = ni.GetLastHealthReportTime();
                info["HealthReport"]       = ni.GetHealthReport();
                info["NodeManagerVersion"] = ni.GetNodeManagerVersion();
                if (report != null)
                {
                    info["NumContainers"]     = report.GetNumContainers();
                    info["UsedMemoryMB"]      = report.GetUsedResource().GetMemory();
                    info["AvailableMemoryMB"] = report.GetAvailableResource().GetMemory();
                }
                nodesInfo.AddItem(info);
            }
            return(JSON.ToString(nodesInfo));
        }
Exemple #13
0
 //responses
 public void signUpResponse(JSON root)
 {
     if (root.fields.ContainsKey("id"))
     {
         id = root.ToString("id");
     }
 }
Exemple #14
0
        public static BTNodeData CreateCompositeNodeData(JSON js)
        {
            string         nodeTypeStr = js.ToString("nodeType");
            COMPOSITE_TYPE nodeType    = (COMPOSITE_TYPE)Enum.Parse(typeof(COMPOSITE_TYPE), nodeTypeStr);

            if (nodeType == COMPOSITE_TYPE.SEQUENCER)
            {
                return(new BTSequenceNodeData(js));
            }
            else if (nodeType == COMPOSITE_TYPE.SELECTOR)
            {
                return(new BTSelectorNodeData(js));
            }
            else if (nodeType == COMPOSITE_TYPE.PARALLEL)
            {
                return(new BTParallelNodeData(js));
            }
            else if (nodeType == COMPOSITE_TYPE.DYNAMIC_SELECTOR)
            {
                return(new BTDynamicSelectorNodeData(js));
            }
            else
            {
                UnityEngine.Debug.Log("Error: Invalid Decorator Node Type: " + nodeTypeStr);
            }
            return(null);
        }
        /**
         * Create purchase from json string
         * @param jsonString data serialized to json
         */
        public Purchase(string jsonString)
        {
            var json = new JSON(jsonString);
            ItemType = json.ToString("itemType");
            OrderId = json.ToString("orderId");
            PackageName = json.ToString("packageName");
            Sku = json.ToString("sku");
            PurchaseTime = json.ToLong("purchaseTime");
            PurchaseState = json.ToInt("purchaseState");
            DeveloperPayload = json.ToString("developerPayload");
            Token = json.ToString("token");
            OriginalJson = json.ToString("originalJson");
            Signature = json.ToString("signature");
            AppstoreName = json.ToString("appstoreName");
			Receipt = json.ToString("receipt");
        }
Exemple #16
0
        public BTreeData(JSON js)
        {
            _id = js.ToString("name");

            List <BTNodeData> listOfNodes = new List <BTNodeData>();

            JSON[] nodeList = js.ToArray <JSON>("bTree");
            for (int i = 0; i < nodeList.Length; ++i)
            {
                BTNodeData nodeData = BTNodeData.CreateNodeData(nodeList[i]);
                listOfNodes.Add(nodeData);
            }

            JSON[] connectionList = js.ToArray <JSON>("connections");
            for (int i = 0; i < connectionList.Length; ++i)
            {
                int        inNodeId  = connectionList[i].ToInt("inNodeId");
                int        outNodeId = connectionList[i].ToInt("outNodeId");
                BTNodeData inNode    = listOfNodes[inNodeId];
                BTNodeData outNode   = listOfNodes[outNodeId];
                if (inNode.type == BTNodeData.TYPE.ROOT || inNode.type == BTNodeData.TYPE.DECORATOR)
                {
                    (inNode as BTDecoratorNodeData).AddChild(outNode);
                    if (inNode.type == BTNodeData.TYPE.ROOT)
                    {
                        _btRootData = outNode;
                    }
                }
                else if (inNode.type == BTNodeData.TYPE.COMPOSITE)
                {
                    (inNode as BTCompositeNodeData).AddChild(outNode);
                }
            }
        }
Exemple #17
0
 private void signInResponse(JSON root)
 {
     if (root.fields.ContainsKey("id"))
     {
         id = root.ToString("id");
     }
 }
Exemple #18
0
        private void Request(String method, Uri uri, object body)
        {
            Log.Trace("{0}ing to {1}", method, uri);
            WebRequest request = WebRequest.Create(Uri);

            request.Method = method;

            if (body != null)
            {
                request.ContentType = "application/json; charset=UTF-8";
                string text = JSON.ToString(GetDescriptor(), 4);
                Log.Trace("Data: {0}", text);
                byte[] data = Encoding.UTF8.GetBytes(text);
                request.ContentLength = data.Length;
                Stream outstream = request.GetRequestStream();
                try {
                    outstream.Write(data, 0, data.Length);
                } finally {
                    outstream.Close();
                }
            }

            WebResponse response = request.GetResponse();

            if (response == null)
            {
                return;
            }
            StreamReader reader = new StreamReader(response.GetResponseStream());

            reader.ReadToEnd();
        }
Exemple #19
0
        public static BTNodeData CreateNodeData(JSON js)
        {
            string baseTypeStr = js.ToString("baseType");
            TYPE   baseType    = (TYPE)Enum.Parse(typeof(TYPE), baseTypeStr);

            if (baseType == TYPE.ACTION)
            {
                return(BTActionNodeData.CreateActionNodeData(js));
            }
            else if (baseType == TYPE.DECORATOR)
            {
                return(BTDecoratorNodeData.CreateDecoratorNodeData(js));
            }
            else if (baseType == TYPE.COMPOSITE)
            {
                return(BTCompositeNodeData.CreateCompositeNodeData(js));
            }
            else if (baseType == TYPE.ROOT)
            {
                BTNodeData rootNodeData = BTDecoratorNodeData.CreateRootNodeData(js);
                rootNodeData.type = TYPE.ROOT;
                return(rootNodeData);
            }
            else
            {
                UnityEngine.Debug.Log("Error: Invalid Node Type: " + baseTypeStr);
            }
            return(null);
        }
Exemple #20
0
    public static Color GetColorFromExcelConverted(ref JSON js, string value, Color?defaultValue = null)
    {
        Color  color    = defaultValue.HasValue ? defaultValue.Value : Color.black;
        string colorStr = js.ToString(value);

        if (!string.IsNullOrEmpty(colorStr))
        {
            if ((colorStr.StartsWith("#") || char.IsLetter(colorStr[0])))
            {
                if (!ColorUtility.TryParseHtmlString(colorStr, out color))
                {
                    Debug.LogWarning("Invalid Color HEX value (" + colorStr + ") found in data for key: " + value);
                }
            }
            else
            {
                char[]   delimiterChars = { ' ', ',', ':', '[', ']' };
                string[] vals           = colorStr.Split(delimiterChars);
                float[]  rgb            = new float[3];
                int      counter        = 0;
                for (int i = 0; i < vals.Length; ++i)
                {
                    if (string.IsNullOrEmpty(vals[i]))
                    {
                        continue;
                    }

                    rgb[counter++] = float.Parse(vals[i]);
                }
                color = new Color(rgb[0], rgb[1], rgb[2], 1);
            }
        }

        return(color);
    }
Exemple #21
0
		// Used for Android
        public SkuDetails(string jsonString) {
			var json = new JSON(jsonString);
			ItemType = json.ToString("itemType");
			Sku = json.ToString("sku");
			Type = json.ToString("type");
			Price = json.ToString("price");
			Title = json.ToString("title");
			Description = json.ToString("description");
			Json = json.ToString("json");
			CurrencyCode = json.ToString("currencyCode");
			PriceValue = json.ToString("priceValue");
			ParseFromJson();
        }
Exemple #22
0
        public SkuDetails(JSON json) {
            ItemType = json.ToString("itemType");
            Sku = json.ToString("sku");
            Type = json.ToString("type");
            Price = json.ToString("price");
            Title = json.ToString("title");
            Description = json.ToString("description");
            Json = json.ToString("json");
			CurrencyCode = json.ToString("currencyCode");
			PriceValue = json.ToString("priceValue");

            Sku = OpenIAB_iOS.StoreSku2Sku(Sku);
        }
Exemple #23
0
        /**
         * Create purchase from json string
         * @param jsonString data serialized to json
         */
        public Purchase(string jsonString)
        {
            var json = new JSON(jsonString);

            ItemType         = json.ToString("itemType");
            OrderId          = json.ToString("orderId");
            PackageName      = json.ToString("packageName");
            Sku              = json.ToString("sku");
            PurchaseTime     = json.ToLong("purchaseTime");
            PurchaseState    = json.ToInt("purchaseState");
            DeveloperPayload = json.ToString("developerPayload");
            Token            = json.ToString("token");
            OriginalJson     = json.ToString("originalJson");
            Signature        = json.ToString("signature");
            AppstoreName     = json.ToString("appstoreName");
            Receipt          = json.ToString("receipt");
        }
        public Purchase(JSON json)
        {
            ItemType         = json.ToString("itemType");
            OrderId          = json.ToString("orderId");
            Receipt          = json.ToString("receipt");
            PackageName      = json.ToString("packageName");
            Sku              = json.ToString("sku");
            PurchaseTime     = json.ToLong("purchaseTime");
            PurchaseState    = json.ToInt("purchaseState");
            DeveloperPayload = json.ToString("developerPayload");
            Token            = json.ToString("token");
            OriginalJson     = json.ToString("originalJson");
            Signature        = json.ToString("signature");
            AppstoreName     = json.ToString("appstoreName");

            Sku = OpenIAB_iOS.StoreSku2Sku(Sku);
        }
Exemple #25
0
        private void SendSensorDataJSON(HttpListenerContext context)
        {
            HttpListenerRequest request = context.Request;

            DateTime start = parseDate(request.QueryString["start"], DateTime.UtcNow.AddMinutes(-10));
            DateTime end   = parseDate(request.QueryString["end"], DateTime.UtcNow);

            string req = request.RawUrl;

            req = req.Remove(req.IndexOf('?'));
            string sensorId          = req.Substring(9);// "sensors/" is 8 characters long
            string sensorPath        = req.Substring(8).Replace('-', '/');
            long   componentSensorId = DataManager.GetComponentSensorId(sensorPath);

            if (componentSensorId != -1)
            {
                double avg;
                double min;
                double max;
                double stddev;
                List <DataManagerData> values = DataManager.GetDataForSensor(componentSensorId, start, end - start, DataManager.DateRangeType.day, DataManager.DateRangeType.second, out avg, out min, out max, out stddev);

                string     componentType = null;
                SensorType sensorName    = 0;
                var        aggStatus     = DataManager.GetAggregateData(componentSensorId, out min, out max, out avg, out stddev, out componentType, out sensorName);

                string JSON;
                if (aggStatus)
                {
                    JSON = "{\"id\": \"" + sensorId + "\", \"componentType\": \"" + componentType + "\", \"sensorType\": \"" + sensorName + "\", \"min\": " + Math.Round(min, 2) + ", \"max\": " + Math.Round(max, 2) + ", \"avg\": " + Math.Round(avg, 2) + ", \"stddev\": " + Math.Round(stddev, 2) + ", \"data\": [";
                }
                else
                {
                    JSON = "{\"id\": \"" + sensorId + "\", \"data\": [";
                }
                foreach (DataManagerData data in values)
                {
                    JSON += "[\"" + data.TimeStamp.ToString("yyyy/MM/dd HH:mm:ss") + " GMT\", " + data.Measure + "],";
                }
                JSON  = JSON.Remove(JSON.LastIndexOf(","));
                JSON += ("]}");

                var    responseContent = JSON.ToString();
                byte[] buffer          = Encoding.UTF8.GetBytes(responseContent);

                context.Response.ContentLength64 = buffer.Length;
                context.Response.ContentType     = "application/json";

                Stream outputStream = context.Response.OutputStream;
                outputStream.Write(buffer, 0, buffer.Length);
                outputStream.Close();
                return;
            }

            context.Response.OutputStream.Close();
            context.Response.StatusCode = 404;
            context.Response.Close();
        }
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestTagsMetricsPair()
        {
            MetricsServlet.TagsMetricsPair pair = new MetricsServlet.TagsMetricsPair(outputRecord
                                                                                     .GetTagsCopy(), outputRecord.GetMetricsCopy());
            string s = JSON.ToString(pair);

            Assert.Equal("[{\"testTag1\":\"testTagValue1\",\"testTag2\":\"testTagValue2\"},"
                         + "{\"testMetric1\":1,\"testMetric2\":33}]", s);
        }
Exemple #27
0
        public void Load(JSON js, string filePath)
        {
            ClearAll();

            SetFilePath(filePath);
            _name = js.ToString("name");

            JSON[] nodeListJS = js.ToArray <JSON>("bTree");
            for (int i = 0; i < nodeListJS.Length; ++i)
            {
                float           posX     = nodeListJS[i].ToFloat("posX");
                float           posY     = nodeListJS[i].ToFloat("posY");
                ZNode.BASE_TYPE baseType = ZEditorUtils.ParseEnum <ZNode.BASE_TYPE>(nodeListJS[i].ToString("baseType"));
                ZNode           newNode  = null;
                if (baseType == ZNode.BASE_TYPE.ROOT)
                {
                    newNode = CreateRoot(posX, posY);
                }
                else if (baseType == ZNode.BASE_TYPE.SUBTREE)
                {
                    newNode = CreateBaseNode(baseType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.COMPOSITE)
                {
                    ZNodeComposite.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZNodeComposite.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateCompositeNode(nodeType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.DECORATOR)
                {
                    ZNodeDecorator.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZNodeDecorator.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateDecoratorNode(nodeType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.ACTION)
                {
                    ZBTActionManager.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZBTActionManager.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateActionNode(nodeType, posX, posY, nodeListJS[i]);
                }
                newNode.Name = nodeListJS[i].ToString("id");
            }

            JSON[] connectionListJS = js.ToArray <JSON>("connections");
            for (int i = 0; i < connectionListJS.Length; ++i)
            {
                int            inId         = connectionListJS[i].ToInt("inNodeId");
                int            outId        = connectionListJS[i].ToInt("outNodeId");
                ZNodeConnector inConnector  = GetNode(inId).OutConnector;
                ZNodeConnector outConnector = GetNode(outId).InConnector;
                if (inConnector != null && outConnector != null)
                {
                    CreateConnection(inConnector, outConnector);
                }
                else
                {
                    Debug.Log("Unable to find in or out connector for node: " + inId.ToString() + " " + outId.ToString());
                }
            }
        }
Exemple #28
0
        public override string ToString()
        {
            if (JSON == null)
            {
                return(null);
            }

            return(JSON.ToString());
        }
        public SkuDetails(string jsonString)
        {
            JSON jSON = new JSON(jsonString);

            ItemType     = jSON.ToString("itemType");
            Sku          = jSON.ToString("sku");
            Type         = jSON.ToString("type");
            Price        = jSON.ToString("price");
            Title        = jSON.ToString("title");
            Description  = jSON.ToString("description");
            Json         = jSON.ToString("json");
            CurrencyCode = jSON.ToString("currencyCode");
            PriceValue   = jSON.ToString("priceValue");
            ParseFromJson();
        }
Exemple #30
0
        public Purchase(JSON json) {
            ItemType = json.ToString("itemType");
            OrderId = json.ToString("orderId");
            PackageName = json.ToString("packageName");
            Sku = json.ToString("sku");
            PurchaseTime = json.ToLong("purchaseTime");
            PurchaseState = json.ToInt("purchaseState");
            DeveloperPayload = json.ToString("developerPayload");
            Token = json.ToString("token");
            OriginalJson = json.ToString("originalJson");
            Signature = json.ToString("signature");
            AppstoreName = json.ToString("appstoreName");

			Sku = OpenIAB_iOS.StoreSku2Sku(Sku);
        }
Exemple #31
0
 public BattleActionData(JSON actionJS)
 {
     frame              = actionJS.ToInt("frame");
     framesToRun        = actionJS.ToInt("numFrames");
     id                 = actionJS.ToString("id");
     type               = (BattleActionTypes.TYPE)System.Enum.Parse(typeof(BattleActionTypes.TYPE), actionJS.ToString("type"));
     debug              = actionJS.ToBoolean("debug");
     pause              = actionJS.ToBoolean("pause");
     playTerminateLogic = actionJS.ToBoolean("resetOnEnd", true);
 }
Exemple #32
0
 private void OnPurchaseSucceeded(string sku)
 {
     if (purchaseSucceededEvent != null)
     {
         // sku actually is a serialzied dictionary with 2 keys (sku & receipt);
         // make a new JSON object to easily parse these out.
         JSON json_obj = new JSON(sku);
         purchaseSucceededEvent(Purchase.CreateFromSku(OpenIAB_iOS.StoreSku2Sku(json_obj.ToString("sku")), json_obj.ToString("receipt")));
     }
 }
Exemple #33
0
        private HttpWebRequest preSend(out string dstr)
        {
            dstr = "";
            try
            {
                switch (Method)
                {
                default:
                case XNetMethod.GET:
                    JSON dor = JSON.ParseFromURLData((_url.Query.Length > 0 ? _url.Query.Substring(1) : ""));
                    foreach (string k in d.ObjKeys)
                    {
                        if (dor.ObjExists(k))
                        {
                            dor[k] = d[k];
                        }
                        else
                        {
                            dor.ObjAdd(k, d[k]);
                        }
                    }
                    string xurl = _url.GetLeftPart(UriPartial.Path);
                    xurl += (dor.Count > 0 ? "?" + dor.ToURLData() : "");

                    r = (HttpWebRequest)WebRequest.Create(xurl);
                    break;

                case XNetMethod.POST:
                    if (_ctype == null || _ctype.Length <= 0)
                    {
                        _ctype = "application/json";
                    }
                    r = (HttpWebRequest)WebRequest.Create(_url);
                    switch (_ctype.ToLower())
                    {
                    case "application/json":
                        dstr = d.ToString();
                        break;

                    default:
                        dstr = "Protocol data '" + _ctype + "' not supported";
                        return(null);
                    }
                    r.ContentType = _ctype;
                    break;
                }
                r.Method = _method;
                return(r);
            }
            catch (Exception ex)
            {
                dstr = ex.Message;
                return(null);
            }
        }
Exemple #34
0
        public virtual Response Get(string path, string op)
        {
            Log.Info("get: " + Path + "=" + path + ", " + Op + "=" + op);
            IDictionary <string, object> m = new SortedDictionary <string, object>();

            m[Path] = path;
            m[Op]   = op;
            string js = JSON.ToString(m);

            return(Response.Ok(js).Type(MediaType.ApplicationJson).Build());
        }
Exemple #35
0
		private void ParseFromJson() {
			if (string.IsNullOrEmpty(Json)) return;
			var json = new JSON(Json);
			if (string.IsNullOrEmpty(PriceValue)) {
				float val = json.ToFloat("price_amount_micros");
				val /= 1000000;
				PriceValue = val.ToString();
			}
			if (string.IsNullOrEmpty(CurrencyCode))
				CurrencyCode = json.ToString("price_currency_code");
		}
Exemple #36
0
 public SkuDetails(string json)
 {
     var j = new JSON(json);
     ItemType = j.ToString("itemType");
     Sku = j.ToString("sku");
     Type = j.ToString("type");
     Price = j.ToString("price");
     Title = j.ToString("title");
     Description = j.ToString("description");
     Json = j.ToString("json");
 }