Ejemplo n.º 1
0
    public string SerializeABPackData()
    {
        Dictionary <string, List <Resolver.AssetItem> > ssab;

        if (System.IO.File.Exists(GetShardABFileName()))
        {
            string[] lines = System.IO.File.ReadAllLines(GetShardABFileName());
            string   s     = "";
            foreach (var item in lines)
            {
                s += item;
            }
            ssab = Resolver.DeserializSharedItem(s);
        }
        else
        {
            ssab = new Dictionary <string, List <Resolver.AssetItem> >();
        }

        List <SharedItem> tempdataitems = new List <SharedItem>(abPack.Count);

        foreach (string key in abPack.Keys)
        {
            List <AssetItem> vals = new List <AssetItem>();
            foreach (var item in abPack[key])
            {
                if (item != "")//没有依赖的场景
                {
                    string v     = sharedFiles[item];
                    int    index = v.IndexOf(RELATED_ROOT_PATH);
                    string name  = v.Substring(index);

                    bool b = true;
                    if (ssab.ContainsKey(key))
                    {
                        for (int i = 0; i < ssab[key].Count; i++)
                        {
                            if (ssab[key][i].Name == name)
                            {
                                b = false;
                                break;
                            }
                        }
                    }
                    vals.Add(new AssetItem(name));
                }
            }
            tempdataitems.Add(new SharedItem(key, vals));
        }

        XmlSerializer           serializer = new XmlSerializer(typeof(List <SharedItem>));
        StringWriter            sw         = new StringWriter();
        XmlSerializerNamespaces ns         = new XmlSerializerNamespaces();

        ns.Add("", "");

        serializer.Serialize(sw, tempdataitems, ns);

        return(sw.ToString());
    }