コード例 #1
0
        public override List <ContentProviderOperation> Parse(XDocument input, ContentResolver resolver)
        {
            List <ContentProviderOperation> batch = new List <ContentProviderOperation>();

            // Clear any existing static blocks, as they may have been updated.
            String selection = ScheduleContract.Blocks.BLOCK_TYPE + "=? OR " + ScheduleContract.Blocks.BLOCK_TYPE + "=?";

            String[] selectionArgs =
            {
                ParserUtils.BlockTypeFood,
                ParserUtils.BlockTypeOfficeHours
            };
            batch.Add(ContentProviderOperation.NewDelete(ScheduleContract.Blocks.CONTENT_URI).WithSelection(selection, selectionArgs).Build());

            var blocks = from x in input.Descendants("block")
                         select new BlocksXml
            {
                StartTime = ParserUtils.ParseTime(x.Element("start").Value),
                EndTime   = ParserUtils.ParseTime(x.Element("end").Value),
                Title     = x.Element("title").Value,
                BlockType = x.Element("type") != null?x.Element("type").Value : ""
            };

            foreach (var item in blocks)
            {
                batch.Add(ParseBlock(item));
            }

            return(batch);
        }
コード例 #2
0
        public override List <ContentProviderOperation> Parse(XDocument input, ContentResolver resolver)
        {
            List <ContentProviderOperation> batch = new List <ContentProviderOperation>();

            var sessions = from x in input.Descendants("session")
                           select new SessionXml
            {
                Start     = ParserUtils.ParseTime(x.Element("start").Value),
                End       = ParserUtils.ParseTime(x.Element("end").Value),
                RoomId    = ScheduleContract.Rooms.GenerateRoomId(x.Element("room").Value),
                TrackId   = ScheduleContract.Tracks.GenerateTrackId(x.Element("track").Value),
                Title     = x.Element("title").Value,
                SessionId = x.Element("id") != null?x.Element("id").Value             : null,
                Abstract  = x.Element("abstract") != null?x.Element("abstract").Value : null
            };

            Console.WriteLine("Sessions = " + sessions.Count());

            foreach (var item in sessions)
            {
                ParseSessions(item, batch, resolver);
            }

            return(batch);
        }