//////////////////////////////////////////////////////////////////////
        /// <summary>parses the inner state of the element</summary>
        /// <param name="e">the Event arguments</param>
        /// <param name="parser">the atomFeedParser that called this</param>
        //////////////////////////////////////////////////////////////////////
        public override void Parse(ExtensionElementEventArgs e, AtomFeedParser parser)
        {
            XmlNode eventNode = e.ExtensionElement;

            Tracing.TraceMsg(eventNode.LocalName);
            // Ensure that the namespace is correct.
            if (String.Compare(eventNode.NamespaceURI,
                GCodeSearchParserNameTable.CSNamespace, true) == 0)
            {
                // Parse a File Element
                if (eventNode.LocalName == GCodeSearchParserNameTable.EVENT_FILE)
                {
                    file = File.ParseFile(eventNode, parser);
                    e.DiscardEntry = true;
                }
                    // Parse a Package Element
                else if ((eventNode.LocalName == GCodeSearchParserNameTable.EVENT_PACKAGE))
                {
                    package = Package.ParsePackage(eventNode, parser);
                    e.DiscardEntry = true;
                }
                    // Parse Match Elements 
                else if (eventNode.LocalName == GCodeSearchParserNameTable.EVENT_MATCH)
                {
                    matches.Add(Match.ParseMatch(eventNode, parser));
                    e.DiscardEntry = true;
                } 
            }
        }
Ejemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////////////
        #endregion


        /// <summary>
        /// Parses the inner state of the element
        /// </summary>
        /// <param name="e">The extension element that should be added to this entry</param>
        /// <param name="parser">The AtomFeedParser that called this</param>
        public virtual void Parse(ExtensionElementEventArgs e, AtomFeedParser parser)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }


            Tracing.TraceMsg("Entering Parse on AbstractEntry");
            XmlNode node = e.ExtensionElement;

            if (this.ExtensionFactories != null && this.ExtensionFactories.Count > 0)
            {
                Tracing.TraceMsg("Entring default Parsing for AbstractEntry");

                IExtensionElementFactory f = FindExtensionFactory(node.LocalName,
                                                                  node.NamespaceURI);
                if (f != null)
                {
                    this.ExtensionElements.Add(f.CreateInstance(node, parser));
                    e.DiscardEntry = true;
                }
            }
            return;
        }
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a GsaExtension object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created GsaExtension object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            GsaExtension gsa = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                  node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return null;
                }
            }

            gsa = new GsaExtension();
            
            if (node != null)
            {
                if (node.Attributes == null || node.Attributes[PropertyName] == null)
                {
                    throw new ArgumentException("GsaContent name can not found in this name space");
                }
                gsa.ContentName = node.Attributes[PropertyName].Value;
                gsa.ContentValue = node.InnerText == null ? "" : node.InnerText;
            }
            return gsa;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// parses a single error element
        /// </summary>
        /// <param name="reader">XmlReader positioned at the start of the status element</param>
        /// <param name="parser">the feedparser to be used</param>
        /// <returns>GDataBatchError</returns>
        public static GDataBatchError ParseBatchError(XmlReader reader, AtomFeedParser parser)
        {
            if (reader == null)
            {
                throw new System.ArgumentNullException("reader");
            }

            object          localname = reader.LocalName;
            GDataBatchError error     = null;

            if (localname.Equals(parser.Nametable.BatchError))
            {
                error = new GDataBatchError();
                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        localname = reader.LocalName;
                        if (localname.Equals(parser.Nametable.BatchReason))
                        {
                            error.Reason = Utilities.DecodedValue(reader.Value);
                        }
                        else if (localname.Equals(parser.Nametable.Type))
                        {
                            error.Type = Utilities.DecodedValue(reader.Value);
                        }
                        else if (localname.Equals(parser.Nametable.BatchField))
                        {
                            error.Field = Utilities.DecodedValue(reader.Value);
                        }
                    }
                }
            }
            return(error);
        }
Ejemplo n.º 5
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a File object.</summary> 
        /// <param name="node">File node</param>
        /// <param name="parser">AtomFeedParser to use</param>
        /// <returns>the created File object</returns>
        //////////////////////////////////////////////////////////////////////
        public static File ParseFile(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            File file = null;
            Tracing.Assert(node != null, "node should not be null");
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            // Ensure that the namespace is correct.
            if (String.Compare(node.NamespaceURI,
                GCodeSearchParserNameTable.CSNamespace, true) == 0)
            {
                file = new File();
                if (node.Attributes != null)
                {
                    file.filename =
                        node.Attributes[
                        GCodeSearchParserNameTable.ATTRIBUTE_NAME].Value;
                }
                else 
                {
                    throw new ArgumentNullException(
                        BaseNameTable.gBatchNamespace +
                        ":" + GCodeSearchParserNameTable.EVENT_FILE + " must contain exactly one "
                        + GCodeSearchParserNameTable.ATTRIBUTE_NAME + " attribute");
                }
            }
            return file;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// reads the current positioned reader and creates a batchstatus element
        /// </summary>
        /// <param name="reader">XmlReader positioned at the start of the status element</param>
        /// <param name="parser">The Feedparser to be used</param>
        /// <returns>GDataBatchStatus</returns>
        public static GDataBatchStatus ParseBatchStatus(XmlReader reader, AtomFeedParser parser)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            GDataBatchStatus status = null;

            object localname = reader.LocalName;

            if (localname.Equals(parser.Nametable.BatchStatus))
            {
                status = new GDataBatchStatus();
                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        localname = reader.LocalName;
                        if (localname.Equals(parser.Nametable.BatchReason))
                        {
                            status.Reason = Utilities.DecodedValue(reader.Value);
                        }
                        else if (localname.Equals(parser.Nametable.BatchContentType))
                        {
                            status.ContentType = Utilities.DecodedValue(reader.Value);
                        }
                        else if (localname.Equals(parser.Nametable.BatchStatusCode))
                        {
                            status.Code = int.Parse(Utilities.DecodedValue(reader.Value), CultureInfo.InvariantCulture);
                        }
                    }
                }

                reader.MoveToElement();

                // FIX: THIS CODE SEEMS TO MAKE AN INFINITE LOOP WITH NextChildElement()

                int lvl = -1;
                // status can have one child element, errors
                while (Utilities.NextChildElement(reader, ref lvl))
                {
                    localname = reader.LocalName;

                    if (localname.Equals(parser.Nametable.BatchErrors))
                    {
                        GDataBatchError.ParseBatchErrors(reader, parser, status);
                    }
                }
            }
            return(status);
        }
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Where  object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created Where  object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            RecurrenceException exception  = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                  node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return null;
                }
            }

            exception = new RecurrenceException(); 

            if (node != null)
            {
                if (node.Attributes != null)
                {
                    if (node.Attributes[GDataParserNameTable.XmlAttributeSpecialized] != null)
                    {
                        exception.Specialized = bool.Parse(node.Attributes[GDataParserNameTable.XmlAttributeSpecialized].Value); 
                    }
                }

                if (node.HasChildNodes)
                {
                    XmlNode childNode = node.FirstChild;
                    while (childNode != null && childNode is XmlElement)
                    {
                        if (childNode.LocalName == GDataParserNameTable.XmlEntryLinkElement)
                        {
                            exception.EntryLink = EntryLink.ParseEntryLink(childNode, parser); 
                        }
                        childNode = childNode.NextSibling;
                    }
                }
                if (exception.EntryLink == null)
                {
                    throw new ArgumentException("g:recurringException/entryLink is required.");
                }
            }

            return exception; 
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Parses the inner state of the element
        /// </summary>
        /// <param name="e">The extension element that should be added to this entry</param>
        /// <param name="parser">The AtomFeedParser that called this</param>
        public virtual void Parse(ExtensionElementEventArgs e, AtomFeedParser parser)
        {
            Tracing.TraceMsg("Entering Parse on AbstractEntry");
            XmlNode node = e.ExtensionElement;
            if (this.ExtensionFactories != null && this.ExtensionFactories.Count > 0)
            {
                Tracing.TraceMsg("Entring default Parsing for AbstractEntry");

                IExtensionElementFactory f = FindExtensionFactory(node.LocalName, 
                                                                  node.NamespaceURI);
                if (f != null)
                {
                    this.ExtensionElements.Add(f.CreateInstance(node, parser));
                    e.DiscardEntry = true;
                }
            }
            return;
        }
        /// <summary>
        /// this is the subclassing method for AtomBase derived 
        /// classes to overload what childelements should be created
        /// needed to create CustomLink type objects, like WebContentLink etc
        /// </summary>
        /// <param name="reader">The XmlReader that tells us what we are working with</param>
        /// <param name="parser">the parser is primarily used for nametable comparisons</param>
        /// <returns>AtomBase</returns>
        public override AtomBase CreateAtomSubElement(XmlReader reader, AtomFeedParser parser)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (parser == null)
            {
                throw new ArgumentNullException("parser");
            }

            Object localname = reader.LocalName;
            if (localname.Equals(parser.Nametable.Category))
            {
                return new YouTubeCategory();
            }
            return base.CreateAtomSubElement(reader, parser);
        }
Ejemplo n.º 10
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>parses an xml node to create a Recurrence object</summary> 
        /// <param name="node">Recurrence node</param>
        /// <param name="parser">AtomFeedParser to use</param>
        /// <returns> the created Recurrence object</returns>
        //////////////////////////////////////////////////////////////////////
        public static RecurrenceException ParseRecurrenceException(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            RecurrenceException exception  = null;

            Tracing.Assert(node != null, "node should not be null");

            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            object localname = node.LocalName;
            if (localname.Equals(GDataParserNameTable.XmlRecurrenceExceptionElement))
            {
                exception = new RecurrenceException(); 
                if (node.Attributes != null)
                {
                    if (node.Attributes[GDataParserNameTable.XmlAttributeSpecialized] != null)
                    {
                        exception.Specialized = bool.Parse(node.Attributes[GDataParserNameTable.XmlAttributeSpecialized].Value); 
                    }
                }

                if (node.HasChildNodes)
                {
                    XmlNode childNode = node.FirstChild;
                    while (childNode != null && childNode is XmlElement)
                    {
                        if (childNode.LocalName == GDataParserNameTable.XmlEntryLinkElement)
                        {
                            exception.EntryLink = EntryLink.ParseEntryLink(childNode, parser); 
                        }
                        childNode = childNode.NextSibling;
                    }
                }
            }

            if (exception.EntryLink == null)
            {
                throw new ArgumentException("g:recurringException/entryLink is required.");
            }
            return exception; 
        }
Ejemplo n.º 11
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Where  object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created Where  object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            Comments comments = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (!localname.Equals(this.XmlName) ||
                    !node.NamespaceURI.Equals(this.XmlNameSpace))
                {
                    return null;
                }
            }

            comments = new Comments();

            if (node != null)
            {
                if (node.HasChildNodes)
                {
                    XmlNode commentsChild = node.FirstChild;
                    while (commentsChild != null && commentsChild is XmlElement)
                    {
                        if (commentsChild.LocalName == GDataParserNameTable.XmlFeedLinkElement &&
                            commentsChild.NamespaceURI == BaseNameTable.gNamespace)
                        {
                            if (comments.FeedLink == null)
                            {
                                comments.FeedLink = FeedLink.ParseFeedLink(commentsChild);
                            }
                            else
                            {
                                throw new ArgumentException("Only one feedLink is allowed inside the gd:comments");
                            }
                        }
                        commentsChild = commentsChild.NextSibling;
                    }
                }

            }
            return comments; 
        }
Ejemplo n.º 12
0
        /// <summary>
        /// parses a batchinterrupt element from a correctly positioned reader
        /// </summary>
        /// <param name="reader">XmlReader at the start of the element</param>
        /// <param name="parser">the feedparser to be used</param>
        /// <returns>GDataBatchInterrupt</returns>
        public static GDataBatchInterrupt ParseBatchInterrupt(XmlReader reader, AtomFeedParser parser)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            object localname = reader.LocalName;
            GDataBatchInterrupt interrupt = null;

            if (localname.Equals(parser.Nametable.BatchInterrupt))
            {
                interrupt = new GDataBatchInterrupt();
                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        localname = reader.LocalName;
                        if (localname.Equals(parser.Nametable.BatchReason))
                        {
                            interrupt.Reason = Utilities.DecodedValue(reader.Value);
                        }
                        else if (localname.Equals(parser.Nametable.BatchSuccessCount))
                        {
                            interrupt.Successes = int.Parse(Utilities.DecodedValue(reader.Value), CultureInfo.InvariantCulture);
                        }
                        else if (localname.Equals(parser.Nametable.BatchFailureCount))
                        {
                            interrupt.Failures = int.Parse(Utilities.DecodedValue(reader.Value), CultureInfo.InvariantCulture);
                        }
                        else if (localname.Equals(parser.Nametable.BatchParsedCount))
                        {
                            interrupt.Parsed = int.Parse(Utilities.DecodedValue(reader.Value), CultureInfo.InvariantCulture);
                        }
                        else if (localname.Equals(parser.Nametable.BatchUnprocessed))
                        {
                            interrupt.Unprocessed = int.Parse(Utilities.DecodedValue(reader.Value), CultureInfo.InvariantCulture);
                        }
                    }
                }
            }
            return(interrupt);
        }
Ejemplo n.º 13
0
        /////////////////////////////////////////////////////////////////////////////

        #endregion



        //////////////////////////////////////////////////////////////////////
        /// <summary>given a stream, parses it to construct the Feed object out of it</summary>
        /// <param name="stream"> a stream representing hopefully valid XML</param>
        /// <param name="format"> indicates if the stream is Atom or Rss</param>
        //////////////////////////////////////////////////////////////////////
        public void Parse(Stream stream, AlternativeFormat format)
        {
            Tracing.TraceCall("parsing stream -> Start:" + format.ToString());
            BaseFeedParser feedParser = null;

            // make sure we reset our collections
            this.Authors.Clear();
            this.Contributors.Clear();
            this.Links.Clear();
            this.Categories.Clear();

            feedParser = new AtomFeedParser(this);

            // create a new delegate for the parser
            feedParser.NewAtomEntry        += new FeedParserEventHandler(this.OnParsedNewEntry);
            feedParser.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewExtensionElement);
            feedParser.Parse(stream, this);

            Tracing.TraceInfo("Parsing stream -> Done");
            // done parsing
        }
Ejemplo n.º 14
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Package object.</summary> 
        /// <param name="node">Package node</param>
        /// <param name="parser">AtomFeedParser to use</param>
        /// <returns>the created Package object</returns>
        //////////////////////////////////////////////////////////////////////
        public static Package ParsePackage(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            Package package = null;
            Tracing.Assert(node != null, "node should not be null");
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            object localname = node.LocalName;
            // Ensure that the namespace is correct.
            if (String.Compare(node.NamespaceURI,
                GCodeSearchParserNameTable.CSNamespace, true) == 0)
            {
                if (localname.Equals(GCodeSearchParserNameTable.EVENT_PACKAGE))
                {
                    package = new Package();
                    if (node.Attributes != null)
                    {
                        package.name =
                            node.Attributes[
                            GCodeSearchParserNameTable.ATTRIBUTE_NAME].Value;
                        package.uri =
                            node.Attributes[
                            GCodeSearchParserNameTable.ATTRIBUTE_URI].Value;
                    }
                    else 
                    {
                        throw new ArgumentNullException(
                            BaseNameTable.gBatchNamespace +
                            ":" + GCodeSearchParserNameTable.EVENT_PACKAGE +
                            " must contain the attributes " +
                            GCodeSearchParserNameTable.ATTRIBUTE_NAME + " and " +
                            GCodeSearchParserNameTable.ATTRIBUTE_URI);
                    }
                }
            }
            return package;
        }
Ejemplo n.º 15
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Reminder object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created Reminder object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            if (node != null)
            {
                object localname = node.LocalName;
                if (!localname.Equals(this.XmlName) ||
                    !node.NamespaceURI.Equals(this.XmlNameSpace))
                {
                    return null;
                }
            }

            Recurrence recurrence = new Recurrence();

            if (node != null)
            {
                recurrence.Value = node.InnerText.Trim();
            }

            return recurrence;
        }
Ejemplo n.º 16
0
        /// <summary>eventhandler - called for event extension element
        /// </summary>
        /// <param name="sender">the object which send the event</param>
        /// <param name="e">FeedParserEventArguments, holds the feedEntry</param>
        /// <returns> </returns>
        protected void OnNewExtensionsElement(object sender, ExtensionElementEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            AtomFeedParser parser = sender as AtomFeedParser;

            if (e.Base.XmlName == AtomParserNameTable.XmlAtomEntryElement)
            {
                // the base is the Entry of the feed, let's call our parsing on the Entry
                AtomEntry entry = e.Base as AtomEntry;
                if (entry != null)
                {
                    entry.Parse(e, parser);
                }
            }
            else
            {
                HandleExtensionElements(e, parser);
            }
        }
Ejemplo n.º 17
0
        /////////////////////////////////////////////////////////////////////////////


        #endregion


        /// <summary>
        /// this is the subclassing method for AtomBase derived
        /// classes to overload what childelements should be created
        /// needed to create CustomLink type objects, like WebContentLink etc
        /// </summary>
        /// <param name="reader">The XmlReader that tells us what we are working with</param>
        /// <param name="parser">the parser is primarily used for nametable comparisons</param>
        /// <returns>AtomBase</returns>
        public override AtomBase CreateAtomSubElement(XmlReader reader, AtomFeedParser parser)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (parser == null)
            {
                throw new ArgumentNullException("parser");
            }

            Object localname = reader.LocalName;

            if (localname.Equals(parser.Nametable.Source))
            {
                return(new AtomSource());
            }
            else if (localname.Equals(parser.Nametable.Content))
            {
                return(new AtomContent());
            }
            return(base.CreateAtomSubElement(reader, parser));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// parses a list of errors
        /// </summary>
        /// <param name="reader">XmlReader positioned at the start of the status element</param>
        /// <param name="status">the batch status element to add the errors tohe</param>
        /// <param name="parser">the feedparser to be used</param>
        public static void ParseBatchErrors(XmlReader reader, AtomFeedParser parser, GDataBatchStatus status)
        {
            if (reader == null)
            {
                throw new System.ArgumentNullException("reader");
            }

            object localname = reader.LocalName;

            if (localname.Equals(parser.Nametable.BatchErrors))
            {
                int lvl = -1;
                while (Utilities.NextChildElement(reader, ref lvl))
                {
                    localname = reader.LocalName;
                    if (localname.Equals(parser.Nametable.BatchError))
                    {
                        status.Errors.Add(ParseBatchError(reader, parser));
                    }
                }
            }
            return;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// event on the Feed to handle extension elements during parsing
        /// </summary>
        /// <param name="e">the event arguments</param>
        /// <param name="parser">the parser that caused this</param>
        protected virtual void HandleExtensionElements(ExtensionElementEventArgs e, AtomFeedParser parser)
        {
            Tracing.TraceMsg("Entering HandleExtensionElements on AbstractFeed");
            XmlNode node = e.ExtensionElement;

            if (this.ExtensionFactories != null && this.ExtensionFactories.Count > 0)
            {
                Tracing.TraceMsg("Entring default Parsing for AbstractFeed");
                foreach (IExtensionElementFactory f in this.ExtensionFactories)
                {
                    Tracing.TraceMsg("Found extension Factories");
                    if (String.Compare(node.NamespaceURI, f.XmlNameSpace, true, CultureInfo.InvariantCulture) == 0)
                    {
                        if (String.Compare(node.LocalName, f.XmlName, true, CultureInfo.InvariantCulture) == 0)
                        {
                            e.Base.ExtensionElements.Add(f.CreateInstance(node, parser));
                            e.DiscardEntry = true;
                            break;
                        }
                    }
                }
            }
            return;
        }
Ejemplo n.º 20
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Where  object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created Where  object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            When when = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                  node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return null;
                }
            }

            bool startTimeFlag = false, endTimeFlag = false;

            when = new When();
            if (node != null)
            {
                if (node.Attributes != null)
                {
                    String value = node.Attributes[GDataParserNameTable.XmlAttributeStartTime] != null ? 
                        node.Attributes[GDataParserNameTable.XmlAttributeStartTime].Value : null; 
                    if (value != null)
                    {
                        startTimeFlag = true;
                        when.startTime = DateTime.Parse(value);
                        when.AllDay = (value.IndexOf('T') == -1); 
                    }
                
                    value = node.Attributes[GDataParserNameTable.XmlAttributeEndTime] != null ? 
                        node.Attributes[GDataParserNameTable.XmlAttributeEndTime].Value : null; 
                
                    if (value != null)
                    {
                        endTimeFlag = true;
                        when.endTime = DateTime.Parse(value); 
                        when.AllDay = when.AllDay && (value.IndexOf('T') == -1); 
                    }
                
                    if (node.Attributes[GDataParserNameTable.XmlAttributeValueString] != null)
                    {
                        when.valueString = node.Attributes[GDataParserNameTable.XmlAttributeValueString].Value;
                    }
                }
                // single event, g:reminder is inside g:when
                if (node.HasChildNodes)
                {
                    XmlNode whenChildNode = node.FirstChild;
                    IExtensionElementFactory f = new Reminder() as IExtensionElementFactory;
                    while (whenChildNode != null && whenChildNode is XmlElement)
                    {
                        if (String.Compare(whenChildNode.NamespaceURI, f.XmlNameSpace, true, CultureInfo.InvariantCulture) == 0)
                        {
                            if (String.Compare(whenChildNode.LocalName, f.XmlName, true, CultureInfo.InvariantCulture) == 0)
                            {
                                Reminder r = f.CreateInstance(whenChildNode, null) as Reminder;
                                when.Reminders.Add(r);
                            }
                        }
                        whenChildNode = whenChildNode.NextSibling;
                    }
                }
            }
            
            if (!startTimeFlag)
            {
                throw new ClientFeedException("g:when/@startTime is required.");
            }

            if (endTimeFlag && when.startTime.CompareTo(when.endTime) > 0)
            {
                throw new ClientFeedException("g:when/@startTime must be less than or equal to g:when/@endTime.");
            }

            return when;
        }
Ejemplo n.º 21
0
 //////////////////////////////////////////////////////////////////////
 /// <summary>Parses an xml node to create a Package object.</summary> 
 /// <param name="node">xml node</param>
 /// <param name="parser">the atomfeedparser to use for deep dive parsing</param>
 /// <returns>the created IExtensionElementFactory object</returns>
 //////////////////////////////////////////////////////////////////////
 public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
 {
     return ParsePackage(node, parser);
 }
        // end of accessor public SortedList GadgetPreferences


        #region WebContent Parser

        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a webcontent object.</summary> 
        /// <param name="node">xml node</param>
        /// <param name="parser">the atomfeedparser to use for deep dive parsing</param>
        /// <returns>the created SimpleElement object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser) 
        {
            Tracing.TraceCall();

            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                    node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return null;
                }
            }
            
            WebContent webContent = null;
          
            webContent = new WebContent();
            if (node.Attributes != null)
            {
                String value = node.Attributes[GDataParserNameTable.XmlAttributeUrl] != null ? 
                    node.Attributes[GDataParserNameTable.XmlAttributeUrl].Value : null; 
                if (value != null)
                {
                    webContent.Url = value;
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeDisplay] != null ?
                    node.Attributes[GDataParserNameTable.XmlAttributeDisplay].Value : null;
                if (value != null)
                {
                    webContent.Display = value;
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeWidth] != null ? 
                    node.Attributes[GDataParserNameTable.XmlAttributeWidth].Value : null; 

                if (value != null)
                {
                    webContent.Width = uint.Parse(value, System.Globalization.NumberStyles.Integer, CultureInfo.InvariantCulture);
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeHeight] != null ? 
                    node.Attributes[GDataParserNameTable.XmlAttributeHeight].Value : null; 

                if (value != null)
                {
                    webContent.Height = uint.Parse(value, System.Globalization.NumberStyles.Integer, CultureInfo.InvariantCulture);
                }
            }
              // single event, g:reminder is inside g:when
            if (node.HasChildNodes)
            {
                XmlNode gadgetPrefs = node.FirstChild;
                while (gadgetPrefs != null && gadgetPrefs is XmlElement)
                {
                    if (String.Compare(gadgetPrefs.NamespaceURI, XmlNameSpace, true) == 0)
                    {
                        if (String.Compare(gadgetPrefs.LocalName, GDataParserNameTable.XmlWebContentGadgetElement) == 0)
                        {
                            if (gadgetPrefs.Attributes != null)
                            {
                                string value = gadgetPrefs.Attributes[BaseNameTable.XmlValue] != null ? 
                                               gadgetPrefs.Attributes[BaseNameTable.XmlValue].Value : null;

                                string name  = gadgetPrefs.Attributes[BaseNameTable.XmlName] != null ?
                                               gadgetPrefs.Attributes[BaseNameTable.XmlName].Value : null;

                                if (name != null)
                                {
                                    webContent.GadgetPreferences.Add(name, value);
                                }
                            }
                        }
                    }
                    gadgetPrefs = gadgetPrefs.NextSibling;
                }
            }
            return webContent;
        }
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Reminder object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created Reminder object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            Reminder reminder = null;
          
            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                    node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return null;
                }
            }

            reminder = new Reminder();
            if (node != null && node.Attributes != null)
            {
                if (node.Attributes[GDataParserNameTable.XmlAttributeAbsoluteTime] != null)
                {
                    try
                    {
                        reminder.AbsoluteTime =
                        DateTime.Parse(node.Attributes[GDataParserNameTable.XmlAttributeAbsoluteTime].Value);
                    }
                    catch (FormatException fe)
                    {
                        throw new ArgumentException("Invalid g:reminder/@absoluteTime.", fe);
                    }
                }

                if (node.Attributes[GDataParserNameTable.XmlAttributeDays] != null)
                {
                    try
                    {
                        reminder.Days = Int32.Parse(node.Attributes[GDataParserNameTable.XmlAttributeDays].Value);
                    }
                    catch (FormatException fe)
                    {
                        throw new ArgumentException("Invalid g:reminder/@days.", fe);
                    }
                }

                if (node.Attributes[GDataParserNameTable.XmlAttributeHours] != null)
                {
                    try
                    {
                        reminder.Hours = Int32.Parse(node.Attributes[GDataParserNameTable.XmlAttributeHours].Value);
                    }
                    catch (FormatException fe)
                    {
                        throw new ArgumentException("Invalid g:reminder/@hours.", fe);
                    }
                }

                if (node.Attributes[GDataParserNameTable.XmlAttributeMinutes] != null)
                {
                    try
                    {
                        reminder.Minutes = Int32.Parse(node.Attributes[GDataParserNameTable.XmlAttributeMinutes].Value);
                    }
                    catch (FormatException fe)
                    {
                        throw new ArgumentException("Invalid g:reminder/@minutes.", fe);
                    }
                }

                if (node.Attributes[GDataParserNameTable.XmlAttributeMethod] != null)
                {
                    try
                    {
                        reminder.Method = (ReminderMethod)Enum.Parse(typeof(ReminderMethod), 
                                                                     node.Attributes[GDataParserNameTable.XmlAttributeMethod].Value,
                                                                     true);
                    }
                    catch (Exception e)
                    {
                        throw new ArgumentException("Invalid g:reminder/@method.", e);
                    }
                }
            }
            return reminder;
        }
Ejemplo n.º 24
0
 /// <summary>
 /// creates a new GDataBatchEntryData
 /// </summary>
 /// <param name="node"></param>
 /// <param name="parser"></param>
 /// <returns></returns>
 public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser) {
     //we really don't know how to create an instance of ourself.
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Is called after we already handled the custom entry, to handle all 
 /// other potential parsing tasks
 /// </summary>
 /// <param name="e"></param>
 /// <param name="parser">the atom feed parser used</param>
 protected override void HandleExtensionElements(ExtensionElementEventArgs e,
     AtomFeedParser parser) {
     base.HandleExtensionElements(e, parser);
 }
Ejemplo n.º 26
0
        /// <summary>Parses an xml node to create an instance object.</summary> 
        /// <param name="node">the parsed xml node, can be NULL</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created SimpleElement object</returns>
        public override IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser) {
            Tracing.TraceCall();

            SimpleElement e = null;

            if (node != null) {
                object localname = node.LocalName;
                if (!localname.Equals(this.XmlName) ||
                    !node.NamespaceURI.Equals(this.XmlNameSpace)) {
                    return null;
                }
            }

            // memberwise close is fine here, as everything is identical besides the value
            e = this.MemberwiseClone() as SimpleElement;
            e.InitInstance(this);

            if (node != null) {
                e.ProcessAttributes(node);
                if (node.HasChildNodes) {
                    XmlNode n = node.ChildNodes[0];
                    if (n.NodeType == XmlNodeType.Text && node.ChildNodes.Count == 1) {
                        e.Value = node.InnerText;
                    } else {
                        e.ProcessChildNodes(node, parser);
                    }
                }
            }

            return e;
        }
Ejemplo n.º 27
0
 /// <summary>
 /// creates a new GDataBatchEntryData
 /// </summary>
 /// <param name="node"></param>
 /// <param name="parser"></param>
 /// <returns></returns>
 public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
 {
     //we really don't know how to create an instance of ourself.
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 28
0
 /// <summary>
 /// factory method to create an instance of a batchinterrupt during parsing
 /// </summary>
 /// <param name="node">the xmlnode that is going to be parsed</param>
 /// <param name="parser">the feedparser that is used right now</param>
 /// <returns></returns>
 public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
 {
     return(ParseBatchInterrupt(new XmlNodeReader(node), parser));
 }
Ejemplo n.º 29
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Who object.</summary> 
        /// <param name="node">the xml parses node, can be NULL</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created IExtensionElement object</returns>
        //////////////////////////////////////////////////////////////////////
        public override IExtensionElement CreateInstance(XmlNode node, AtomFeedParser parser) 
        {
            IExtensionElement ele = base.CreateInstance(node, parser);

            OriginalEvent ev = ele as OriginalEvent;
            if (ev != null)
            {
                if (ev.IdOriginal == null)
                {
                    throw new ArgumentException("g:originalEvent/@id is required.");
                }
    
                if (ev.OriginalStartTime == null)
                {
                    throw new ArgumentException("g:when inside g:originalEvent is required.");
                }
            }

            return ev;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// this is the subclassing method for AtomBase derived 
        /// classes to overload what childelements should be created
        /// needed to create CustomLink type objects, like WebContentLink etc
        /// </summary>
        /// <param name="reader">The XmlReader that tells us what we are working with</param>
        /// <param name="parser">the parser is primarily used for nametable comparisons</param>
        /// <returns>AtomBase</returns>
        public virtual AtomBase CreateAtomSubElement(XmlReader reader, AtomFeedParser parser)
        {
            Object localname = reader.LocalName;
            if (localname.Equals(parser.Nametable.Id))
            {
                return new AtomId();
            }
            else if (localname.Equals(parser.Nametable.Link))
            {
                return new AtomLink();
            } 
            else if (localname.Equals(parser.Nametable.Icon))
            {
                return new AtomIcon();
            } 
            else if (localname.Equals(parser.Nametable.Logo))
            {
                return new AtomLogo();
            } else if (localname.Equals(parser.Nametable.Author)) 
            {
                return new AtomPerson(AtomPersonType.Author);
            }
            else if (localname.Equals(parser.Nametable.Contributor)) 
            {
                return new AtomPerson(AtomPersonType.Contributor);
            } else if (localname.Equals(parser.Nametable.Title))
            {
                return new AtomTextConstruct(AtomTextConstructElementType.Title);
            } else if (localname.Equals(parser.Nametable.Subtitle))
            {
                return new AtomTextConstruct(AtomTextConstructElementType.Subtitle);
            } else if (localname.Equals(parser.Nametable.Rights))
            {
                return new AtomTextConstruct(AtomTextConstructElementType.Rights);
            } else if (localname.Equals(parser.Nametable.Summary))
            {
                return new AtomTextConstruct(AtomTextConstructElementType.Summary);
             
            } else if (localname.Equals(parser.Nametable.Generator))
            {
                return new AtomGenerator();
            } else if (localname.Equals(parser.Nametable.Category))
            {
                return new AtomCategory();
            }

            throw new NotImplementedException("AtomBase CreateChild should NEVER be called for: " + reader.LocalName);
        }
 /// <summary>
 /// get's called after we already handled the custom entry, to handle all 
 /// other potential parsing tasks
 /// </summary>
 /// <param name="e">the event arguments</param>
 /// <param name="parser">the atom feed parser calling</param>
 protected override void HandleExtensionElements(ExtensionElementEventArgs e, AtomFeedParser parser)
 {
      Tracing.TraceMsg("\t HandleExtensionElements for ListFeedcalled");
 }
Ejemplo n.º 32
0
 /// <summary>
 /// used to copy the unknown childnodes for later saving
 /// </summary>
 public virtual void ProcessChildNodes(XmlNode node, AtomFeedParser parser) {
     if (node != null && node.HasChildNodes) {
         XmlNode childNode = node.FirstChild;
         while (childNode != null) {
             if (childNode.NodeType == XmlNodeType.Element) {
                 this.ChildNodes.Add(childNode);
             }
             childNode = childNode.NextSibling;
         }
     }
 }
 public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
 {
     return ParseGBaseAttribute(node);
 }
Ejemplo n.º 34
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Where  object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created Where  object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            Where where = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (!localname.Equals(this.XmlName) ||
                    !node.NamespaceURI.Equals(this.XmlNameSpace))
                {
                    return null;
                }
            }

            where = new Where();
            if (node != null) {

                if (node.Attributes != null)
                {
                    if (node.Attributes[GDataParserNameTable.XmlAttributeRel] != null)
                    {
                        where.Rel = node.Attributes[GDataParserNameTable.XmlAttributeRel].Value;
                    }
    
                    if (node.Attributes[GDataParserNameTable.XmlAttributeLabel] != null)
                    {
                        where.Label = node.Attributes[GDataParserNameTable.XmlAttributeLabel].Value;
                    }
    
                    if (node.Attributes[GDataParserNameTable.XmlAttributeValueString] != null)
                    {
                        where.ValueString = node.Attributes[GDataParserNameTable.XmlAttributeValueString].Value;
                    }
                }
    
                if (node.HasChildNodes)
                {
                    foreach (XmlNode childNode in node.ChildNodes)
                    {
                        if (childNode.LocalName == GDataParserNameTable.XmlEntryLinkElement)
                        {
                            if (where.EntryLink == null)
                            {
                                where.EntryLink = EntryLink.ParseEntryLink(childNode, parser);
                            }
                            else
                            {
                                throw new ArgumentException("Only one entryLink is allowed inside the g:where");
                            }
                        }
                    }
                }
            }
            return where;
        }
Ejemplo n.º 35
0
        /// <summary>
        /// retrieves a category collection from the given URL
        /// The owner should be a new Collection object, like:
        /// <code>
        ///		GetCategories(new Uri("http://gdata.youtube.com/schemas/2007/categories.cat"), 
        ///					  new YouTubeCategoryCollection())
        /// </code>
        /// </summary>
        /// <returns></returns>
        public static AtomCategoryCollection GetCategories(Uri uri, AtomBase owner) {
            // first order is to get the document into an xml dom
            XmlTextReader textReader = new XmlTextReader(uri.AbsoluteUri);

            AtomFeedParser parser = new AtomFeedParser();
            AtomCategoryCollection collection = parser.ParseCategories(textReader, owner);
            return collection;
        }
Ejemplo n.º 36
0
 /// <summary>
 /// factory method to create an instance of a batchinterrupt during parsing
 /// </summary>
 /// <param name="node">the xmlnode that is going to be parsed</param>
 /// <param name="parser">the feedparser that is used right now</param>
 /// <returns></returns>
 public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 37
0
        /// <summary>
        /// this is the subclassing method for AtomBase derived
        /// classes to overload what childelements should be created
        /// needed to create CustomLink type objects, like WebContentLink etc
        /// </summary>
        /// <param name="reader">The XmlReader that tells us what we are working with</param>
        /// <param name="parser">the parser is primarily used for nametable comparisons</param>
        /// <returns>AtomBase</returns>
        public virtual AtomBase CreateAtomSubElement(XmlReader reader, AtomFeedParser parser)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (parser == null)
            {
                throw new ArgumentNullException("parser");
            }

            Object localname = reader.LocalName;

            if (localname.Equals(parser.Nametable.Id))
            {
                return(new AtomId());
            }
            else if (localname.Equals(parser.Nametable.Link))
            {
                return(new AtomLink());
            }
            else if (localname.Equals(parser.Nametable.Icon))
            {
                return(new AtomIcon());
            }
            else if (localname.Equals(parser.Nametable.Logo))
            {
                return(new AtomLogo());
            }
            else if (localname.Equals(parser.Nametable.Author))
            {
                return(new AtomPerson(AtomPersonType.Author));
            }
            else if (localname.Equals(parser.Nametable.Contributor))
            {
                return(new AtomPerson(AtomPersonType.Contributor));
            }
            else if (localname.Equals(parser.Nametable.Title))
            {
                return(new AtomTextConstruct(AtomTextConstructElementType.Title));
            }
            else if (localname.Equals(parser.Nametable.Subtitle))
            {
                return(new AtomTextConstruct(AtomTextConstructElementType.Subtitle));
            }
            else if (localname.Equals(parser.Nametable.Rights))
            {
                return(new AtomTextConstruct(AtomTextConstructElementType.Rights));
            }
            else if (localname.Equals(parser.Nametable.Summary))
            {
                return(new AtomTextConstruct(AtomTextConstructElementType.Summary));
            }
            else if (localname.Equals(parser.Nametable.Generator))
            {
                return(new AtomGenerator());
            }
            else if (localname.Equals(parser.Nametable.Category))
            {
                return(new AtomCategory());
            }

            throw new NotImplementedException("AtomBase CreateChild should NEVER be called for: " + reader.LocalName);
        }
Ejemplo n.º 38
0
        /// <summary>Parses an xml node to create an instance of this  object.</summary> 
        /// <param name="node">the xml parses node, can be NULL</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created IExtensionElement object</returns>
        public virtual IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser) {
            Tracing.TraceCall();

            ExtensionBase e = null;

            if (node != null) {
                object localname = node.LocalName;
                if (!localname.Equals(this.XmlName) ||
                    !node.NamespaceURI.Equals(this.XmlNameSpace)) {
                    return null;
                }
            }
            // memberwise close is fine here, as everything is identical beside the value
            e = this.MemberwiseClone() as ExtensionBase;
            e.InitInstance(this);

            e.ProcessAttributes(node);
            e.ProcessChildNodes(node, parser);

            return e;
        }
Ejemplo n.º 39
0
        // end of accessor public ArrayList Extensions


        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Who object.</summary> 
        /// <param name="node">the node to work on, can be NULL</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created SimpleElement object</returns>
        //////////////////////////////////////////////////////////////////////
        public override IExtensionElement CreateInstance(XmlNode node, AtomFeedParser parser) 
        {
            Tracing.TraceCall("for: " + XmlName);

            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                    node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return null;
                }
            }

            SimpleContainer sc = null;            
            // create a new container
            sc = this.MemberwiseClone() as SimpleContainer;
      
            if (node != null && node.HasChildNodes)
            {
                XmlNode childNode = node.FirstChild;
                while (childNode != null && childNode is XmlElement)
                {
                    foreach (IExtensionElementFactory f in this.ExtensionFactories)
                    {
                        if (String.Compare(childNode.NamespaceURI, f.XmlNameSpace) == 0)
                        {
                            if (String.Compare(childNode.LocalName, f.XmlName) == 0)
                            {
                                Tracing.TraceMsg("Added extension to SimpleContainer for: " + f.XmlName);
                                sc.ExtensionElements.Add(f.CreateInstance(childNode, parser));
                                break;
                            }
                        }
                    }
                    childNode = childNode.NextSibling;
                }
                if (node.Attributes != null)
                {
                    sc.ProcessAttributes(node);
                }
            }
            return sc;
        }
Ejemplo n.º 40
0
        /////////////////////////////////////////////////////////////////////////////


        #region EntryLink Parser
        //////////////////////////////////////////////////////////////////////
        /// <summary>parses an xml node to create an EntryLink object</summary> 
        /// <param name="node">entrylink node</param>
        /// <param name="parser">AtomFeedParser to use</param>
        /// <returns> the created EntryLink object</returns>
        //////////////////////////////////////////////////////////////////////
        public static EntryLink ParseEntryLink(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            EntryLink link = null;
            Tracing.Assert(node != null, "node should not be null");
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            

            object localname = node.LocalName;
            if (localname.Equals(GDataParserNameTable.XmlEntryLinkElement))
            {
                link = new EntryLink();
                if (node.Attributes != null)
                {
                    if (node.Attributes[GDataParserNameTable.XmlAttributeHref] != null)
                    {
                        link.Href = node.Attributes[GDataParserNameTable.XmlAttributeHref].Value;
                    }

                    if (node.Attributes[GDataParserNameTable.XmlAttributeReadOnly] != null)
                    {
                        link.ReadOnly = node.Attributes[GDataParserNameTable.XmlAttributeReadOnly].Value.Equals(Utilities.XSDTrue);
                    }

                    if (node.Attributes[GDataParserNameTable.XmlAttributeRel] != null)
                    {
                        link.Rel = node.Attributes[GDataParserNameTable.XmlAttributeRel].Value;
                    }

                }

                if (node.HasChildNodes)
                {
                    XmlNode entryChild = node.FirstChild;

                    while (entryChild != null && entryChild is XmlElement)
                    {
                        if (entryChild.LocalName == AtomParserNameTable.XmlAtomEntryElement &&
                            entryChild.NamespaceURI == BaseNameTable.NSAtom)
                        {

                            if (link.Entry == null)
                            {
                                XmlReader reader = new XmlNodeReader(entryChild);
                                // move the reader to the first node
                                reader.Read();
                                parser.NewAtomEntry += new FeedParserEventHandler(link.OnParsedNewEntry); 
                                parser.ParseEntry(reader); 
                            }
                            else
                            {
                                throw new ArgumentException("Only one entry is allowed inside the g:entryLink");
                            }
                        }
                        entryChild = entryChild.NextSibling;
                    }
                }

            }

            return link;
        }
Ejemplo n.º 41
0
 //////////////////////////////////////////////////////////////////////
 /// <summary>Parses an xml node to create a Where  object.</summary> 
 /// <param name="node">the node to parse node</param>
 /// <param name="parser">the xml parser to use if we need to dive deeper</param>
 /// <returns>the created Where  object</returns>
 //////////////////////////////////////////////////////////////////////
 public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
 {
     return FeedLink.ParseFeedLink(node);
 }
Ejemplo n.º 42
0
        /// <summary>
        /// this is the subclassing method for AtomBase derived 
        /// classes to overload what childelements should be created
        /// needed to create CustomLink type objects, like WebContentLink etc
        /// </summary>
        /// <param name="reader">The XmlReader that tells us what we are working with</param>
        /// <param name="parser">the parser is primarily used for nametable comparisons</param>
        /// <returns>AtomBase</returns>
        public override AtomBase CreateAtomSubElement(XmlReader reader, AtomFeedParser parser)
        {
            Object localname = reader.LocalName;

            if ((localname.Equals(parser.Nametable.Link)))
            {
                if (reader.GetAttribute(GDataParserNameTable.XmlAttributeRel) == 
                    WebContentLink.WEB_CONTENT_REL)
                {
                    return new WebContentLink(false);
                }
            }
            return base.CreateAtomSubElement(reader, parser);
            
        }
Ejemplo n.º 43
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>parses the inner state of the element</summary>
        /// <param name="e">the extensionelement during the parsing process, xml node</param>
        /// <param name="parser">the atomFeedParser that called this</param>
        //////////////////////////////////////////////////////////////////////
        public override void Parse(ExtensionElementEventArgs e, AtomFeedParser parser)
        {
            Tracing.TraceCall("AclEntry:Parse is called:" + e);
            XmlNode node = e.ExtensionElement;
 
            if (String.Compare(node.NamespaceURI, AclNameTable.gAclNamespace, true) == 0)
            {
                // Parse a Role Element
                if (node.LocalName == AclNameTable.XmlAclRoleElement)
                {
                    this.Role = AclRole.parse(node);
                    e.DiscardEntry = true;
                }
                // Parse a Where Element
                else if (node.LocalName == AclNameTable.XmlAclScopeElement)
                {
                    this.Scope = AclScope.parse(node);
                    e.DiscardEntry = true;
                }
            }
        }