コード例 #1
0
        /* * * * * * * * * * * * * * * * * * * * * * * * * * *
        * OVERRIDED METHODS
        * * * * * * * * * * * * * * * * * * * * * * * * * * */
        public IParseble Parse(JSONNode rootNode)
        {
//			textAll = new XsollaTextAll ();
//			textAll.Parse (rootNode[XsollaApiConst.R_TEXTALL]);
            JSONNode errorNode = rootNode [XsollaApiConst.ERROR_MSG];

            if (errorNode != null && errorNode.GetType() != typeof(JSONLazyCreator))
            {
                this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
            }
            //errorNode = rootNode [XsollaApiConst.R_TEXTALL] [XsollaApiConst.ERROR_MSG][0];
            errorNode = rootNode ["errors"][0];
            if (errorNode != null)
            {
                this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
            }
            this.SetAccount(rootNode [XsollaApiConst.R_ACCOUNT]);
            this.SetAccountXsolla(rootNode [XsollaApiConst.R_ACCOUNTXSOLLA]);
            this.SetCurrentCommand(rootNode[XsollaApiConst.R_CURRENTCOMMAND]);
            this.SetTitle(rootNode[XsollaApiConst.R_TITLE]);
            this.SetIconUrl(rootNode[XsollaApiConst.R_ICONURL]);
            this.SetCurrency(rootNode[XsollaApiConst.R_CURRENCY]);
            this.SetSum(rootNode[XsollaApiConst.R_BUYDATA]["sum"]);
            this.SetInstruction(rootNode[XsollaApiConst.R_INSTRUCTION]);
            this.SetPid(rootNode[XsollaApiConst.R_PID].AsInt);

            checkoutToken = rootNode ["checkoutToken"];
            JSONNode buyDataNode = rootNode ["buyData"];

            if (buyDataNode != null && !"null".Equals(buyDataNode))
            {
                buyData = new BuyData().Parse(buyDataNode) as BuyData;
            }

            JSONNode summaryNode = rootNode ["summary"];

            if (summaryNode != null && !"null".Equals(summaryNode))
            {
                summary = new XsollaSummary().Parse(summaryNode) as XsollaSummary;
            }

            JSONNode checkoutNode = rootNode ["checkout"];

            if (checkoutNode != null && !"null".Equals(checkoutNode))
            {
                chekout = new XsollaCheckout().Parse(checkoutNode) as XsollaCheckout;
            }

            JSONNode formNode = rootNode [XsollaApiConst.R_FORM];
            IEnumerable <JSONNode> formElements = formNode.Childs;
            IEnumerator <JSONNode> enumerator   = formElements.GetEnumerator();

            this.Clear();
            while (enumerator.MoveNext())
            {
                this.AddElement((XsollaFormElement) new XsollaFormElement().Parse(enumerator.Current));
            }
            return(this);
        }
コード例 #2
0
ファイル: XsollaForm.cs プロジェクト: xsolla/xsolla-unity-sdk
        /* * * * * * * * * * * * * * * * * * * * * * * * * * *
        * OVERRIDED METHODS
        * * * * * * * * * * * * * * * * * * * * * * * * * * */
        //            if (errorNode != null && errorNode.GetType() != typeof(JSONLazyCreator))
        //            {
        //                this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
        //            }
        //            //errorNode = rootNode [XsollaApiConst.R_TEXTALL] [XsollaApiConst.ERROR_MSG][0];
        //            errorNode = rootNode ["errors"][0];
        //            if (errorNode != null)
        //            {
        //                this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
        //            }
        public IParseble Parse(JSONNode rootNode)
        {
            JSONNode errorNode = rootNode [XsollaApiConst.R_ERRORS];
            if(errorNode.Count > 0)
                this.xsollaError = new XsollaError().ParseNew(errorNode[0]) as XsollaError;

            JSONNode messagesNode = rootNode [XsollaApiConst.R_MESSAGES];
            if (messagesNode.Count > 0)
                this.xsollaMessage = new XsollaMessage ().Parse (messagesNode[0]) as XsollaMessage;

            this.SetAccount (rootNode [XsollaApiConst.R_ACCOUNT]);
            this.SetAccountXsolla (rootNode [XsollaApiConst.R_ACCOUNTXSOLLA]);
            this.SetCurrentCommand (rootNode[XsollaApiConst.R_CURRENTCOMMAND]);
            this.SetTitle (rootNode[XsollaApiConst.R_TITLE]);
            this.SetIconUrl (rootNode[XsollaApiConst.R_ICONURL]);
            this.SetCurrency (rootNode[XsollaApiConst.R_CURRENCY]);
            this.SetSum (rootNode[XsollaApiConst.R_BUYDATA]["sum"]);
            this.SetInstruction (rootNode[XsollaApiConst.R_INSTRUCTION]);
            this.SetPid (rootNode[XsollaApiConst.R_PID].AsInt);
            this.SetSkipForm(rootNode[XsollaApiConst.R_SKIPFORM].AsBool);
            this.SetSkipCheckout(rootNode[XsollaApiConst.R_SKIPCHECKOUT].AsBool);

            checkoutToken = rootNode ["checkoutToken"];
            JSONNode buyDataNode = rootNode ["buyData"];
            if (buyDataNode != null && !"null".Equals (buyDataNode)) {
                buyData = new BuyData ().Parse (buyDataNode) as BuyData;
            }

            JSONNode summaryNode = rootNode ["summary"];
            if (summaryNode != null && !"null".Equals(summaryNode)) {
                summary = new XsollaSummary ().Parse (summaryNode) as XsollaSummary;
            }

            JSONNode checkoutNode = rootNode ["checkout"];
            if(checkoutNode != null && !"null".Equals(checkoutNode)){
                chekout = new XsollaCheckout ().Parse (checkoutNode) as XsollaCheckout;
            }

            JSONNode formNode = rootNode [XsollaApiConst.R_FORM];
            IEnumerable<JSONNode> formElements = formNode.Childs;
            IEnumerator<JSONNode> enumerator = formElements.GetEnumerator();
            this.Clear ();
            while(enumerator.MoveNext())
            {
                this.AddElement((XsollaFormElement)new XsollaFormElement().Parse(enumerator.Current));
            }
            return this;
        }
コード例 #3
0
        /* * * * * * * * * * * * * * * * * * * * * * * * * * *
        * OVERRIDED METHODS
        * * * * * * * * * * * * * * * * * * * * * * * * * * */

        //			if (errorNode != null && errorNode.GetType() != typeof(JSONLazyCreator))
        //			{
        //				this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
        //			}
        //			//errorNode = rootNode [XsollaApiConst.R_TEXTALL] [XsollaApiConst.ERROR_MSG][0];
        //			errorNode = rootNode ["errors"][0];
        //			if (errorNode != null)
        //			{
        //				this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
        //			}
        public IParseble Parse(JSONNode rootNode)
        {
            JSONNode errorNode = rootNode [XsollaApiConst.R_ERRORS];

            if (errorNode.Count > 0)
            {
                this.xsollaError = new XsollaError().ParseNew(errorNode[0]) as XsollaError;
            }

            JSONNode messagesNode = rootNode [XsollaApiConst.R_MESSAGES];

            if (messagesNode.Count > 0)
            {
                this.xsollaMessage = new XsollaMessage().Parse(messagesNode[0]) as XsollaMessage;
            }

            this.SetAccount(rootNode [XsollaApiConst.R_ACCOUNT]);
            this.SetAccountXsolla(rootNode [XsollaApiConst.R_ACCOUNTXSOLLA]);
            this.SetCurrentCommand(rootNode[XsollaApiConst.R_CURRENTCOMMAND]);
            this.SetTitle(rootNode[XsollaApiConst.R_TITLE]);
            this.SetIconUrl(rootNode[XsollaApiConst.R_ICONURL]);
            this.SetCurrency(rootNode[XsollaApiConst.R_CURRENCY]);
            this.SetSum(rootNode[XsollaApiConst.R_BUYDATA]["sum"]);
            this.SetInstruction(rootNode[XsollaApiConst.R_INSTRUCTION]);
            this.SetPid(rootNode[XsollaApiConst.R_PID].AsInt);
            this.SetSkipForm(rootNode[XsollaApiConst.R_SKIPFORM].AsBool);
            this.SetSkipCheckout(rootNode[XsollaApiConst.R_SKIPCHECKOUT].AsBool);

            checkoutToken = rootNode ["checkoutToken"];
            JSONNode buyDataNode = rootNode ["buyData"];

            if (buyDataNode != null && !"null".Equals(buyDataNode))
            {
                buyData = new BuyData().Parse(buyDataNode) as BuyData;
            }

            JSONNode summaryNode = rootNode ["summary"];

            if (summaryNode != null && !"null".Equals(summaryNode))
            {
                summary = new XsollaSummary().Parse(summaryNode) as XsollaSummary;
            }

            JSONNode checkoutNode = rootNode ["checkout"];

            if (checkoutNode != null && !"null".Equals(checkoutNode))
            {
                chekout = new XsollaCheckout().Parse(checkoutNode) as XsollaCheckout;
            }

            JSONNode formNode = rootNode [XsollaApiConst.R_FORM];
            IEnumerable <JSONNode> formElements = formNode.Childs;
            IEnumerator <JSONNode> enumerator   = formElements.GetEnumerator();

            this.Clear();
            while (enumerator.MoveNext())
            {
                this.AddElement((XsollaFormElement) new XsollaFormElement().Parse(enumerator.Current));
            }
            return(this);
        }