コード例 #1
0
        public void GetDataFrom(object item)
        {
            AppMsgInfo info = item as AppMsgInfo;

            if (info != null)
            {
                this.appid             = info.appid;
                this.sdkVer            = info.sdkVer;
                this.title             = info.title;
                this.description       = info.description;
                this.action            = info.action;
                this.type              = info.type;
                this.showtype          = info.showtype;
                this.content           = info.content;
                this.url               = info.url;
                this.lowurl            = info.lowurl;
                this.dataurl           = info.dataurl;
                this.lowdataurl        = info.lowdataurl;
                this.totallength       = info.totallength;
                this.attachid          = info.attachid;
                this.fileext           = info.fileext;
                this.extinfo           = info.extinfo;
                this.fromUserName      = info.fromUserName;
                this.mmreader          = info.mmreader;
                this.nChatMsgLocalID   = info.nChatMsgLocalID;
                this.itemType          = info.itemType;
                this.cdnattachurl      = info.cdnattachurl;
                this.cdnthumburl       = info.cdnthumburl;
                this.cdnthumblength    = info.cdnthumblength;
                this.cdnthumbheight    = info.cdnthumbheight;
                this.cdnthumbwidth     = info.cdnthumbwidth;
                this.aeskey            = info.aeskey;
                this.encryver          = info.encryver;
                this.nMsgLocalID       = info.nMsgLocalID;
                this.sourceusername    = info.sourceusername;
                this.sourcedisplayname = info.sourcedisplayname;
                this.httpthumburl      = info.httpthumburl;
                this.packageId         = info.packageId;
                this.packageFlag       = info.packageFlag;
            }
        }
コード例 #2
0
ファイル: AppMsgMgr.cs プロジェクト: kxlcn/android-weixin
        public static AppMsgInfo ParseAppXml(string strInXml)
        {
            string str = Util.preParaXml(strInXml);

            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }
            try
            {
                XElement element = null;
                element = XDocument.Parse(str).Element("msg");
                if (element == null)
                {
                    return(null);
                }
                AppMsgInfo info     = new AppMsgInfo();
                XElement   element2 = element.Element("fromusername");
                if (element2 != null)
                {
                    info.fromUserName = element2.Value;
                }
                XElement nodeappmsg = element.Element("appmsg");
                if (nodeappmsg != null)
                {
                    XAttribute attribute = nodeappmsg.Attribute("appid");
                    if (attribute != null)
                    {
                        info.appid = attribute.Value;
                    }
                    attribute = nodeappmsg.Attribute("sdkver");
                    if (attribute != null)
                    {
                        info.sdkVer = attribute.Value;
                    }
                    XElement element4 = nodeappmsg;
                    if (element4 != null)
                    {
                        XElement element5 = element4.Element("title");
                        if (element5 != null)
                        {
                            info.title = element5.Value;
                        }
                        XElement element6 = element4.Element("des");
                        if (element6 != null)
                        {
                            info.description = element6.Value;
                        }
                        XElement element7 = element4.Element("action");
                        if (element7 != null)
                        {
                            info.action = element7.Value;
                        }
                        XElement element8 = element4.Element("type");
                        if (element8 != null)
                        {
                            info.type = int.Parse(element8.Value);
                        }
                        XElement element9 = element4.Element("showtype");
                        if (element9 != null)
                        {
                            info.showtype = int.Parse(element9.Value);
                        }
                        XElement element10 = element4.Element("content");
                        if (element10 != null)
                        {
                            info.content = element10.Value;
                        }
                        XElement element11 = element4.Element("url");
                        if (element11 != null)
                        {
                            info.url = element11.Value;
                            //if (!string.IsNullOrEmpty(info.url) && EmotionStoreMgr.IsEmotionDetailUrl(info.url))
                            //{
                            //    info.packageId = EmotionStoreMgr.GetPackageIdFromUri(info.url);
                            //}
                        }
                        XElement element12 = element4.Element("lowurl");
                        if (element12 != null)
                        {
                            info.lowurl = element12.Value;
                        }
                        XElement element13 = element4.Element("dataurl");
                        if (element13 != null)
                        {
                            info.dataurl = element13.Value;
                        }
                        XElement element14 = element4.Element("lowdataurl");
                        if (element14 != null)
                        {
                            info.lowdataurl = element14.Value;
                        }
                        XElement element15 = element4.Element("thumburl");
                        if (element15 != null)
                        {
                            info.httpthumburl = element15.Value;
                        }
                        XElement element16 = element4.Element("appattach");
                        if (element16 != null)
                        {
                            XElement element17 = element16.Element("totallen");
                            if (element17 != null)
                            {
                                info.totallength = int.Parse(element17.Value);
                            }
                            XElement element18 = element16.Element("attachid");
                            if (element18 != null)
                            {
                                info.attachid = element18.Value;
                            }
                            XElement element19 = element16.Element("emoticonmd5");
                            if (element19 != null)
                            {
                                info.emoticonmd5 = element19.Value;
                            }
                            XElement element20 = element16.Element("fileext");
                            if (element20 != null)
                            {
                                info.fileext = element20.Value;
                            }
                            XElement element21 = element16.Element("cdnattachurl");
                            if (element21 != null)
                            {
                                info.cdnattachurl = element21.Value;
                            }
                            XElement element22 = element16.Element("cdnthumburl");
                            if (element22 != null)
                            {
                                info.cdnthumburl = element22.Value;
                            }
                            XElement element23 = element16.Element("cdnthumblength");
                            if (element23 != null && element23.Value != "")
                            {
                                info.cdnthumblength = int.Parse(element23.Value);
                            }
                            XElement element24 = element16.Element("cdnthumbheight");
                            if (element24 != null && element24.Value != "")
                            {
                                info.cdnthumbheight = int.Parse(element24.Value);
                            }
                            XElement element25 = element16.Element("cdnthumbwidth");
                            if (element25 != null && element25.Value != "")
                            {
                                info.cdnthumbwidth = int.Parse(element25.Value);
                            }
                            XElement element26 = element16.Element("aeskey");
                            if (element26 != null)
                            {
                                info.aeskey = element26.Value;
                            }
                            XElement element27 = element16.Element("encryver");
                            if (element27 != null)
                            {
                                info.encryver = element27.Value;
                            }
                        }
                        XElement element28 = element4.Element("extinfo");
                        if (element28 != null)
                        {
                            info.extinfo = element28.Value;
                        }
                        XElement element29 = element4.Element("sourceusername");
                        if (element29 != null)
                        {
                            info.sourceusername = element29.Value;
                        }
                        XElement element30 = element4.Element("sourcedisplayname");
                        if (element30 != null)
                        {
                            info.sourcedisplayname = element30.Value;
                        }
                        XElement element31 = element4.Element("emoticonshared");
                        if (element31 != null)
                        {
                            XElement element32 = element31.Element("packageid");
                            if (element32 != null)
                            {
                                info.packageId = element32.Value;
                            }
                            XElement element33 = element31.Element("packageflag");
                            if (element33 != null && element33.Value != "")
                            {
                                info.packageFlag = int.Parse(element33.Value);
                            }
                        }
                        XElement     element34 = element4.Element("mmreader");
                        MMReaderInfo info2     = null;
                        if (element34 != null)
                        {
                            element34 = element34.Element("category");
                            if (element34 != null)
                            {
                                info2 = new MMReaderInfo();
                                XAttribute attribute2 = element34.Attribute("type");
                                if (attribute2 != null && !string.IsNullOrEmpty(element34.Value))
                                {
                                    info2.type = int.Parse(attribute2.Value);
                                }
                                attribute2 = element34.Attribute("count");
                                if (attribute2 != null && !string.IsNullOrEmpty(attribute2.Value))
                                {
                                    info2.count = int.Parse(attribute2.Value);
                                }
                                XElement element35 = element34.Element("name");
                                if (element35 != null)
                                {
                                    info2.name = element35.Value;
                                }
                                XElement element36 = element34.Element("topnew");
                                if (element36 != null)
                                {
                                    MMReaderTopNew new2      = new MMReaderTopNew();
                                    XElement       element37 = element36.Element("cover");
                                    if (element37 != null)
                                    {
                                        new2.cover = element37.Value;
                                    }
                                    element37 = element36.Element("width");
                                    if ((element37 != null) && !string.IsNullOrEmpty(element37.Value))
                                    {
                                        new2.width = int.Parse(element37.Value);
                                    }
                                    element37 = element36.Element("height");
                                    if ((element37 != null) && !string.IsNullOrEmpty(element37.Value))
                                    {
                                        new2.height = int.Parse(element37.Value);
                                    }
                                    info2.topnew = new2;
                                }
                                IEnumerable <XElement> enumerable = element34.Elements("item");
                                if (enumerable != null)
                                {
                                    List <MMReaderItem> list = new List <MMReaderItem>();
                                    foreach (XElement element38 in enumerable)
                                    {
                                        MMReaderItem item = new MMReaderItem();
                                        if (element38 != null)
                                        {
                                            XElement element39 = element38.Element("title");
                                            if (element39 != null)
                                            {
                                                item.title = element39.Value;
                                            }
                                            XElement element40 = element38.Element("digest");
                                            if (element40 != null)
                                            {
                                                item.digest = element40.Value;
                                            }
                                            XElement element41 = element38.Element("url");
                                            if (element41 != null)
                                            {
                                                item.url = element41.Value;
                                            }
                                            XElement element42 = element38.Element("shorturl");
                                            if (element42 != null)
                                            {
                                                item.shorturl = element42.Value;
                                            }
                                            XElement element43 = element38.Element("longurl");
                                            if (element43 != null)
                                            {
                                                item.longurl = element43.Value;
                                            }
                                            XElement element44 = element38.Element("pub_time");
                                            if (element44 != null)
                                            {
                                                item.pub_time = long.Parse(element44.Value);
                                            }
                                            XElement element45 = element38.Element("cover");
                                            if (element45 != null)
                                            {
                                                item.cover = element45.Value;
                                            }
                                            XElement element46 = element38.Element("tweetid");
                                            if (element46 != null)
                                            {
                                                item.tweetid = element46.Value;
                                            }
                                            XElement element47 = element38.Element("itemshowtype");

                                            if (element47 != null && !string.IsNullOrEmpty(element47.Value))
                                            {
                                                //int.TryParse(element47.Value, out item.itemshowtype);
                                                item.itemshowtype = int.Parse(element47.Value);
                                            }
                                            XElement element48 = element38.Element("sources");
                                            if ((element48 != null) && (element48.Elements("source") != null))
                                            {
                                                List <MMReaderItemSource> list2 = new List <MMReaderItemSource>();
                                                foreach (XElement element49 in enumerable)
                                                {
                                                    MMReaderItemSource source    = new MMReaderItemSource();
                                                    XElement           element50 = element49.Element("name");
                                                    if (element50 != null)
                                                    {
                                                        source.name = element50.Value;
                                                    }
                                                    XElement element51 = element49.Element("icon");
                                                    if (element51 != null)
                                                    {
                                                        source.icon = element51.Value;
                                                    }
                                                    list2.Add(source);
                                                }
                                                if (list2.Count != 0)
                                                {
                                                    item.sources = list2;
                                                }
                                            }
                                            XElement element52 = element38.Element("styles");
                                            if (element52 != null)
                                            {
                                                item.styles = new MMReaderItemStyles();
                                                XElement element53 = element52.Element("topColor");
                                                if (element53 != null)
                                                {
                                                    item.styles.topColor = element53.Value;
                                                }
                                                IEnumerable <XElement> enumerable3 = element52.Elements("style");
                                                if (enumerable3 != null)
                                                {
                                                    List <MMReaderItemStyleItem> list3 = new List <MMReaderItemStyleItem>();
                                                    foreach (XElement element54 in enumerable3)
                                                    {
                                                        MMReaderItemStyleItem item2 = new MMReaderItemStyleItem();
                                                        XElement element55          = element54.Element("range");
                                                        if (element55 != null)
                                                        {
                                                            item2.range = element55.Value;
                                                        }
                                                        XElement element56 = element54.Element("font");
                                                        if (element56 != null)
                                                        {
                                                            item2.font = element56.Value;
                                                        }
                                                        XElement element57 = element54.Element("color");
                                                        if (element57 != null)
                                                        {
                                                            item2.color = element57.Value;
                                                        }
                                                        list3.Add(item2);
                                                    }
                                                    if (list3.Count != 0)
                                                    {
                                                        item.styles.styleList = list3;
                                                    }
                                                }
                                                IEnumerable <XElement> enumerable4 = element52.Elements("line");
                                                if (enumerable4 != null)
                                                {
                                                    List <MMReaderItemLineItem> list4 = new List <MMReaderItemLineItem>();
                                                    foreach (XElement element58 in enumerable4)
                                                    {
                                                        MMReaderItemLineItem item3     = new MMReaderItemLineItem();
                                                        XElement             element59 = element58.Element("offset");
                                                        if (element59 != null)
                                                        {
                                                            int.TryParse(element59.Value, out item3.offset);
                                                        }
                                                        XElement element60 = element58.Element("font");
                                                        if (element60 != null)
                                                        {
                                                            item3.font = element60.Value;
                                                        }
                                                        XElement element61 = element58.Element("color");
                                                        if (element61 != null)
                                                        {
                                                            item3.color = element61.Value;
                                                        }
                                                        XElement element62 = element58.Element("chars");
                                                        if (element62 != null)
                                                        {
                                                            item3.chars = element62.Value;
                                                        }
                                                        list4.Add(item3);
                                                    }
                                                    if (list4.Count != 0)
                                                    {
                                                        item.styles.lineList = list4;
                                                    }
                                                }
                                            }
                                            list.Add(item);
                                        }
                                    }
                                    if (list.Count != 0)
                                    {
                                        info2.items = list;
                                    }
                                }
                            }
                        }
                        info.mmreader = info2;
                    }
                }
                if ((info.type == 0x7d0) || (info.type == 0x7d1))
                {
                    info.payinfoitem = WCPayInfoItem.fromXElement(nodeappmsg);
                }
                return(info);
            }
            catch (Exception exception)
            {
                Log.e("AppMsgMgr", exception.ToString() + str);
                return(null);
            }
        }