/// <summary>Constructor, given a category as a string from the URI.</summary> public QueryCategory(string strCategory, QueryCategoryOperator op) { Tracing.TraceMsg("Depersisting category from: " + strCategory); _categoryOperator = op; strCategory = FeedQuery.CleanPart(strCategory); // let's parse the string if (strCategory[0] == '-') { // negator _isExcluded = true; // remove him strCategory = strCategory.Substring(1, strCategory.Length - 1); } // let's extract the scheme if there is one... int iStart = strCategory.IndexOf('{'); int iEnd = strCategory.IndexOf('}'); AtomUri scheme = null; if (iStart != -1 && iEnd != -1) { iEnd++; iStart++; scheme = new AtomUri(strCategory.Substring(iStart, iEnd - iStart - 1)); // the rest is then strCategory = strCategory.Substring(iEnd, strCategory.Length - iEnd); } Tracing.TraceMsg("Category found: " + strCategory + " - scheme: " + scheme); _category = new AtomCategory(strCategory, scheme); }
/// <summary>just go down the child collections</summary> /// <param name="uriBase"> as currently calculated</param> internal override void BaseUriChanged(AtomUri uriBase) { base.BaseUriChanged(uriBase); // now pass it to the properties. uriBase = new AtomUri(Utilities.CalculateUri(Base, uriBase, null)); if (Title != null) { Title.BaseUriChanged(uriBase); } if (Id != null) { Id.BaseUriChanged(uriBase); } foreach (AtomLink link in Links) { link.BaseUriChanged(uriBase); } foreach (AtomPerson person in Authors) { person.BaseUriChanged(uriBase); } foreach (AtomPerson person in Contributors) { person.BaseUriChanged(uriBase); } foreach (AtomCategory category in Categories) { category.BaseUriChanged(uriBase); } if (Rights != null) { Rights.BaseUriChanged(uriBase); } if (Summary != null) { Summary.BaseUriChanged(uriBase); } if (Content != null) { Content.BaseUriChanged(uriBase); } if (Source != null) { Source.BaseUriChanged(uriBase); } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>default constructor</summary> /// <param name="uriBase">the location the feed was loaded from</param> /// <param name="service">the service used to create this feed</param> ////////////////////////////////////////////////////////////////////// public AtomFeed(Uri uriBase, IService service) : base() { Tracing.TraceCall("Constructing AtomFeed"); if (uriBase != null) { ImpliedBase = new AtomUri(uriBase.AbsoluteUri); } Service = service; NewExtensionElement += new ExtensionElementEventHandler(OnNewExtensionsElement); }
/// <summary>public static string CalculateUri(string base, string inheritedBase, string local)</summary> /// <param name="localBase">the baseUri from xml:base </param> /// <param name="inheritedBase">the pushed down baseUri from an outer element</param> /// <param name="localUri">the Uri value</param> /// <returns>the absolute Uri to use... </returns> internal static string CalculateUri(AtomUri localBase, AtomUri inheritedBase, string localUri) { try { Uri uriBase = null; Uri uriSuperBase = null; Uri uriComplete = null; if (inheritedBase != null && inheritedBase.ToString() != null) { uriSuperBase = new Uri(inheritedBase.ToString()); } if (localBase != null && localBase.ToString() != null) { if (uriSuperBase != null) { uriBase = new Uri(uriSuperBase, localBase.ToString()); } else { uriBase = new Uri(localBase.ToString()); } } else { // if no local xml:base, take the passed down one uriBase = uriSuperBase; } if (localUri != null) { if (uriBase != null) { uriComplete = new Uri(uriBase, localUri.ToString()); } else { uriComplete = new Uri(localUri.ToString()); } } else { uriComplete = uriBase; } return(uriComplete != null ? uriComplete.AbsoluteUri : null); } catch (System.UriFormatException) { return("Unsupported URI format"); } }
///////////////////////////////////////////////////////////////////////////// #region overloaded for property changes, xml:base ////////////////////////////////////////////////////////////////////// /// <summary>just go down the child collections</summary> /// <param name="uriBase"> as currently calculated</param> ////////////////////////////////////////////////////////////////////// internal override void BaseUriChanged(AtomUri uriBase) { base.BaseUriChanged(uriBase); // now walk over the entries and forward... uriBase = new AtomUri(Utilities.CalculateUri(Base, uriBase, null)); foreach (AtomEntry entry in Entries) { entry.BaseUriChanged(uriBase); } }
/// <summary>comparison method similar to strings</summary> public static int Compare(AtomUri oneAtomUri, AtomUri anotherAtomUri) { if (oneAtomUri != null) { return(oneAtomUri.CompareTo(anotherAtomUri)); } else if (anotherAtomUri == null) { return(0); } return(-1); }
/// <summary>helper method to encapsulate a string encoding, uses HTML encoding now</summary> /// <param name="writer">the xml writer to write to</param> /// <param name="content">the string to encode</param> protected static void WriteEncodedString(XmlWriter writer, AtomUri content) { if (writer == null) { throw new System.ArgumentNullException("writer", "No valid xmlWriter"); } if (Utilities.IsPersistable(content)) { string encoded = Utilities.EncodeString(content.ToString()); writer.WriteString(encoded); } }
/// <summary> /// finds a category with a given term and scheme /// </summary> /// <param name="term"></param> /// <param name="scheme"></param> /// <returns>AtomCategory or NULL</returns> public AtomCategory Find(string term, AtomUri scheme) { foreach (AtomCategory category in List) { if (scheme == null || scheme == category.Scheme) { if (term == category.Term) { return(category); } } } return(null); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>public AtomId(string uri)</summary> /// <param name="link">the URI for the ID</param> /// <returns> </returns> ////////////////////////////////////////////////////////////////////// public AtomId(string link) : base() { Uri = new AtomUri(link); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>Category constructor</summary> /// <param name="term">the term of the category</param> /// <param name="scheme">the scheme of the category</param> ////////////////////////////////////////////////////////////////////// public AtomCategory(string term, AtomUri scheme) { Term = term; Scheme = scheme; }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>Category constructor</summary> /// <param name="term">the term of the category</param> /// <param name="scheme">the scheme of the category</param> /// <param name="label"> the label for the category</param> ////////////////////////////////////////////////////////////////////// public AtomCategory(string term, AtomUri scheme, string label) { Term = term; Scheme = scheme; _label = label; }
/// <summary>Little helper that checks if a string is XML persistable</summary> public static bool IsPersistable(AtomUri uriString) { return(uriString == null ? false : Utilities.IsPersistable(uriString.ToString())); }
/// <summary>helper method to encapsulate encoding, uses HTML encoding now</summary> /// <param name="writer">the xml writer to write to</param> /// <param name="elementName">the attribute the write</param> /// <param name="content">the string to encode</param> protected static void WriteEncodedElementString(XmlWriter writer, string elementName, AtomUri content) { if (writer == null) { throw new ArgumentNullException("writer"); } if (Utilities.IsPersistable(content)) { string encoded = Utilities.EncodeString(content.ToString()); writer.WriteElementString(elementName, BaseNameTable.NSAtom, encoded); } }
/// <summary>This starts the calculation, to push down the base /// URI changes.</summary> /// <param name="uriValue">the baseuri calculated so far</param> internal virtual void BaseUriChanged(AtomUri uriValue) { // if this is ever getting called explicitly (parsing), we turn on recalc _fAllowRecalc = true; _uriImpliedBase = uriValue; }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>public AtomLink(string uri)</summary> /// <param name="link">the uri for the link </param> ////////////////////////////////////////////////////////////////////// public AtomLink(string link) { HRef = new AtomUri(link); }
/// <summary>just go down the child collections</summary> /// <param name="uriBase"> as currently calculated</param> internal override void BaseUriChanged(AtomUri uriBase) { base.BaseUriChanged(uriBase); foreach (AtomPerson person in Authors) { person.BaseUriChanged(uriBase); } // saving Contributors foreach (AtomPerson person in Contributors) { person.BaseUriChanged(uriBase); } // saving Categories foreach (AtomCategory category in Categories) { category.BaseUriChanged(uriBase); } // saving the generator if (Generator != null) { Generator.BaseUriChanged(uriBase); } // save the icon if (Icon != null) { Icon.BaseUriChanged(uriBase); } // save the logo if (Logo != null) { Logo.BaseUriChanged(uriBase); } // save the ID if (Id != null) { Id.BaseUriChanged(uriBase); } // save the Links foreach (AtomLink link in Links) { link.BaseUriChanged(uriBase); } if (Rights != null) { Rights.BaseUriChanged(uriBase); } if (Subtitle != null) { Subtitle.BaseUriChanged(uriBase); } if (Title != null) { Title.BaseUriChanged(uriBase); } }