示例#1
0
    public void Init()
    {
        entityModels = XmlData.Deserialize <EntityModel>();
        foreach (var entityModel in entityModels)
        {
            entityModelCache[entityModel.baseId] = entityModel;
        }
        shopModels          = XmlData.Deserialize <ShopModel>();
        buildingLimitModels = XmlData.Deserialize <BuildingLimitModel>();
        rankModels          = XmlData.Deserialize <RankModel>();
        battleRewardModels  = XmlData.Deserialize <BattleRewardModel>();
        tipModels           = XmlData.Deserialize <TipModel>();
        try
        {
#if UNITY_EDITOR
            playerLocalDataVO = ExtensionMethods.DeSerialize <PlayerLocalDataVO>(Application.streamingAssetsPath + "/playerLocalDataModel.pbd");
#else
            playerLocalDataVO = ExtensionMethods.DeSerialize <PlayerLocalDataVO>(Application.persistentDataPath + "/playerLocalDataModel.pbd");
#endif
        }
        catch (Exception)
        {
            //pass new player
        }
    }
        public static QueryResponse Deserialize(XmlReader reader, QueryResponse queryResponse)
        {
            if (reader.IsStartElement(DTD.Response.TagQueryResponse))
            {
                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    #region <ERROR>
                    if (reader.IsStartElement(DTD.Response.ServiceResponse.TagError))
                    {
                        throw XMLErrorSerializer.Deserialize(reader.ReadSubtree());
                    }
                    #endregion <ERROR>

                    if (queryResponse == null)
                    {
                        queryResponse = new QueryResponse();
                    }

                    bool lIsHeadProcessed = false;
                    Dictionary <string, DataColumn> lHeadOid = null;
                    Dictionary <string, DataColumn> lHeadCol = null;
                    List <string> lDisplayset = null;
                    List <int>    lDuplicates = null;

                    do
                    {
                        #region <Head>.
                        if (reader.IsStartElement(DTD.Response.QueryResponse.TagHead))
                        {
                            string lClassName = string.Empty;
                            XmlHead.Deserialize(reader.ReadSubtree(), out lHeadOid, out lHeadCol, out lDisplayset, out lDuplicates, ref lClassName);
                            queryResponse.ClassName = lClassName;
                            lIsHeadProcessed        = true;
                        }
                        #endregion <Head>.
                        else
                        {
                            #region <Data>.
                            if (reader.IsStartElement(DTD.Response.QueryResponse.TagData))
                            {
                                if (lIsHeadProcessed)
                                {
                                    queryResponse.Data = XmlData.Deserialize(reader.ReadSubtree(), lHeadOid, lHeadCol, lDuplicates, queryResponse.ClassName);

                                    if (queryResponse.Data != null)
                                    {
                                        queryResponse.Data.ExtendedProperties.Add(DataTableProperties.DisplaySetNames, lDisplayset);
                                    }
                                }
                                else
                                {
                                    throw new ArgumentOutOfRangeException("Node Data from Query.Response is processed before Head node in Xml");
                                }
                            }
                            #endregion <Data>.
                            else
                            {
                                #region <?>
                                reader.Skip();
                                if (reader.NodeType == XmlNodeType.None)
                                {
                                    break;
                                }
                                else
                                {
                                    continue;
                                }
                                #endregion <?>
                            }
                        }
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException();
            }
            return(queryResponse);
        }