示例#1
0
        public static List <Packet> LoadPackets()
        {
            List <Packet> list     = new List <Packet>();
            MetaData      metaData = MetaDataLoader.Load();

            Grouper.GroupingSuperKeyword(metaData);
            foreach (SuperKeyword sk in metaData.superKeywords)
            {
                Packet packet = new Packet();
                if (sk.simple)
                {
                    packet.title = sk.keyword;
                }
                else if (sk.keyword == "*")
                {
                    packet.title = string.Format("【{0}】的作品集", sk.authors[0]);
                }
                else if (sk.authors[0] == "*")
                {
                    packet.title = string.Format("专题:【{0}】", sk.keyword);
                }
                else
                {
                    packet.title = string.Format("【{0}】系列", sk.keyword);
                }
                packet.author   = sk.authors[0];
                packet.simple   = sk.simple;
                packet.chapters = new List <Chapter>();
                foreach (Group g in sk.groupedTids)
                {
                    BBSThread example  = metaData.threads[g.exampleId];
                    string    filename = example.siteId + "/" + example.threadId;
                    Chapter   ch       = new Chapter();
                    ch.id        = filename;
                    ch.title     = example.title;
                    ch.author    = example.author;
                    ch.source    = Constants.SITE_DEF[example.siteId].siteName;
                    ch.savePath  = filename;
                    ch.timestamp = Utils.GetTimestamp(example.postTime);
                    packet.chapters.Add(ch);
                }
                packet.chapters.Sort((x1, x2) => x2.timestamp.CompareTo(x1.timestamp));
                packet.timestamp = packet.chapters[0].timestamp;
                packet.key       = Utils.CalcKey(packet.title, packet.author, sk.simple);
                packet.summary   = Utils.CalcSumary(packet.title, packet.author, sk.simple, packet.chapters, null);
                packet.source    = "Forum";
                list.Add(packet);
            }
            list.Sort((x1, x2) => x2.timestamp.CompareTo(x1.timestamp));
            string packetFolder = Constants.LOCAL_PATH + "packets";

            foreach (string f in Directory.EnumerateFiles(packetFolder))
            {
                Packet packet = LoadPacketFromZip(f);
                list.Add(packet);
            }
            return(list);
        }
示例#2
0
        public CldrLoader(string rootPath, CldrLoadOptions loadOptions = CldrLoadOptions.Normal)
        {
            if (File.Exists(rootPath))
            {
                _zip = ZipFile.OpenRead(rootPath);
            }
            else
            {
                DirectoryInfo info = new DirectoryInfo(rootPath);
                if (!info.Exists)
                {
                    throw new DirectoryNotFoundException(info.FullName);
                }
                rootPath = info.FullName;
                if (!Directory.Exists(Path.Combine(rootPath, "main")))
                {
                    rootPath = Path.Combine(rootPath, "common");
                    if (!Directory.Exists(Path.Combine(rootPath, "main")))
                    {
                        throw new FileLoadException("Not a valid CLDR folder");
                    }
                }
                Root = rootPath;
            }
            _scripts = XUtil.GetScriptMap();
            MetaDataLoader loader = new MetaDataLoader(this);

            using (XmlReader reader = OpenXmlFile("supplemental", "supplementalMetadata")) {
                loader.LoadMetaData(reader);
            }

            if ((loadOptions & CldrLoadOptions.Subdivision) != 0)
            {
                using (XmlReader reader = TryOpenXmlFile("supplemental", "subdivisions")) {
                    if (reader != null)
                    {
                        loader.LoadSubdivisions(reader);
                    }
                    else
                    {
                        loadOptions &= ~CldrLoadOptions.Subdivision;
                    }
                }
            }
            LoadOptions = loadOptions;

            using (XmlReader reader = OpenXmlFile("supplemental", "supplementalData")) {
                loader.Load(reader);
            }
            foreach (string name in GetAllLocaleNames())
            {
                GetLocaleInfo(name).HasFile = true;
            }
        }