예제 #1
0
 public void WriteDocument(RootElement root)
 {
     base.WriteHeader();
     WriteElement(root);
 }
예제 #2
0
        public static EComMessage CreateMessageFromElement(RootElement element)
        {
            // temp for Mobile Vikings
            EComMessage msg = null;
            if (!element.HasAttributes)
                throw new ApplicationException("received an element without attributes: " + element.Tag);
            switch (element.Tag)
            {
                case Tag.Req:
                    msg = new RequestMessage(element);
                    break;
                case Tag.Rsp:
                    msg = new ResponseMessage(element);
                    break;
                default:
                    throw new ApplicationException("message tag not supported: " + element.Tag);
            }
            msg.tempRootElement = element;
            return msg;

            //EComMessage msg = null;
            //if (!element.HasAttributes)
            //    throw new ApplicationException("received an element without attributes: " + element.Tag);
            //switch (element.Tag)
            //{
            //    case Tag.Req:
            //        string app = element[Comtech.Wbxml.Attribute.App];
            //        string id = element[Comtech.Wbxml.Attribute.Id];
            //        if (id == "topup")
            //            msg = new AuthorizationMessage(element);
            //        //else if (id == "voucher")
            //        //	msg = new AuthorizationMessage(element);
            //        //else if (id == "reversal")
            //        //	msg = new AuthorizationMessage(element);
            //        else if (id == "checktopup")
            //            msg = new AuthorizationMessage(element);
            //        else if (id == "closeday")
            //            msg = new CloseDayMessage(element);
            //        else if (id == "balance")
            //            msg = new BalanceMessage(element);
            //        else if (id == "history")
            //            msg = new HistoryMessage(element);
            //        else if (id == "billinfo")
            //            msg = new BillInfoMessage(element);
            //        else if (id == "billpayment")
            //            msg = new BillPaymentMessage(element);
            //        else if (id == "problemreport")
            //            msg = new ProblemReportMessage(element);
            //        else if (id == "4gsecure")
            //            msg = new _4GSecureMessage(element);
            //        else if (id == "handshake")
            //            msg = new HandshakeMessage(element);
            //        else if (id == "download")
            //            msg = new DownloadMessage(element);
            //        else if (id == "notify")
            //            msg = new NotificationMessage(element);
            //        else
            //            throw new ApplicationException(String.Format("message id not supported: {0} {1}", app, id));
            //        break;
            //    case Tag.Rsp:
            //        // for terminal simulator
            //        // hack
            //        if (element.Attributes.ContainsKey(Comtech.Wbxml.Attribute.Ftp))
            //        {
            //            msg = new DownloadResponseMessage(element);
            //        }
            //        else
            //        {
            //            msg = new ResponseMessage(element);
            //        }
            //        break;
            //    default:
            //        throw new ApplicationException("message tag not supported: " + element.Tag);
            //}
            //return msg;
        }
예제 #3
0
 public WbxmlParser(byte[] buffer, Encoding encoding)
 {
     MemoryStream ms = new MemoryStream(buffer);
     rootElement = RootElement.ReadFromStreamWithHeader(ms, encoding);
 }