本文整理汇总了C#中Google.GData.Client.AtomFeedParser类的典型用法代码示例。如果您正苦于以下问题:C# AtomFeedParser类的具体用法?C# AtomFeedParser怎么用?C# AtomFeedParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AtomFeedParser类属于Google.GData.Client命名空间,在下文中一共展示了AtomFeedParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
//////////////////////////////////////////////////////////////////////
/// <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;
}
}
}
示例2: CreateInstance
//////////////////////////////////////////////////////////////////////
/// <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;
}
示例3: ParseFile
//////////////////////////////////////////////////////////////////////
/// <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;
}
示例4: CreateInstance
//////////////////////////////////////////////////////////////////////
/// <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;
}
示例5: Parse
/// <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;
}
示例6: CreateAtomSubElement
/// <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);
}
示例7: ParseRecurrenceException
//////////////////////////////////////////////////////////////////////
/// <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;
}
示例8: CreateInstance
//////////////////////////////////////////////////////////////////////
/// <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;
}
示例9: ParsePackage
//////////////////////////////////////////////////////////////////////
/// <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;
}
示例10: CreateInstance
//////////////////////////////////////////////////////////////////////
/// <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;
}
示例11: CreateInstance
//////////////////////////////////////////////////////////////////////
/// <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;
}
示例12: CreateInstance
//////////////////////////////////////////////////////////////////////
/// <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);
}
示例13: CreateInstance
// 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;
}
示例14: CreateInstance
/// <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.");
}
示例15: HandleExtensionElements
/// <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);
}